aolsenjazz / libsamplerate-js

Resample audio in node or browser using a web assembly port of libsamplerate.
Other
31 stars 8 forks source link

nodejs error TypeError: Cannot read properties of undefined (reading 'bind') #132

Closed Goddard closed 12 months ago

Goddard commented 12 months ago

feeding chunks to resampler errors out immediately -

const { create, ConverterType } = require('@alexanderolsen/libsamplerate-js');

just importing this causes the error let resampler = await create(nChannels, inputSampleRate, outputSampleRate, { converterType });

Goddard commented 12 months ago

TypeError: Cannot read properties of undefined (reading 'bind') at D (/home/goddard/project/node_modules/@alexanderolsen/libsamplerate-js/dist/libsamplerate.js:1:4317) at /home/goddard/project/node_modules/@alexanderolsen/libsamplerate-js/dist/libsamplerate.js:1:2009083 at /home/goddard/project/node_modules/@alexanderolsen/libsamplerate-js/dist/libsamplerate.js:1:2008431 at Object.next (/home/goddard/project/node_modules/@alexanderolsen/libsamplerate-js/dist/libsamplerate.js:1:2008536) at /home/goddard/project/node_modules/@alexanderolsen/libsamplerate-js/dist/libsamplerate.js:1:2009403 at new Promise () at b (/home/goddard/project/node_modules/@alexanderolsen/libsamplerate-js/dist/libsamplerate.js:1:2009139) at Object. (/home/goddard/project/server.js:35:17) at Module._compile (node:internal/modules/cjs/loader:1196:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1250:10)

aolsenjazz commented 12 months ago

I'm happy to help, but I can't really help you without more information. Please either consider closing this issue + reopening using the bug report template I've provided, or specify more details about your environment. Node version, LibSampleRateJS version, OS, etc.

About all I can say right now with what you've provided is:

Seems to me there might be an older version in use, but please provide more info and we can figure it out.

Goddard commented 12 months ago

I used this command as stated on the readme today to install.

npm i @alexanderolsen/libsamplerate-js

I am using node version 16.20.0

Goddard commented 12 months ago

I also tried building from source with the docker image and got the same issue.

aolsenjazz commented 12 months ago

What operating system are you using? If I run the following:

nvm install 16.20.0
nvm use 16.20.0
mkdir lsr-test
cd lsr-test
npm init -y
touch index.js
npm i -S @alexanderolsen/libsamplerate-js

edit index.js:

const { create, ConverterType } = require('@alexanderolsen/libsamplerate-js');

and run

node index.js

The program completes without error, so this must be an environment issue. Please provide as much environment info as you can. What OS/version are you using? Is this in the browser, node AudioWorklet, etc? Please double check node version with node -v

Goddard commented 12 months ago

Manjaro(Linux) it is rolling so latest.

I am running it in the cli so node. I also use nvm.

But this is running in a docker instance that is ubuntu. node --version v16.20.0

aolsenjazz commented 12 months ago

Thanks. Does the CLI example work for you? I don't have a Linux installation, but I need to install one for another project anyways. Will bump that up in my to-do's so I can check this out too. Thanks for verifying node version.

aolsenjazz commented 12 months ago

I've fresh installed Manjaro Kernel version 5.15.131 and the following works as expected. Same process - init empty project, install, create index, execute using node 16.20.0

const { create, ConverterType } = require('@alexanderolsen/libsamplerate-js');

(async () => {
  const inSampleRate = 44100;
  const outSampleRate = 96000;
  const nChannels = 1;
  create(nChannels, inSampleRate, outSampleRate).then((src) => {
    const d = new Float32Array(44100);
    const resampled = src.simple(d);
    console.log(resampled.length);
  });
})();

Inspecting the trace you got, the .bind() statement is being called on console.error. So for whatever reason console.error is not defined in your env.

Sorry to say, not sure what else I can do for you here.

aolsenjazz commented 12 months ago

Closing as this seems to be an environment issue. Feel free to followup and we can reopen