Skip to content
This repository has been archived by the owner on Feb 18, 2022. It is now read-only.

note-parser not working when using as a library in another project #45

Open
bgruber opened this issue Aug 4, 2017 · 5 comments
Open

Comments

@bgruber
Copy link

bgruber commented Aug 4, 2017

Hi!

Synthesizers work great for me in the demo project. However, when I add react-music as a dependency to another project, I'm unable to use Synth or Monosynth, seemingly because of an error using note-parser:

Uncaught TypeError: Cannot read property 'freq' of undefined
    at Monosynth.createOscillator (monosynth.js:147)
    at Monosynth.playStep (monosynth.js:163)
    at Scheduler.process (scheduler.js:119)
    at loop (scheduler.js:34)

The Sampler instrument works fine.

@paulsoh
Copy link

paulsoh commented Sep 23, 2017

I think this is a note-parser package issue. <Synth /> and <Monosynth /> both use parser.freq and it seems like depending on what kind of syntax you're using it works on some environments where in other it doesn't (In my case, i was working on a react app using create-react-app)

I had to move the entire react-music src/ folder to inside of my react project and had to switch out all the import parser from 'note-parser' to var parser = require('parser')

and now it seems like it's working! Not elegant but a workaround for now.

Inside my apps

import {
  Analyser,
  Song,
  Sequencer,
  Sampler,
  Synth,
} from '../ReactMusic';

Inside Monosynth, Synth

var parser = require('note-parser');

@MariaPet
Copy link

It's not the right solution but it works temporarily for me if I change line 128 in node_modules/react-music/lib/components/synth from this:

// osc.frequency.value = _noteParser2.default.freq(transposed);

to this:

osc.frequency.value = _noteParser2.freq(transposed);

_noteParser2.default is undefined

Would be nice if that could be fixed in a new release.

@micaelmbagira
Copy link

Is there an update on this?

1 similar comment
@x5engine
Copy link

x5engine commented Jun 9, 2020

Is there an update on this?

@hazem3500
Copy link

It's not the right solution but it works temporarily for me if I change line 128 in node_modules/react-music/lib/components/synth from this:

// osc.frequency.value = _noteParser2.default.freq(transposed);

to this:

osc.frequency.value = _noteParser2.freq(transposed);

_noteParser2.default is undefined

Would be nice if that could be fixed in a new release.

This worked for me 👍!

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

No branches or pull requests

6 participants