[Speex-dev] Nothing but rhythm was left after encoding and decoding by speex on ipad(XCode 4.1 48110)

刘华 liuhua1976 at gmail.com
Wed Oct 5 00:24:22 PDT 2011


Is there anybody who did the same thing?


在 2011年9月29日 下午8:08,刘华 <liuhua1976 at gmail.com> 写道:
> hi,
>
> I tried to encode the voice data read from AudioQueue and then decode
> it. There was nothing but rhythm left, it sounds like robot's voice,
> but I cannot recognize any word.
>
> The app was compiled by XCode 4.1. Speex 1.0.5 and 1.2.rc1 gave the
> same result. When compiling speex 1.0.5, I  added them to Xcode
> project, set the Header Search Paths, then compiled successfully. When
> compiling speex 1.2.rc1, I included the config.h file generated by the
> configure on Mac OS X 10.7.1(add "#include config.h" in arch.h) and
> did the same thing with that on speex 1.0.5.
>
> The following is the code I used to encode and decode, it works
> properly in Android 3.0:
>
> static int speexo_encode(const void *in_bytes, void *out_bytes, int size)
> {
>        if (!codec_open)
>                return 0;
>
>        int return_value;
>
>        speex_bits_reset(&ebits);
>
>        //speex_echo_capture(echo_state, (short*)in_bytes, (short*)in_bytes);
>
>        //speex_preprocess_run(prep_state, (short*)in_bytes);
>
>        speex_encode_int(enc_state, (short*)in_bytes, &ebits);
>        if(speex_bits_nbytes(&ebits) >= (int)size) {
>                return_value = 0;
>        }
>        else {
>                return_value = (int)speex_bits_write(&ebits, (char*)out_bytes, size);
>        }
>
>        return return_value;
> }
>
> static int speexo_decode(const void *in_bytes, int in_len, void *out_bytes)
> {
>        if (!codec_open)
>                return 0;
>
>        int return_value;
>
>        speex_bits_reset(&dbits);
>        speex_bits_read_from(&dbits, (char *)in_bytes, in_len);
>        if (0 != speex_decode_int(dec_state, &dbits, (short*)out_bytes)) {
>                return_value = 0;
>        }
>        else {
>                return_value = dec_frame_size*2;
>        }
>
>        return return_value;
> }
>
> Please give your suggestion, thanks.
>


More information about the Speex-dev mailing list