JSpeex Decoding not working

600 Views Asked by At

I'm using the JSpeex library for audio encoding. The encoding seems to work fine. But decoding doesn't.(i.e. I get all zeros as decoded data.)

// encoding ///

SpeexEncoder enc = new SpeexEncoder();


// if i use channel as 1 instead of 2 even encoding doesn't work

enc.init(mode, quality, 44100, 2);

enc.processData(b, 0, b.length); // b is byte array i'm trying to encode & then decode

enc.getProcessedData(temp, 0); // save encoded data to temp // temp is byte array

////Decoding /////////

SpeexDecoder dec = new SpeexDecoder();

dec.init(mode,44100,2,true);

dec.processData(temp, 0, temp.length);

dec.getProcessedData(decoded, 0); //decoded is the output byte array which comes only zeros

If anyone has any info on this please reply.

Thanks

1

There are 1 best solutions below

0
On

I realize this post is a bit old, but ran into a similar problem with Speex.js (a javascript port).

Not sure if the issue is the same for you, but I found that there was an implicit conversion from Float32Array to Int16Array that didn't actually convert the data. This meant that all of the (-1.0,1.0) float data was essentially integer zeros, and was converted as such.

Just needed to do the conversion to Int16Array before passing in the data (so it wouldn't need to do any data conversion within the library) and the output sprang to life :)

Hope that helps. cheers!