akrennmair / libmp3lame-js

port of libmp3lame to JavaScript using emscripten
223 stars 61 forks source link

Allow hooking into VBR calls #3

Closed akumpf closed 11 years ago

akumpf commented 11 years ago

I'm kinda shooting in the dark here, but I tried this on my local copy and it worked well. Please pull this if it seems correct.

Also added self call at the end since I needed to do that to expose Lame to other webworkers.

See my fork of your webworker here (that uses VBR): https://github.com/chaoscollective/chaos-lib-client/blob/master/jsworkers/lame/encoder.js

There's also a compressed version of the javascript with changes incorporated in the parent folder if that's helpful.

I'm getting nice sounding (and well compressed files) for these settings:

    encoder.postMessage({
      cmd: 'init',
      config: {
        in_samplerate:  44100,
        out_samplerate: 44100,
        bitrate: 64, // doesn't matter with VBR
        channels: 1,
        vbr: 2,
        vbr_min: 4, // min kbps
        vbr_max: 128, // max kbps
        vbr_q: 9 // quality of 9 gives both small files and good quality.
      }
    });