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@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
> 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!On regular data, gzip might get a 5% reduction, so I doubt you can get 50% unless you're encoding zeros or doing something wrong...> if (sample_rate > 22050) > libspeex_enc_state = speex_encoder_init(&speex_wb_mode); > else > libspeex_enc_state = speex_encoder_init(&speex_nb_mode);In normal operation, narrowband is 8000 Hz, wideband is 16000 Hz and ultra-wideband is 32000 Hz, so I'd change the 22050 for something like 12000 (and maybe have above 22050 encoded in ultra-wideband if necessary). Jean-Marc -- Jean-Marc Valin, M.Sc.A. LABORIUS (http://www.gel.usherb.ca/laborius) Université de Sherbrooke, Québec, Canada -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 242 bytes Desc: signature.asc Url : http://lists.xiph.org/pipermail/speex-dev/attachments/20021213/e4943549/signature-0001.pgp
> Is the following code correct for compressing audio? The output I get isso> extremely small, but what is more important: if I pass it through zlib, it > gets at least 50% smaller!JM> On regular data, gzip might get a 5% reduction, so I doubt you can get JM> 50% unless you're encoding zeros or doing something wrong... I think I'm doing something wrong :o) Don't know what though. Also, I could not find in the documentation how to convert the sample-data to floats. Now I'm just doing something like float_data[index] = (float)input_data[index]; where input_data is a short *input_data "array". Is this correct? Or should I scale the data down to -1.0 <= x <= 1.0? JM> In normal operation, narrowband is 8000 Hz, wideband is 16000 Hz and JM> ultra-wideband is 32000 Hz, so I'd change the 22050 for something like JM> 12000 (and maybe have above 22050 encoded in ultra-wideband if JM> necessary). Ah, ok, thanks. --- >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@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.