Hi, in a VoIP application, the endpoint A send speex payload to B. B doesn't know how A acquire audio, it only know that the channel is narrowband so, how can B know the size of the output buffer to pass to the speex_decode()? Thanks, Daniele.
Daniele Barzotti <daniele.barzotti at eurocomtel.com> writes:> Hi, > > in a VoIP application, the endpoint A send speex payload to B. > B doesn't know how A acquire audio, it only know that the channel is > narrowband so, how can B know the size of the output buffer to pass to > the speex_decode()?Usually a buffer is one frame of data, and a frame is 20 milliseconds. Since the sample rate is typically 8 kHz in narrowband mode, this corresponds to a buffer size of 160 samples. --Randy> > Thanks, > Daniele. > _______________________________________________ > Speex-dev mailing list > Speex-dev at xiph.org > http://lists.xiph.org/mailman/listinfo/speex-dev >-- Randy Yates % "She's sweet on Wagner-I think she'd die for Beethoven. Digital Signal Labs % She love the way Puccini lays down a tune, and mailto://yates at ieee.org % Verdi's always creepin' from her room." http://www.digitalsignallabs.com % "Rockaria", *A New World Record*, ELO
Il 14/04/2010 14:37, Randy Yates wrote:> > Usually a buffer is one frame of data, and a frame is 20 milliseconds. > Since the sample rate is typically 8 kHz in narrowband mode, this > corresponds to a buffer size of 160 samples.Hi Randy, thanks for the reply. So, suppose I encode an audio buffer (8000 kHz, MONO, float) of 640 PCM frames. In output I have 4 speex frame of 20 byte each that I put in a RPT payload of 80 bytes: UINT CSpeexCodec::Encode( float *inBuff, const char**outBuff, UINT BufferFrames ) { speex_encoder_ctl(spx_state_, SPEEX_GET_FRAME_SIZE, &spx_frame_size_); while (BufferFrames>0) { speex_bits_reset(&spx_bits_); speex_encode(spx_state_, inBuff, &spx_bits_); nbBytes += speex_bits_write(&spx_bits_, spx_enc_frame_, spx_frame_size_); inBuff+= spx_frame_size_; BufferFrames -= spx_frame_size_; } ..nbBytes is 80 bytes.. } Now I send this packet over the network and, into the receiving side, I need to recreate the original PCM buffer (640 frames). But how can I know the size of each speex frame into a multiframe payload? Daniele.