Kevin Jenkins
2006-May-20 14:33 UTC
[Speex-dev] Size of each block in a circular buffer and the sample rate
int frameSize; speex_encoder_ctl(enc_state, SPEEX_GET_FRAME_SIZE, &frameSize); Is frameSize in bytes? If not, what unit is it in? I need to know so I know how big to make each element in my circular buffer. Also, do I need to call speex_encoder_ctl( enc_state, SPEEX_SET_SAMPLING_RATE, &sampleRate ); Depending on sample rate I record my audio in? If not, is there any benefit to setting the sample rate, such as reduced bandwidth?
Jean-Marc Valin
2006-May-20 14:40 UTC
[Speex-dev] Size of each block in a circular buffer and the sample rate
> Is frameSize in bytes? If not, what unit is it in? I need to know so I > know how big to make each element in my circular buffer.It's in samples, regardless of whether you use floats or shorts.> Also, do I need to call > > speex_encoder_ctl( enc_state, SPEEX_SET_SAMPLING_RATE, &sampleRate ); > > Depending on sample rate I record my audio in? If not, is there any > benefit to setting the sample rate, such as reduced bandwidth?The only thing Speex does with the sampling rate is compute the final bit-rate it corresponds to. If you use a "nominal" bit-rate (8 kHz for narrowband, 16 kHz for wideband, ...), which I strongly recommend, you don't even need to call this. Jean-Marc
Kevin Jenkins
2006-May-20 15:47 UTC
[Speex-dev] Size of each block in a circular buffer and the sample rate
Thanks! I hope this isn't a stupid question but if I want to play two or more voices at the same time, I just add the values of the samples right? If I'm using an unsigned short, should I then clamp the values to 65535? Jean-Marc Valin wrote:>> Is frameSize in bytes? If not, what unit is it in? I need to know so I >> know how big to make each element in my circular buffer. > > It's in samples, regardless of whether you use floats or shorts. > >> Also, do I need to call >> >> speex_encoder_ctl( enc_state, SPEEX_SET_SAMPLING_RATE, &sampleRate ); >> >> Depending on sample rate I record my audio in? If not, is there any >> benefit to setting the sample rate, such as reduced bandwidth? > > The only thing Speex does with the sampling rate is compute the final > bit-rate it corresponds to. If you use a "nominal" bit-rate (8 kHz for > narrowband, 16 kHz for wideband, ...), which I strongly recommend, you > don't even need to call this. > > Jean-Marc > >