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

WIP: Support for automated parameters #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

martinholters
Copy link

This is a proof-of-concept implementation picking up the idea from #15 (comment). It works like a charm for my limited use case (exponentialRampToValueAtTime and cancelAndHoldAtTime only). I've tried to implement the whole spec (except for throwing on error conditions for now), and the complexity is somewhat alarming. I also haven't done much testing, so this is likely still rather buggy. Before investing more time to finish this, I'd appreciate some feedback:

  • Does this approach look like a good idea? Does it have any drawbacks I'm not aware of (yet)?
  • Is all this extra code worth it?

Fixes #15.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

@martinholters
Copy link
Author

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

@martinholters
Copy link
Author

Any thoughts on this, @developit?

@developit
Copy link
Collaborator

developit commented Dec 5, 2018

Hey @martinholters! Sorry about the wait there - I read this but then forgot to come back to the tab. I like the approach and I think this is the right way to move forward. However, I have to wonder - do you think this would be worth pulling out into its own library as an AudioParam polyfill? I could certainly see other polyfills using it.

Cheers!

@@ -25,14 +25,180 @@ if (typeof AudioWorkletNode !== 'function') {
const outputChannels = options && options.outputChannelCount ? options.outputChannelCount[0] : 2;
const scriptProcessor = context.createScriptProcessor(undefined, 2, outputChannels);

const automationEvents = new Map();

function SetValue (value, startTime) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like these classes could get pulled out of AudioWorkletNode so they're shared?

@martinholters
Copy link
Author

However, I have to wonder - do you think this would be worth pulling out into its own library as an AudioParam polyfill?

I'm not sure I fully understand, so let me check we're on the same page. It might make sense to pull this into a library which provides a way to construct an AudioParam and then an API call to evaluate its value at a specific time/for a block of samples, basically putting the code now added toscriptProcessor.onaudioprocess into its own function. That might indeed be useful when implementing your own ScriptProcessor. (Although I wouldn't call it a polyfill; that might be part of the reason I'm not sure I understood you correctly.) Do you see other application scenarios?

@developit
Copy link
Collaborator

You described what I meant perfectly, and agreed regarding it not really needing to be a polyfill. Shouldn't block merging based on that goal though, I'll re-review (sorry for the delay!)

@chrisguttandin
Copy link

Hi @martinholters, I just came across this thread. I recently created a very similar abstraction for my standardized-audio-context package. The little library is called automation-events. It maintains a list of automation events and provides a method to get the value of the hypothetical AudioParam at a certain point in time. Maybe that comes in handy for what you're planning to do.

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

Successfully merging this pull request may close these issues.

Scheduled parameter changes not working
4 participants