webaudiomodules / wam-examples

MIT License
44 stars 7 forks source link

Failed to load second WebAudioModule #97

Open yojeek opened 1 year ago

yojeek commented 1 year ago

Problem

Bundled WebAudioModule examples can be only loaded once. Attempt to load another module ends with

localhost/:1 Uncaught DOMException: Failed to execute 'registerProcessor' on 'AudioWorkletGlobalScope': An AudioWorkletProcessor with name:"com.webaudiomodule.default" is already registered.

Steps to reproduce

  1. Run yarn start
  2. Open browser
  3. Select "Synth101" and load it
  4. Select "OBXD" and load it

Enviorenment

Chrome Version 114.0.5735.198 (Official Build) (x86_64) MacOS 12.3.1

Screenshot 2023-07-12 at 22 05 22
micbuffa commented 1 year ago

Hmmm this seems to be a bug in the ObXd wam. When I try to load other WAMs the error never happens. It only happens when ObXd is loaded, then other wam fail. We investigate...

micbuffa commented 1 year ago

Hmmm it seems that the error raised by Obxd should be caught and displayed as a warning...

micbuffa commented 1 year ago

What are you trying to do? Thanks for notifying us the error with ObXd...

yojeek commented 1 year ago

@micbuffa I've put together example https://github.com/yojeek/wam-examples/commit/d0c11df516d925d04f13649766f673edd61b9f33

I've bundled simpleMidiKeyboard with Rollup and tried to use it together with synth101 and OBDX, and both times it failed.

Steps to reproduce:

  1. Run host
  2. Select "Simple MIDI Keyboard (packed)" from list
  3. Load
  4. Select "synth101" or "obdx" from list
  5. Load

I assumed that something wrong with bundling part.

micbuffa commented 1 year ago

Hi! I'll try to see what's wrong in your example. In between, I quickly made a small example that might help, that requires no "building step at all": https://mega.nz/file/TtxS0KpS#ef1LI0T8lpFXbGwKvRD-cjuqlXnc5nzCOVWrWggkTXI

This examples has all the api, sdk, sdk-parammgr pre-built in a libs dir. It also uses two web components we wrote for simplifying the embedding if WAMs in a HTML page ( and ), you can edit the index.html file. What is interesting is that you have here an example of reuse of existing WAMs. We really need to make a set of small examples, with and without build tools. I had to edit the paths that reference the sdk, sdk-parammgr and api in the index.js of the WAMs, and also I completed the descriptors with hasMidiInput, hasMidiOutput etc... we extended the descriptor recently and the wam-example repo is not up to date. WAMs are ok without this, but can't be loaded with our new wam-host and wam-plugin web components. I'll look at your example this afternoon.

yojeek commented 1 year ago

@micbuffa I've tried to replace synth101 from this repo with synth101 from https://github.com/boourns/wam-community and the later version works just fine with bundled simpleMidiKeyboard scenario. So looks like something wrong with version of Synth101 used in this repo .

Added it to my example for comparison : https://github.com/yojeek/wam-examples/commit/be72c6a9296e7c6fe7765af284491e774b6793d9

micbuffa commented 1 year ago

I also took synth101 from https://github.com/boourns/wam-community (after building it) for the example I shared. I just edited the paths to api, sdk and sdk-parammgr from the index.js of synth101. So you say that the synth101 from wam-example is the one that does not work well, due to a bad versions of sdk, api, sdk-parammgr from the wam-examples repo? I'll check that too... This repo is indeed a bit outdated (descriptors are not up to date), and maybe the embedded version of sdk, api and sdk-parammgr are not correct. Thanks for notifying.

yojeek commented 1 year ago

I strongly believe that the reason of original issue is absence of identifiers (related PR): https://github.com/webaudiomodules/wam-examples/pull/94.

Also, it should be stated in readme/wiki that unique identifier is mandatory for a plugin.

Once you have two plugins without identifiers everything collapses.

micbuffa commented 1 year ago

Thanks for this bug report. We'll try to update the repo rapidly. Indeed, missing ids make sense for this kind of bug.

Fr0stbyteR commented 1 year ago

See #94