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: AudioWorkletize #307
base: main
Are you sure you want to change the base?
WIP: AudioWorkletize #307
Conversation
@@ -76,6 +76,8 @@ | |||
(function () { | |||
var _this; | |||
var Audio = function Audio(bufferSize) { | |||
var _this2 = this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea what happened here
Hey @hughrawlinson - thanks for starting this! I'd love to have a look at this properly over Christmas. It's definitely possible to load the worklet code via Webpack, and we can figure out a nice model for sending frame-synced feature data back to the main thread. We could just try a naive technique with |
Hi, Would be happy to know what is the state of this PR, since i'm attempting to use Meyda with the standardized-audio-context and it is currently not possible... createScriptProcessor is not a part of it.. |
@Seanitzel I think the current state is that we'll spend time on it when we can, but that use case makes a much stronger case for prioritizing it! Thanks for sharing 😄 |
No problem! Anything i can do to speed up things? |
@Seanitzel I'll take a look today, see if there's any issues I can break out on their own, and you could pick one of those to tackle if you like! |
@Seanitzel I got stuck here. The issue is that I haven't been able to get the webpack worklet loader to run the JS in the imported file through webpack before inlining it. That meant I couldn't actually run meyda inside the worklet. I have a vague idea that it might be possible to have webpack do some code splitting and import code into strings that get registered as blob-urls and can then be client-side imported in both the main thread and the worklet. But that's super confusing for me right now. I'll try to come back to it when I have time. There was also a bit of a design issue in here. Since the feature extraction happens in another thread, the user of meyda would need to asynchronously get the latest audio features, which makes rendering realtime animations based on the audio features pretty tricky without an awful lot of expensive message passing. We'll need to think of a good way to solve that too. In case it helps, I have been working on a library that does offline audio feature extraction using meyda in a worker, so if you have all your audio up front, it might be a good option. It's called feature-extractor-worker, and there's an alpha on npm. Does that suit your use case? |
b3a415a
to
a599bfe
Compare
@hughrawlinson My use case is real-time extraction too. I guess i will attempt to implement the extractors i need independently, but will keep an eye on this. Thank you for the support! :) |
@Seanitzel if you want to just use the feature extractors directly you can import them from Meyda still. Something like |
I should have thought about trying that haha, it works! Thank you :) |
Hi, Any update on this? I believe browsers will soon be removing the WebAudio script processor API. I can try to merge this PR on a local branch. Is it fully working as far as you know (minus docs/package-lock.json confilicts)? |
Hi! I haven't heard of browsers planning to remove the ScriptProcessorNode interface - can you link to an issue tracker issue for that? If I remember correctly, this PR works, but has a significant bump in bundle size that I'd like to avoid before merging. |
Hi Hugh, The reason I brought it up was because I've heard the audio script processor works on the main (UI) thread, which has a lot going already in my app. The post I saw was from a while back and it said "deprecated" not removed, so I apologize for raising any alarm. It would be very nice to have this library up to date with e latest audio processing API, but I am not really sure what the issue with the bundler may be. Is it duplicating some stuff? |
related to #286
To be clear, this is just my sketch at how it might work, I wanted to understand how to use AudioWorklet. Would love feedback if someone has time, no worries otherwise. I'll hope to keep going with this.
I think generally I'm leaning towards separate packages here, to get around loading two copies of Meyda (or, we can rely on our users tree shaking, or maybe web modules are good).
@jakubfiala I know you worked on this back in February, would love to see some code if you have it :)