Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NumUsed is not defined #1

Closed
aviankona opened this issue Jun 13, 2015 · 12 comments
Closed

NumUsed is not defined #1

aviankona opened this issue Jun 13, 2015 · 12 comments

Comments

@aviankona
Copy link

Hi,

I saw your project and was very impressed.

While testing to see it's performance, I've came across an error.

"NumUsed is not defined" on lame.all.js line 15163.

Would appreciate a bug fix in order to complete the cycle.

Thanks,
Avi.

@zhuker
Copy link
Owner

zhuker commented Jun 13, 2015

fixed
let me know if it works for you.

@aviankona
Copy link
Author

thanks for the fix,

now it throws "fill_buffer_resample is not defined"

lame.all.js:15169 Uncaught ReferenceError: fill_buffer_resample is not defined

@zhuker
Copy link
Owner

zhuker commented Jun 14, 2015

can you send me the code which reproduces the bug?
do you intentionally resample?

@aviankona
Copy link
Author

Hi Alex,

Here is my complete flow:

  • record audio with the WebAudio Api,
    block size 2048
    sample rate - according to the mic input (will probably be 44,100 or 48,000).
  • Convert it to WAV - preserving it's sample rate, using it's block size. defining the WAV output to mono. the function returns an UInt16Array.
  • Execute a copy of your function (from the example page) with the original sample rate and block size.

I'm executing the conversion in a web worker.

See conversion function below:
function _newEncodeMp3( uint16Array ){
var liblame = new lamejs();
var mp3enc = new liblame.Mp3Encoder(1, ORIGINAL_SAMPLE_RATE, 16);
var remaining = uint16Array.length;
var maxSamples = ORIGINAL_BLOCK_SIZE;
for (var i = 0; remaining >= maxSamples; i += maxSamples) {
var mono = uint16Array.subarray(i, i + maxSamples);
var mp3buf = mp3enc.encodeBuffer(mono);
if (mp3buf.length > 0) {
//TODO write to output
}
remaining -= maxSamples;
}
var mp3buf = mp3enc.flush();

    return mp3buf;
}

Thanks for the support,
Avi.

@zhuker
Copy link
Owner

zhuker commented Jun 14, 2015

what was the ORIGINAL_SAMPLE_RATE when the code failed?

@zhuker
Copy link
Owner

zhuker commented Jun 14, 2015

are you sure you want 16kbps mp3?
for such low bitrates lame does resampling to a lower sample rate

@aviankona
Copy link
Author

My sample rate is 44100
what's the minimum kbps that you suggest?

@zhuker
Copy link
Owner

zhuker commented Jun 14, 2015

depends on your application
try 64 and let me know if it works for you

@zhuker
Copy link
Owner

zhuker commented Jun 14, 2015

just fixed the resampling code
should work with 16kbps now
try it

@aviankona
Copy link
Author

Just tested it.

it fails on the initialization with the following error:
lame.all.js:15509 Uncaught ReferenceError: fs is not defined

@zhuker
Copy link
Owner

zhuker commented Jun 14, 2015

my bad, forgot to disable tests, just fixed

@aviankona
Copy link
Author

Hi Alex,

Conversion function has finished successfully!

I'll create an output file and check the conversion.

Thanks!
Avi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants