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

"MPEGMode is not defined" #86

Closed
DonLifeScore opened this issue Dec 7, 2021 · 21 comments · Fixed by #87
Closed

"MPEGMode is not defined" #86

DonLifeScore opened this issue Dec 7, 2021 · 21 comments · Fixed by #87

Comments

@DonLifeScore
Copy link

Hi.

I'm hitting an error in the new update (1.2.1 vs. 1.2.0):

Uncaught (in promise) ReferenceError: MPEGMode is not defined
at Lame.js:135
at e.lame_init (Lame.js:229)
at new e.exports.Mp3Encoder (index.js:100)
at export-audio.js:80

Where I'm call this:

const mp3_bitRateKbps = 256;
const mp3_sampleRate = 44100;
const mp3encoder = new lamejs.Mp3Encoder(2, mp3_sampleRate, mp3_bitRateKbps);

-- Don Tillman

@isolin
Copy link
Contributor

isolin commented Dec 13, 2021

Hi Don, same here! The previous fix unfortunately caused some issues with modules relying on implicitly & improperly loaded submodules. The following changes fix at least my pipeline, I hope yours as well. Until there is a new version out, you need to edit the respective files in your node_modules/lamejs folder. After the filename I give the line number to insert the requirement.

Lame.js:29
Encoder.js:112
PsyModel.js:162
all need var MPEGMode = require('./MPEGMode.js');

BitStream.js:33
Presets.js:18
both need var Lame = require('./Lame.js');

QuantizePVT.js:54
needs var BitStream = require('./BitStream.js');

@Specy
Copy link

Specy commented Dec 19, 2021

Also having the same issue with sveltekit, waiting for PR to be merged and new version deployed

@T0914
Copy link

T0914 commented Jan 6, 2022

Any update on this conversation guys ? I have the same issue

@tommy-banana
Copy link

I'm still having to make these manual changes despite using 1.2.1.

@dadodasyra
Copy link

same issue too

@spicemix
Copy link

spicemix commented Mar 10, 2022

I was using this approach to linking with unreleased deps for a while and it was working, but at the moment for me neither that approach nor direct linking to 1.2.1 works. This issue shouldn't have been closed yet; we need a working release thanks!

(BTW, I found that unlinking on both ends and re-linking did the trick, but a new release would be so much easier)

@MrAlekhin
Copy link

I have the same issue still. Why is it closed?

@Selithrarion
Copy link

still

@tommy-banana
Copy link

Try audio-encoder npm . works.

@Selithrarion
Copy link

Try audio-encoder npm . works.

it seems audio-encoder uses lamejs and i have the same err ;(
just copied their example to my app
Selithrarion/vue_audio-tools@391fd2f

@tommy-banana
Copy link

tommy-banana commented Apr 9, 2022 via email

@wug-ge
Copy link

wug-ge commented Jun 4, 2022

It's pretty dirty, but this repo fixed it for me if you don't want to manually each time:
https://www.npmjs.com/package/lamejstmp

It's dirty as hell of course, I hope this gets resolved.

Also, this repo might do what most people want with less boilerplate, it has lamejs bundled into it and doesn't suffer from this issue:
https://github.com/closeio/mic-recorder-to-mp3

@Digglit
Copy link

Digglit commented Dec 28, 2022

Is there something I'm missing about this? The issue has been closed for a while, but I am still experiencing the same problem. This fix works, when can it be expected to be included in production?

Hi Don, same here! The previous fix unfortunately caused some issues with modules relying on implicitly & improperly loaded submodules. The following changes fix at least my pipeline, I hope yours as well. Until there is a new version out, you need to edit the respective files in your node_modules/lamejs folder. After the filename I give the line number to insert the requirement.

Lame.js:29 Encoder.js:112 PsyModel.js:162 all need var MPEGMode = require('./MPEGMode.js');

BitStream.js:33 Presets.js:18 both need var Lame = require('./Lame.js');

QuantizePVT.js:54 needs var BitStream = require('./BitStream.js');

@jgentes
Copy link

jgentes commented Dec 30, 2022

The issue is fixed in the latest release on Github, just not on NPM apparently. You can use this as a workaround in your package.json:

"dependencies": {
    "lamejs": "github:zhuker/lamejs"
}

@viniciusgusmao
Copy link

The issue is fixed in the latest release on Github, just not on NPM apparently. You can use this as a workaround in your package.json:

"dependencies": {
    "lamejs": "github:zhuker/lamejs"
}

Great! Worked for me.

@KhoaTheBest
Copy link

@viniciusgusmao it doesn't work for me :(

@TVNielsen
Copy link

@viniciusgusmao it doesn't work for me :(

could be you're using mic-recorder like i was and this one carries a 3 year old version of lamejs which you will have to manually override, even with this solve from @jgentes
at least i did, although it somewhat contradicts my understanding of it having lamejs as a dependency, here's sharing hope you can use it to solve your issue too

@KhoaTheBest
Copy link

@TVNielsen Im using lamejs directly

@TVNielsen
Copy link

TVNielsen commented Jan 11, 2023 via email

@vanphucLE
Copy link

vanphucLE commented Jul 10, 2023

Declaring global variables can help:

import MPEGMode from 'lamejs/src/js/MPEGMode';
import Lame from 'lamejs/src/js/Lame';
import BitStream from 'lamejs/src/js/BitStream';


window.MPEGMode = MPEGMode;
window.Lame = Lame;
window.BitStream = BitStream;

@digiage
Copy link

digiage commented Nov 7, 2023

@viniciusgusmao it doesn't work for me :(

have you done npm install after changing package.json ?

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

Successfully merging a pull request may close this issue.