> >> 2. What does SPEEX_GET_LOOKAHEAD do? How to use it? >> In speexenc.c, there is following code: >> >> ... >> speex_encoder_ctl(st, SPEEX_GET_LOOKAHEAD, &lookahead); >> ... >> nb_encoded = -lookahead; >> >> Can someone explain what this means? > > The lookahead is the number of samples you need to discard at the > start. > > Jean-MarcIn my application, even 5ms (110 samples at 22KHz) matters. So what should I do to avoid discarding samples at the beginning? 1. Turning off look ahead? 2. Padding 0's at the beginning.
Jean-Marc Valin
2006-Oct-31 12:38 UTC
[Speex-dev] 2 questions, frame size and SPEEX_GET_LOOKAHEAD
> In my application, even 5ms (110 samples at 22KHz) matters.1) If 5 ms matters, I don't recommend Ogg (and I definitely hope you're not running Windows!) 2) 22 kHz is *not* recommended. Use 16 kHz instead> So what > should I do to avoid discarding samples at the beginning?Why are they so precious, they're *zeros* (or nearly).> 1. Turning off look ahead? > 2. Padding 0's at the beginning.Or you can always just play them if they're so precious. Ah, the sound of 5ms worth of zeros... Jean-Marc
Ok, let me first explain why 5ms matters, even they are 0's, in my particular application. I am working on a speech synthesis system. The basic idea is concatenating pre-recorded phonemes or words into longer sentences. So any missing or extra samples, even it is as short as 5~10ms, cause very noticeable discontinuities. I want to use speex to compress/decompress those pre-recorded material. But I'm concerned about the extra 0's might be padded at both ends. For the zero padding at the last frame, I know how to remove it after decoding. But I am a little confused by the look ahead at the beginning. The sample code in the manual doesn't use look ahead, while the speexenc.c does. I'd like to know what difference it makes. Let me plugin some numbers. I am using wide-band mode, the frame size is 320 samples. Say I take the first frame of an audio buffer, i.e. the first 320 samples, and feed them into encoder. Then after decompress, do I get all 320 samples, or a portion of 320 samples with some 0 padding at the very beginning? Thank you. On Oct 31, 2006, at 12:38 PM, Jean-Marc Valin wrote:>> In my application, even 5ms (110 samples at 22KHz) matters. > > 1) If 5 ms matters, I don't recommend Ogg (and I definitely hope > you're > not running Windows!) > 2) 22 kHz is *not* recommended. Use 16 kHz instead > >> So what >> should I do to avoid discarding samples at the beginning? > > Why are they so precious, they're *zeros* (or nearly). > >> 1. Turning off look ahead? >> 2. Padding 0's at the beginning. > > Or you can always just play them if they're so precious. Ah, the sound > of 5ms worth of zeros... > > Jean-Marc