GoogleChromeLabs / audioworklet-polyfill

🔊 Polyfill AudioWorklet using the legacy ScriptProcessor API.
https://googlechromelabs.github.io/audioworklet-polyfill/
Apache License 2.0
195 stars 20 forks source link

WIP: Support for automated parameters #16

Open martinholters opened 5 years ago

martinholters commented 5 years ago

This is a proof-of-concept implementation picking up the idea from https://github.com/GoogleChromeLabs/audioworklet-polyfill/issues/15#issuecomment-436105404. 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:

Fixes #15.

googlebot commented 5 years ago

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).

:memo: 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 commented 5 years ago

I signed it!

googlebot commented 5 years ago

CLAs look good, thanks!

martinholters commented 5 years ago

Any thoughts on this, @developit?

developit commented 5 years ago

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!

martinholters commented 5 years ago

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 commented 5 years ago

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 commented 4 years ago

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.