jpemartins / speex.js

Speex codec in Javascript. Mirror from https://code.ua.pt/projects/speex-js
214 stars 63 forks source link

Wideband support - does not work? #11

Closed arielvsp closed 10 years ago

arielvsp commented 10 years ago

Hello, wideband support still does not seem to work correctly for me.

  1. Tested on your web site (http://jpemartins.github.io/speex.js/): 16KHz/16bit short wav recording (counting one to ten) produced ogg file that only plays "one" and "ten", skipping most of audio. Environment: latest Chrome, FF and VLC player on Win7-SP1-64bit
  2. Tested dynamic encoding (mic -> resampler -> Speex): does not seem to provide correct wideband frames. Original Speex (C code from speex.org) decoder marks most of frames as incorrect. To the best of my understanding, the returned frame size is incorrect: 38 bytes come back on each submitted 160 samples (wb mode 8). Expected: 70 bytes.

I'm willing to provide any further information and/or help testing the feature, as necessary if it helps.

BR/Ariel

jpemartins commented 10 years ago

Thanks for trying this out. Regarding the first issue, my ogg demuxer/muxer does not fill the granule_pos correctly (is remains 0 over the ogg pages) . Instead it should contain the number of samples per page. Just to double check you might wanna try to decoding the file on the webpage. The web app will play after decode. If it still doesn't play it's something else that I am not aware of :(

About issue 2, Speex only encodes/decodes audio without any wav or ogg info. Also, if you see 38 bytes it means you might be encoding in narrow band mode, in which 38 is the expected size for quality parameter 8 in mode 0 (narrow band). Not sure if it answers your question but let me know if I am missing something here. I will be glad to help.

arielvsp commented 10 years ago

Thanks for a quick response. By the way, a great job in developing and supporting this soft! Kudos! Regarding Issue 1. Yes, decoding the file on the webpage works perfect! So I cannot rely of 3rd party Ogg players for testing for the moment.

Issue 2: Re [Speex only encodes/decodes audio without any wav or ogg info]: clear, I used codecs in the past, including Speex library in C Re [you might be encoding in narrow band mode]: yes, that's what I thought. However, in the initialization the mode was set to "1", like this: var codec = new Speex({ quality: 8, mode: 1 }); I tried to set all other relevant parameters, too, with little success :-( Is there any default setting you can recommend or any problem you can see in what I did?

BR/Ariel

jpemartins commented 10 years ago

Glad to hear that! Thanks!

Thanks for a quick response. By the way, a great job in developing and supporting this soft! Kudos!

I currently dont have a way to find the correspondent encoded frame size based on the mode. It is hardcoded in a map, but only with the values for narrowband. For wideband and ultra wideband you need to manually specify:

var codec = new Speex({ quality: 8, mode: 1, bits_size: 70 });

Let me know if it worked for you Cheers

arielvsp commented 10 years ago

Hi, I have tried your suggestion and, unfortunately, no much luck - still getting back a 38 byte frame. Just after codec initialization (exactly as you suggested) codec.encoder.bits_size returns 38. Anything else I can try/test? Any suggestion would be greatly appreciated. NOTE: I'm using the minimized library. Is it aligned with the latest sources? BR/Ariel

jpemartins commented 10 years ago

NOTE: I'm using the minimized library. Is it aligned with the latest sources?

Looks like that is the problem. The minified version hasn't been updated for a while. I had some minification problem regarding some of the compression options. But it is fixed now in commit https://github.com/jpemartins/speex.js/commit/a6bbdfd0ab9525eec208c0746b49015cd2f74a3c