[speex-dev] question on usage of the libraries

Folkert van Heusden folkert at vanheusden.com
Fri Dec 13 11:21:15 PST 2002



Hi,

I'm not sure if I should post this question to this list. If not; please
tell me.
Ok, here it comes:
Is the following code correct for compressing audio? The output I get is so
extremely small, but what is more important: if I pass it through zlib, it
gets at least 50% smaller!

Init:
        int bitrate = max_bandwidth * 8;
        speex_bits_init(&libspeex_bits);
        if (sample_rate > 22050)
                libspeex_enc_state = speex_encoder_init(&speex_wb_mode);
        else
                libspeex_enc_state = speex_encoder_init(&speex_nb_mode);
        speex_encoder_ctl(libspeex_enc_state, SPEEX_SET_SAMPLING_RATE,
&sample_rate);
        speex_encoder_ctl(libspeex_enc_state, SPEEX_SET_BITRATE, &bitrate);
        speex_encoder_ctl(libspeex_enc_state, SPEEX_GET_FRAME_SIZE,
&libspeex_frame_size);

compression:
        while(n_samples_todo > 0)
        {
                int cur_n_bytes_out;
                speex_bits_reset(&libspeex_bits);
                speex_encode(libspeex_enc_state, &in_float[input_pnt],
&libspeex_bits);
                cur_n_bytes_out = speex_bits_nbytes(&libspeex_bits);
                speex_bits_write(&libspeex_bits, &(*data_out)[output_pnt],
cur_n_bytes_out)
                output_pnt     += cur_n_bytes_out;
                input_pnt      += libspeex_frame_size;
                n_samples_todo -= libspeex_frame_size;
        }

Thank you.

<p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'speex-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the Speex-dev mailing list