0

I have an AudioTrack generated in my code. I retrieved the code from here.

What i need to do is to get the band level of the tone generated. So, to be able to do this, I initialized an Equalizer, and set the audio session to the session id of the generated audio track.

audioTrackSessionId = audioTrack.getAudioSessionId();
equalizer = new Equalizer(1, audioTrackSessionId);
equalizer.setEnabled(true); 

What I need is to retrieve the band level for the frequency given, let's say freqOfTone = 1000; //Hz so I need to get the level of band 2 (band 2 's range is 461Hz to 1800Hz).

If I use equalizer.getBandLevel(2) it's returning the level of the equalizer by default, not the level of the generated tone (audioTrack).

Does anyone know how to retrieve the band level of the generated tone?

Hanady
  • 779
  • 2
  • 15
  • 38
  • What you're trying to do is not supported by the Equalizer API. You could try using the [Visualizer.getFft](http://developer.android.com/reference/android/media/audiofx/Visualizer.html#getFft(byte[])) method instead. – Michael Aug 09 '13 at 14:53
  • But how can i get the level in db for a frequency given using getFft() method? – Hanady Aug 12 '13 at 05:53
  • @Hanady have you checked the answer.Why don't you accept the answer. – shehzy Mar 05 '15 at 08:36

1 Answers1

1

getBandLevel like this

short minEQLevel = equalizerWrapper.getBandLevelRange()[0];

short maxEQLevel = equalizerWrapper.getBandLevelRange()[1];
Zar E Ahmer
  • 33,936
  • 20
  • 234
  • 300