How to add stereo, high frequencies in the sound equalizer?

I am trying to use a small sound equalizer. I want to add to it the options for high frequencies, stereo, as in the Poweramp player.

Poweramp music player image

I have successfully implemented an equlizer with 5 bands:

public class FragmentEqualizer extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) { super.onCreateView(inflater,container,savedInstanceState); equalizer = new EQ(getActivity(), new Equalizer(0,com.androidhive.musicplayer.AndroidBuildingMusicPlayerActivity.mp.getAudioSessionId())); for(Bar bar : eqBars) bar.setActiveEQ(); maximum= EQ.getEqualizer().getBandLevelRange()[1]; minimum= EQ.getEqualizer().getBandLevelRange()[0]; } public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); lvforprest.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view,int position, long id) { btnformenu.setText(gtuforpresets.get(position).gtumcaFirstName); if(position!=0 && position <=10) { try { EQ.getEqualizer().usePreset((short) (position-1)); EQ.getEqualizer().setBandLevel((short)0, EQ.getEqualizer().getBandLevel((short) 0)); EQ.getEqualizer().setBandLevel((short)1, EQ.getEqualizer().getBandLevel((short) 1)); EQ.getEqualizer().setBandLevel((short)2, EQ.getEqualizer().getBandLevel((short) 2)); EQ.getEqualizer().setBandLevel((short)3, EQ.getEqualizer().getBandLevel((short) 3)); EQ.getEqualizer().setBandLevel((short)4, EQ.getEqualizer().getBandLevel((short) 4)); eqBars.get(0).setEQPosition(EQ.getEqualizer().getBandLevel((short) 0)); eqBars.get(1).setEQPosition(EQ.getEqualizer().getBandLevel((short) 1)); eqBars.get(2).setEQPosition(EQ.getEqualizer().getBandLevel((short) 2)); eqBars.get(3).setEQPosition(EQ.getEqualizer().getBandLevel((short) 3)); eqBars.get(4).setEQPosition(EQ.getEqualizer().getBandLevel((short) 4)); seekbar1katop.setText(EQ.getEqualizer().getBandLevel((short) 0)+"mB"); seekbar2katop.setText(EQ.getEqualizer().getBandLevel((short) 1)+"mB"); seekbar3katop.setText(EQ.getEqualizer().getBandLevel((short) 2)+"mB"); seekbar4katop.setText(EQ.getEqualizer().getBandLevel((short) 3)+"mB"); seekbar5katop.setText(EQ.getEqualizer().getBandLevel((short) 4)+"mB"); } catch(IllegalStateException e) { Toast.makeText(getActivity(),"Unable",Toast.LENGTH_SHORT).show(); } catch(IllegalArgumentException e) { Toast.makeText(getActivity(),"Unable",Toast.LENGTH_SHORT).show(); } catch(UnsupportedOperationException e) { Toast.makeText(getActivity(),"Unable",Toast.LENGTH_SHORT).show(); } } // Toast.makeText(getApplicationContext(),"You Clicked : " + mEqualizer.getEnabled(),Toast.LENGTH_SHORT).show(); } }); } } 

The above code is just a brief summary of my equalizer code. This does not work, like the example I posted here. .

I also want to add triple, stereo, mono effects to my equalizer.

I already implemented the bass tuning as follows:

 public static void setBassBoost(BassBoost bassBoost, int percent) { try{ bassBoost.setStrength((short) ((short) 1000 / 100 * percent)); bassBoost.setEnabled(true); }catch (Exception e){ } } public static void setBassBoostOff(BassBoost bassBoost) { bassBoost.setEnabled(false); } 

I used the inbulilt class to enhance the bass.

How to add trio and stereo / mono effects to my application?

+7
java android android-layout audio
source share
1 answer

There is no need to use an AudioTrack object to change the low, mid and high frequencies (even because you can only play compressed PCM data with this object).

You just need to adjust the level of natural frequencies using Equalizer . To get the number of ranges available, just call:

 myEqualizer.getNumberOfBands() 

Given the number of ranges available, you can set the level for each range using the following method:

 myEqualizer.setBandLevel(band, level); 

Where:

range : a frequency band that will have a new gain. Numbering strips start at 0 and end with (number of strips - 1).

level : new win in milliseconds to be set in this band. getBandLevelRange () will determine the maximum and minimum values.

The value of each bar from left to right is shown in the following image:

ranges meaning

UPDATE

To implement the trivial balance effect, simply highlight the volume left / right on your player ( MediaPlayer , SoundPool , ...):

 mediaPlayer.setVolume(left, right) 

To get a mono effect, you can use Virtualizer , which provides a stereo expansion effect, you can set the strength of the virtualization effect using the method:

 virtualizer.setStrength(1000); //range is [0..1000] 

You need to carefully read the documentation to check if the current configuration of your virtualizer is really supported by the base system.


In any case, this is not a true monophonic conclusion, and I think that you cannot get a monaural stereo speaker without using a low-level API such as AudioTrack (in fact, Poweramp uses its own JNI libraries for its sound pipeline). If you want to use AudioTrack for playback, you need to consider that it only supports PCM (WAV) data as input: this means that you cannot play compressed audio file (for example, MP3, flac, ...) since you you must first manually decode the compressed audio file.

 [Compressed File (MP3)] ===> decode() ===> [PCM data] ===> customEffect() ===> AudioTrack playback() 

Thus, to play compressed audio using both AudioTrack (and, ultimately, creating a custom effect), the following steps are required:

I suggest you skip this effect;)


As for the bass boost effect, you need to check if your current configuration is supported by a running device (like a virtualizer). Have a look here for more info on this.

+9
source share

All Articles