Skip to content

[Question] Accessing Audio Output Data for Visualization? #722

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

Open
JamesMoreau opened this issue Mar 28, 2025 · 1 comment
Open

[Question] Accessing Audio Output Data for Visualization? #722

JamesMoreau opened this issue Mar 28, 2025 · 1 comment

Comments

@JamesMoreau
Copy link

Hi, I’m working on a music player using rodio and would like to implement a real-time audio visualizer, akin to what is seen in WinAmp. To achieve this, I need access to the audio data being played.

Is there a way to access the audio samples rodio sends to the output device?

If not, what’s the easiest approach to achieve this while still using rodio for playback?

Thanks.

@dvdsk
Copy link
Collaborator

dvdsk commented Mar 28, 2025

Yes but you might need to do a little more work then usual since you can not use Sink. Instead you want to use rodio's audio pipeline directly and add a custom component for visualization.

Here are some helpful examples for using rodio's pipeline directly:

In addition to that you will use inner_mut() within the periodic_callback() closure to get to to different components in the pipeline. See this part of the Sink source as an example for that.

Regarding the audio visualization, you probably need to do something with every sample for that. You need to add a custom Source for that. It will wrap any other source (see amplify as example). In the iterator implementation for the source you can the freely do something with the samples as long as its fast. You might want to send the samples over to another thread and make the visualization there.

Good luck!

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