Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove options argument from AWP constructor #2040

Merged
merged 2 commits into from
Aug 21, 2019

Conversation

hoch
Copy link
Member

@hoch hoch commented Aug 21, 2019

Fixes #2036 per #2036 (comment).

In short, the base class constructor does not need options passed from the node.


Preview | Diff

@hoch hoch requested a review from rtoy August 21, 2019 19:22
@hoch hoch added this to In PR Review in V1 Aug 21, 2019
@hoch hoch merged commit 8b52eb7 into WebAudio:master Aug 21, 2019
V1 automation moved this from In PR Review to Done Aug 21, 2019
@hoch hoch deleted the 2036-remove-options-awp branch August 21, 2019 21:13
@pm100
Copy link

pm100 commented Feb 12, 2022

well I just spent a happy few hours working out that I cannot pass options into the constructor (I only needed options at worklet startup so this seemed a better option that processing via process method args). All the docs say its supported. The typescript def files all have it.

@padenot
Copy link
Member

padenot commented Feb 14, 2022

You can, and it works:

<script type="[worklet]()">
  registerProcessor('test-param', class param extends AudioWorkletProcessor {
    constructor(options) {
      console.log("ctor", options.processorOptions);
      super(options)
    }
    process(input, output, parameters) {
    }
  });
</script>
<script>
  var ac = new AudioContext;
  var e = document.querySelector("script[type=worklet]")
  var text = e.innerText;
  const blob = new Blob([text], {type: "application/javascript"});

  var url = URL.createObjectURL(blob);
  var option = { key: "An option" };
  ac.audioWorklet.addModule(url).then(() => {
      nodea = new AudioWorkletNode(ac, 'test-param', {processorOptions: option});
      nodea.connect(ac.destination);
  });
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
V1
  
Done
Development

Successfully merging this pull request may close these issues.

Remove options parameter of AudioWorkletProcessor constructor
4 participants