質問

I'm working on some music analysis using the Visualizer class on Android 2.3.1. I am finding that the FFT and waveform magnitudes are affected by the volume of the device. This means that if the user has the volume turned down I receive little or not FFT data.

I've tested this on a Motorola Xoom, Samsung Galaxy Tab and the emulator and it behaves this way.

I am using the code below:

mp = new MediaPlayer();
mp.setDataSource("/sdcard/sine1.wav");
mp.prepare();
mp.setLooping(true);
mp.start();
int audioSessionID = mp.getAudioSessionId();
v = new Visualizer(audioSessionID);
v.setEnabled(true);

Looking at the docs for the Visualizer class it seems that if we are passing in a valid audio session id then the visualizer should operate upon this audio session. It appears that the Visualizer is operating upon the output mix.

Has anyone else encountered this or found a way around it?

Thanks

役に立ちましたか?

解決

I was also facing the same problem, but it is working when i am enabled the Eqaulizer and Visualizer for same seession id.I dont know the reason for it ,i checked it remove the equalizer from visualizer class in api demos it is working as you said.

 Equalizer mEqualizer = new Equalizer(0, SessionId);
 mEqualizer.setEnabled(true); // need to enable equalizer
 Visualizer mVisualizer = new Visualizer(SessionId);

他のヒント

There are two options for the Visualizer scaling mode:

SCALING_MODE_AS_PLAYED and SCALING_MODE_NORMALIZED

If you want the Visualizer to be normalized, as in it's consistent no matter what the volume is, then use SCALING_MODE_NORMALIZED.

mVisualizer.scalingMode = Visualizer.SCALING_MODE_AS_PLAYED

Keep in mind though that this drastically changes the values being sent to the Visualizer, so other adjustments may be needed.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top