I am trying to a small audio songs equalizer. I want to add in it options of treble,stereo like it is in Poweramp player.
I implemented equlizer with 5 bands successfully like this:-
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();
}
});
}
}
Above code is just a short brief of my equalizer code.it wont work just as a example i posted here . .
I too want to add treble, stereo, mono effects in my equalizer.
I already implemented bass boost like this:
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 an inbulilt class for bass boost.
How can I add treble and stereo/mono effects to my app?