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

[Firefox] Data from right channel is not passed to encoder despite there are expected two channels #88

Open
dominiksekula opened this issue Feb 2, 2022 · 0 comments

Comments

@dominiksekula
Copy link

Hi! 👋
Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch lamejs@1.2.0 for the project I'm working on.

I encountered an issue in Firefox (v96.0.3) that variable for the right channel is not passed to the encodeBuffer despite there are 2 channels. To prevent that I've added extra validation of the presence of that right channel. That could probably simply replace checking for number of channels instead of extend that validation condition but I didn't investigate the code deeper and as a quick fix I went with the safest solution from my point of view.

Here is the diff that solved my problem:

diff --git a/node_modules/lamejs/src/js/index.js b/node_modules/lamejs/src/js/index.js
index 7539d66..f18e7c7 100644
--- a/node_modules/lamejs/src/js/index.js
+++ b/node_modules/lamejs/src/js/index.js
@@ -115,7 +115,8 @@ function Mp3Encoder(channels, samplerate, kbps) {
     var mp3buf = new_byte(mp3buf_size);
 
     this.encodeBuffer = function (left, right) {
-        if (channels == 1) {
+
+        if (channels == 1 || !right) {
             right = left;
         }
         assert(left.length == right.length);

This issue body was partially generated by patch-package.

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

1 participant