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

ScriptProcessor vs. AudioWorklet vs. AnalyserNode #24

Open
danigb opened this issue Oct 18, 2021 · 2 comments
Open

ScriptProcessor vs. AudioWorklet vs. AnalyserNode #24

danigb opened this issue Oct 18, 2021 · 2 comments

Comments

@danigb
Copy link

danigb commented Oct 18, 2021

Very nice library, thanks!

I have a question: is there a reason not to use an AnalyserNode? From an audio performance point of view, it would be the best option.

If there are any impediments, I guess the next best option is to use AudioWorklet, because ScriptProcessorNode is deprecated. Any plans on this?

@esonderegger
Copy link
Owner

Thanks! And that's a great question!

To support features like peak holding, or calculations like true-peak metering, this library needs to read sample values. To the best of my knowledge, that means AnalyzerNode is out.

As for ScriptProcessorNode vs AudioWorklet, until relatively recently (Safari 14.1 - a little over a year ago), AudioWorklet hasn't been supported across all major browsers. I wrote most of this code for a hackathon in 2014 and don't use it for any work projects, so I hadn't been following these advancements closely.

I've recently started trying to do a rewrite of this library using AudioWorklet and Typescript. I figured that, since AudioWorklet requires a secure context, it would be a breaking change no matter what. So it would be a good time to rework other parts of the public API too (like initialization being cut from a two-step process to a single one, and making vertical vs horizontal explicit).

It's been a slow process, though (I only have about 30 minutes a day to work on it) so no promises on when this will be ready to be released. I'm hoping some time in February or March.

@suterma
Copy link

suterma commented Mar 24, 2023

I was wondering about this too. AnalyzerNode can get the raw samples though, using https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getFloatTimeDomainData.

In my use case I also want to support Apple iOS from version 12, so reading @esonderegger 's answer, this would actually be a dealbreaker for me.

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

No branches or pull requests

3 participants