We write a music player for android. There was a task to make a normal equalizer. In general, there are a couple of questions.

First, if ndk not used, then the standard class Equalizer (SDK) provides 5 tracks (frequencies), and in many players under the android of these tracks there will be more.

Secondly, it is necessary to realize the volume, bass and treble. Volume turned out to do:

 float percent=jogView.angle_/(270+0.f); int volume = Math.round(maxVolume*percent); audio.setStreamVolume(AudioManager.STREAM_MUSIC, volume, 0); 

There are also presets in the standard Equalizer, but there are few of them:

  • Classical,
  • Dance,
  • Jazz
  • Pop,
  • Rock

Here, if necessary, the code of the equalizer tracks:

 private void setupEqualizerFxAndUI() { // Create the Equalizer object (an AudioEffect subclass) and attach it to our media player, // with a default priority (0). Equalizer.Settings eqSettings=mEqualizer.getProperties(); Log.v("Settings",eqSettings.toString()); TextView eqTextView = new TextView(this.c); eqTextView.setText("Equalizer:"); mLinearLayout.addView(eqTextView); short bands = mEqualizer.getNumberOfBands(); final short minEQLevel = mEqualizer.getBandLevelRange()[0]; final short maxEQLevel = mEqualizer.getBandLevelRange()[1]; for (short i = 0; i < bands; i++) { final short band = i; TextView freqTextView = new TextView(this.c); freqTextView.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); freqTextView.setGravity(Gravity.CENTER_HORIZONTAL); freqTextView.setText((mEqualizer.getCenterFreq(band) / 1000) + " Hz"); mLinearLayout.addView(freqTextView); LinearLayout row = new LinearLayout(this.c); row.setOrientation(LinearLayout.HORIZONTAL); TextView minDbTextView = new TextView(this.c); minDbTextView.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); minDbTextView.setText((minEQLevel / 100) + " dB"); TextView maxDbTextView = new TextView(this.c); maxDbTextView.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); maxDbTextView.setText((maxEQLevel / 100) + " dB"); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.weight = 1; SeekBar bar = new SeekBar(this.c); bar.setLayoutParams(layoutParams); bar.setMax(maxEQLevel - minEQLevel); bar.setProgress(mEqualizer.getBandLevel(band)); bar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mEqualizer.setBandLevel(band, (short) (progress + minEQLevel)); } public void onStartTrackingTouch(SeekBar seekBar) {} public void onStopTrackingTouch(SeekBar seekBar) {} }); row.addView(minDbTextView); row.addView(bar); row.addView(maxDbTextView); mLinearLayout.addView(row); } } 

How to make a treble, bass? And how to make more tracks to adjust the equalizer?

    1 answer 1

    In the framework of Java, I suppose, nothing. It is enough to look at the source code of the Equalizer class to understand that there are 5 equalizer bands there.

    Go towards the NDK - for example, here .

    PS Not tracks E of the Qualizer , but bands of the E Qualizer

    • I read the equalizer documentation, and there are few settings. Thanks for the example. Is it possible to connect a piece of ndk painlessly into a java project? - Firespirit