Hi,
If you're looking at only one frame, I can understand why you don't get
the same thing. In narrowband more, Speex introduces a 80-sample delay,
not to mention that the decoded signal is supposed to _sound_ the same,
not necessarily _look_ the same.
Jean-Marc
Le vendredi 12 ao?t 2005 ? 10:05 -0500, James Stanton a ?crit
:> I'm trying to use the speex API, and I think I'm missing something.
I'm
> running on Mac OSX Tiger, and the attached microphone is a iSight. If I
> call the "speex_encode_int" function, and then immediately call
the
> "speex_decode_int" function, shouldn't I get back the same
data? i.e.
> in my example code, shouldn't the two arrays contain at least similar
> data? The data I'm seeing is drastically different. If so, is the
> encoding data sensitive? If my data being fed in is wrong, will the
> encoding and decoding not work correctly? Any help would be greatly
> appriciated.
>
> Thanks!
>
> Jamie Stanton
> jstanton@clairvista.com
>
> I've got the following code:
>
> static void testAudio(UInt8 *data, long dataLength)
> {
> //data is a linear PCM stream from an attached microphone. sample rate
> is 8000, 16 bits per sample
> void *state;
> void *state2;
> SpeexBits bits;
> short tempShort;
> short tempPtr[160];
> short tempPtrDecode[160];
> state = speex_encoder_init(&speex_nb_mode);
> state2 = speex_decoder_init(&speex_nb_mode);
> speex_bits_init(&bits);
> //code simplified to just read in the first frame
> for (int i = 0; i < 320; i +=2)
> {
> tempShort = *((short*)(data + i));
> tempPtr[i / 2] = tempShort;
> }
> speex_bits_reset(&bits);
> speex_encode_int(state, tempPtr, &bits);
> speex_bits_rewind(&bits);
> speex_decode_int(state2, &bits, tempPtrDecode);
> //tempPtr != tempPtrDecode, it's not even close.
> }
>
>
> _______________________________________________
> Speex-dev mailing list
> Speex-dev@xiph.org
> http://lists.xiph.org/mailman/listinfo/speex-dev
>
--
Jean-Marc Valin <Jean-Marc.Valin@USherbrooke.ca>
Universit? de Sherbrooke