Слово
«nbbytes»впервые сказано пользователем
belkins 25.02.2009 в 20:40,
и с тех пор употреблялось
9 раз.
Сообщения со словом
«nbbytes»
Запрос выполнился за
0.0048 сек.
- 25.02.2009, 20:40. belkins в теме
«программирование звука unix»
... buf size float input buf size char cbits 2000 int nbbytes holds the state of the encoder void state holds bits so they can be read and written to by the speex routines speexbits bits int i tmp int tmp rate if argc 2 printf команда s filename rate n argv 0 return exit success create a new encoder state in narrowband mode state speex encoder init speex nb mode set the quality to 8 15 kbps tmp 8 speex encoder ctl state speex set quality tmp speex encoder ctl state speex get sampling rate tmp rate printf rate i tmp rate out fd open argv 1 o creat o wronly 0777 fout fopen argv 1 w audio fd open dev dsp o rdonly 0 atexit onexit format afmt s16 le ioctl audio fd sndctl dsp setfmt format if format afmt s16 le printf ошибка запрошенный формат не поддерживается return exit failure nchans 1 ioctl audio fd sndctl dsp channels nchans if argc 3 rate atoi argv 2 else rate 8000 ioctl audio fd sndctl dsp speed rate printf используемая частота дискретизации i гц n rate initialization of the structure that holds the bits speex bits init bits for count 0 count rate 5 nchans count actlen actlen read audio fd buf buf size copy the 16 bits values to float so speex can work on them for i 0 i buf size i input i buf i printf ok n flush all the bits in the struct so we can encode a new frame speex bits reset bits encode the frame i speex encode int state buf bits printf encode i n i copy the bits to an array of char that can be written nbbytes speex bits write bits cbits 2000 write the size of the frame first this is what sampledec expects but it s likely to be different in your own application fwrite nbbytes sizeof int 1 fout write the compressed data fwrite cbits 1 nbbytes fout write out fd buf actlen printf i n actlen destroy the encoder state speex encoder destroy state destroy the bit-packing struct speex bits destroy bits fclose fin fclose fout return exit success это я декодирую и воспроизвожу код include speex speex h include stdio h include stdio h include stdlib h include sys ioctl h include unistd h include fcntl h include sys soundcard h define buf size 160 define frame size 160 int main int argc char argv int audio fd in fd format int nchans rate actlen short buf buf size char outfile file fout fin holds the audio that will be written to file 16 bits per sample short out frame size speex handle samples as float so we need an array of floats float output frame size char cbits 200 int nbbytes holds the state of the decoder void state holds bits so they can be read and written to by the speex routines speexbits bits int i tmp if argc 2 printf команда s filename rate n argv 0 return exit success in fd open argv 1 o rdonly audio fd open dev dsp o wronly 0 format afmt s16 le ioctl audio fd sndctl dsp setfmt format if format afmt s16 le printf ошибка запрошенный формат не поддерживается return exit failure nchans 1 ioctl audio fd sndctl dsp channels nchans if argc 3 rate atoi argv 2 else rate 8000 ioctl audio fd sndctl dsp speed rate printf используемая частота дискретизации i гц n rate the frame size in hardcoded for this sample code but it doesn t have to be create a new decoder state in narrowband mode state speex decoder init speex nb mode set the perceptual enhancement on tmp 1 speex decoder ctl state speex set enh tmp outfile argv 1 fout fopen root c w fin fopen argv 1 r initialization of the structure that holds the bits speex bits init bits while 1 read the size encoded by sampleenc this part will likely be different in your application fread nbbytes sizeof int 1 fin fprintf stderr nbbytes d n nbbytes if feof fin break read the packet encoded by sampleenc fread cbits 1 nbbytes fin copy the data into the bit-stream struct speex bits read from bits cbits nbbytes decode the data i speex decode int state bits...