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

Making visualization independent of the volume #19

Open
mobilevisuals opened this issue Apr 23, 2015 · 5 comments
Open

Making visualization independent of the volume #19

mobilevisuals opened this issue Apr 23, 2015 · 5 comments

Comments

@mobilevisuals
Copy link

If the volume is high, the FFT values are also higher. This will make the music visualization dependent on the volume, which is not a good thing. It should be the same visualization for low and high volumes. I found an interesting and easy solution to that problem:

http://stackoverflow.com/questions/8048692/android-visualizer-fft-waveform-affected-by-device-volume

It works for apps, which have their own music player, because they then have a MediaPlayer object. The Equalizer and the Visualizer must have the same audio session id for this to work. That session id belongs to the MediaPlayer object.

The problem is that it does not work for external media players, like Spotify. The visualization becomes dependent on the volyme there. There is no option get a handle to a mediaplayer object for Spotfify, so I have to set the audioSessionID to 0. This means any player currently used. This will however make the volume code not work.

Has someone a good suggestion to make this work on external players too? It would help me a lot to keep improving my apps. The following are the code i added to the apps. The first code works and is for apps with their own player . The second code is for external players like Spotify and it does not work.

  1. Internal players:

// Create the Visualizer object and attach it to our media player.
mVisualizer = null;
int sessionId = player.getAudioSessionId();
mEqualizer = new Equalizer(0, sessionId);
mEqualizer.setEnabled(true);
mVisualizer = new Visualizer(sessionId);

  1. External players:

    mVisualizer = null;
    int sessionId = 0;
    mEqualizer = new Equalizer(0, sessionId);
    mEqualizer.setEnabled(true);
    mVisualizer = new Visualizer(sessionId);

@mobilevisuals
Copy link
Author

Has anyone found a solution to this? It is very annoying that this works on iOS, but not on Android.

@NFSS10
Copy link

NFSS10 commented Jan 26, 2017

I can't find a solution either, did someone found a fix already?

@tracyliu1
Copy link

tracyliu1 commented Dec 28, 2017

I tried the second code and it seems worked! I was use the Locamedia App(A mediaplayer running backgroung in service), then the visualizer is in another App. oh,sorry, It`s on Android.

BTW,I test mEqualizer.setEnabled(true) ,mVisualizer.setEnabled(true) .but the visualization still depends on volume

@hallidev
Copy link

hallidev commented Mar 8, 2018

There is a method on the Visualizer class called SetScalingMode - have you tried that?

@timendez
Copy link

I'm encountering the same problem. I'm enabling the equalizer, setting the scaling mode to normalized, and still getting audio-dependent FFT data for a Visualizer with an audioSession of 0

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

5 participants