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

Capture Handling with audio frame stack #15

Open
dcerisano opened this issue Jan 16, 2015 · 1 comment
Open

Capture Handling with audio frame stack #15

dcerisano opened this issue Jan 16, 2015 · 1 comment

Comments

@dcerisano
Copy link

Thanks for your work with the Visualizer class, especially the decoding of the FFT frame.

Your app synchronizes animation with the sound sampling rate with (invalidate).

   * Pass FFT data to the visualizer. Typically this will be obtained from the
   * Android Visualizer.OnDataCaptureListener call back. See
   * {@link Visualizer.OnDataCaptureListener#onFftDataCapture }
   * @param bytes
   */
  public void updateVisualizerFFT(byte[] bytes) {
    mFFTBytes = bytes;
    invalidate();
  }

The problem with this is that Visualizer's sound sampling mechanism is clunky. I have only seen a maximum sound buffer sampling rate of about 50ms which is crippling your graphics frame rate to about (20 fps) because of the synchronization with (invalidate).

The solution is to abandon Visualizer's data capture listener and set up a simple capture handler than runs at a nice smooth 60 fps.

Using a thread safe stack to store the capture frames will asynchronize the audio capturing and graphics rendering threads. Mirror smooth animation will result. Your graphics thread can feed on the stack asynchronously.

Your graphics are pretty basic and should be able to keep up, with room for even more fancy stuff.

It should result in peformance like this WebGL visualizer (which passes FFT data to the GPU as a texture!)
https://www.shadertoy.com/view/Xds3Rr

@felixpalmer
Copy link
Owner

All sounds most sensible. If you get to implementing a more performant version, that will be most welcome

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