Skip to content

Making visualization independent of the volume #19

Open
@mobilevisuals

Description

@mobilevisuals

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions