tuna icon indicating copy to clipboard operation
tuna copied to clipboard

Unable to use WahWah In Compiled Electron App

Open stuible opened this issue 6 years ago • 15 comments

I'm experiencing a very strange bug with the WahWah effect in Tuna.js. When I compile my electron app which uses WahWah. No matter what options I pass in (Even just bypass). I get the following error: TypeError: Cannot assign to read only property 'Q' of object '#<BiquadFilterNode>'

Web Tools debugging tracks the error down to this line: https://github.com/Theodeus/tuna/blob/master/tuna.js#L1978

I really appreciate the work put into this library, it's been great to use, this one is just a bit of a head scratcher.

stuible avatar Mar 09 '19 00:03 stuible

That's an interesting one indeed!

It makes sense that it happens even though it's in bypass, since the node is still initialized with the defaults. It look like the Web Audio implementations in Electron and browsers differ then.

I'd have to setup an electron project to figure this out, though I'm currently on parental leave, so time is in short supply. :) Do you have a project somewhere that I could clone and test with?

Theodeus avatar Mar 14 '19 18:03 Theodeus

Thanks reply, I appreciate it! I have a relatively complex project that displays this error but I almost feel bad making you look through it's code base: https://github.com/stuible/Image-Snafu/tree/WahWahErrorOnBuild

The Javascript responsible for directly interfacing with Tuna.js is found: https://github.com/stuible/Image-Snafu/tree/WahWahErrorOnBuild/src/assets/js/snafu.js

It should be noted that no other audio effect I have tested has caused this error.

stuible avatar Mar 16 '19 01:03 stuible

I also have received a similar error for WahWah effect, but on the web (chrome) -

tuna.js:1924 Uncaught TypeError: Cannot assign to read only property 'filterFreqTimeout' of object '[object Object]'
    at Tuna.WahWah.value (tuna.js:1924)
    at Tuna.WahWah.<anonymous> (tuna.js:1925)

I will try to come up with a good environment to test and isolate the problem.

Awesome library by the way! Every other effect works like a charm. 👍

darrendahl avatar Nov 11 '20 21:11 darrendahl

Looks like the whole filter frequency bit in the WahWah could use some refactoring. :) The whole try/catch bit in there looks suspicious. But for your specific error, with the filterFrequencyTimeout, that could be a straight out bug in that that property isn't set as writable.

Now I just have to figure out how to trigger the error before I patch it. 😁

Theodeus avatar Nov 12 '20 11:11 Theodeus

Ahh yeah when I isolate here it works... so still a mystery

https://codesandbox.io/s/hopeful-chaplygin-8egr9?file=/src/index.js

darrendahl avatar Nov 12 '20 11:11 darrendahl

I was also just looking into this...

I have found a possible bug here, that should probably assign to "this.filter.Q.value", but it's more related to the first bug in this issue

alesaccoia avatar Nov 12 '20 12:11 alesaccoia

That ought to trigger the setter here, so I think that should work..

Theodeus avatar Nov 12 '20 12:11 Theodeus

nice try then, gimme a few more tries and I may be of help again :P

alesaccoia avatar Nov 12 '20 12:11 alesaccoia

@darrendahl - when you're creating the WahWah in the original code, are you passing any parameters to the constructor? If so - what values are passed when you get the error?

Also, if you run Tuna unminified, does adding writable: true here change anything?

EDIT: typo 😨

Theodeus avatar Nov 12 '20 13:11 Theodeus

It does! I dont see that error anymore (it was on a loop so would get hundreds), now I see this one more prominently (it was also happening before but at the top of the error stack so I missed it)

tunajs.js:1979 Uncaught (in promise) TypeError: Cannot set property Q of #<BiquadFilterNode> which has only a getter

darrendahl avatar Nov 12 '20 13:11 darrendahl

Nice!

And this might be where your finding comes in, Alessandro, as we're setting the Q without Q.value here, and that's an actual native Web Audio node!

I would still be interested in reproducing this though. When you do get the error, Darren, has the code been through some kind of processing (webpack or the like?).

Theodeus avatar Nov 12 '20 13:11 Theodeus

Got it, thanks! This fixes it.

line 1979

this.filterPeaking.Q.value= this._resonance;

from

this.filterPeaking.Q= this._resonance;

Yes I'm using rollup - resolves at "tunajs": "^1.0.11"

darrendahl avatar Nov 12 '20 14:11 darrendahl

https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode/Q

darrendahl avatar Nov 12 '20 14:11 darrendahl

https://github.com/Theodeus/tuna/pull/82

darrendahl avatar Nov 12 '20 14:11 darrendahl

PS I've never contributed to an open source project before 😂

darrendahl avatar Nov 12 '20 14:11 darrendahl