rserota / wad

Web Audio DAW. Use the Web Audio API for dynamic sound synthesis. It's like jQuery for your ears.
MIT License
1.89k stars 160 forks source link

Tuna supprt broken when using UMD #67

Closed phal0r closed 6 years ago

phal0r commented 8 years ago

When using Common.js to load WAD, Tuna is included in the build, but also recognizes the presence of module.exports and is not exposed to the window object. While this behaviour is correct, WAD hardcodedly tries to access Tuna via window object:

if ( window.Tuna != undefined ) {
        Wad.tuna = new Tuna(Wad.audioContext)
}

As a workaround I am using this:

var Tuna = require('tunajs');

window.Tuna = Tuna;
var Wad = require('./../vendors/wad/wad.min');

I suggest refactoring to a Common.js build which uses tunjas as dependency from NPM, so the min build will include it automatically and Common.js environments will treat Tuna as normal dependency. If you want, I can help you in this matter.

rserota commented 8 years ago

Thank you for raising this issue. I would definitely appreciate your help with refactoring. A pull request would be ideal.

phal0r commented 8 years ago

Ok, sure thing. I already forked it and added ArrayBuffers and AudioBuffers as valid source porperty for WAD :)

rserota commented 8 years ago

Those sound like useful features. Just be careful not to break any recording features, since I believe creating a Wad from a recording also uses ArrayBuffers. Check out lines 2594-2599 3298-3311 in build/wad.js. There might be an opportunity for a refactor there as well.

phal0r commented 8 years ago

Thanks for the hint, I will check it out.

frastlin commented 6 years ago

I just ran into this issue as well. I am using Wad in my react app that uses pure ES6 with Babel. if I try and use tuna I get the following error: TypeError: Wad.tuna is undefined ["./node_modules/web-audio-daw/build/wad.js"]/</Wad</setUpTunaOnPlay

Looking forward to this fix! Thanks,

rserota commented 6 years ago

Tuna should now work properly in version 3.0.0.