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 > >
John Miles
2006-May-20 16:52 UTC
[Speex-dev] Size of each block in a circular buffer and the samplerate
Basically, yeah, but you want to add your samples as signed 32-bit ints, and do the clamping (to +/- 32K) after all of the additions have taken place. -- john> -----Original Message----- > From: speex-dev-bounces@xiph.org [mailto:speex-dev-bounces@xiph.org]On > Behalf Of Kevin Jenkins > Sent: Saturday, May 20, 2006 3:47 PM > To: Jean-Marc Valin > Cc: speex-dev@xiph.org > Subject: Re: [Speex-dev] Size of each block in a circular buffer and the > samplerate > > > 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? > >
Kevin Jenkins
2006-May-20 18:29 UTC
[Speex-dev] First argument to speex_decode NULL for missing data?
----------- Again, once the decoder initialization is done, for every input frame: speex_bits_read_from(&bits, input_bytes, nbBytes); speex_decode(dec_state, &bits, output_frame); where input_bytes is a (char *) containing the bit-stream data received for a frame, nbBytes is the size (in bytes) of that bit-stream, and output_frame is a (float *) and pints to the area where the decoded speech frame will be written. A NULL value as the first argument indicates that we don't have the bits for the current frame. ----------- In the snip above, the manual says to make the first argument NULL - however that looks like a mistake to me. It should be the 2nd argument right?