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

Record output of audio visualizer with proper delays in audio player #72

Open
BenBergman opened this issue Feb 1, 2018 · 4 comments
Open

Comments

@BenBergman
Copy link

I'm trying to record the output of an audio visualizer I built that uses HTML5 audio tag sources for input and feeds in through an analyzer node. When played without CCapture it runs just fine at a high framerate. With CCapture running it runs at a slow frame rate (as expected) but the audio is still running real time. This causes the video output to appear as though it is in fast forward.

I see that CCapture overrides HTMLAudioElement.prototype.currentTime. Do I need to enable anything to get this working? I have tried with Firefox and Chrome and I don't see any errors in the console with verbose mode on.

@spite
Copy link
Owner

spite commented Feb 1, 2018

Yes, unfortunately there's no way to "throttle" the internal workings of Web Audio, so the AnalyserNode will run in real time, desyncing from the canvas capture. That's a problem that affects all captures that deal with FFT and signal processing, I've run into that many times. There's only two real solutions or workarounds: reimplement the AnalyserNode so it runs throttled, or pre-generate and store the FFT result. 😐

@BenBergman
Copy link
Author

BenBergman commented Feb 1, 2018

Ah, interesting. I'm not even using the FFT, I'm just looking at the waveform. If Web Audio can't be throttled, what effect does swapping out the currentTime property have? Is there an alternative to using AnalyserNode for just looking at the waveform which works with CCapture?

@spite
Copy link
Owner

spite commented Feb 1, 2018

CurrentTime is part of the HTMLAudio/VideoElement, so it's monkey patched in case your code is syncing to an audio or video file.

There isn't a way to sync AnalyserNode, AFAIK, except the two options i mentioned before, replacing frequency domain data (FFT) with time domain data in your case.

I mean, technically stopping and starting the audio graph should work, but i've never tried...

@BenBergman
Copy link
Author

BenBergman commented Feb 2, 2018

Ah, gotcha. currentTime is just for time based sync with tracks, not actual reactivity to sound. I thought maybe it was used internally for playback coordination or something but was failing to do so when using analyserNode. My mistake.

For the purposes of my current project's proof of concept I've managed to get the frame dropping with a screen capture program to a tolerable level. If I want to improve this further I'll make two apps: one that analyses the audio and spits out data with time stamps and another that feeds that data into the visualizer and renders out using CCapture, much as you suggested.

Thanks for the feedback!

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

2 participants