我的均衡器活动班级
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_equalizer);
verticalSeekbar[0] = findViewById(R.id.verticalSeekbar1);
slider_labels[0] = findViewById(R.id.tvFreq1);
slider_value[0] = findViewById(R.id.value1);
verticalSeekbar[1] = findViewById(R.id.verticalSeekbar2);
slider_labels[1] = findViewById(R.id.tvFreq2);
slider_value[1] = findViewById(R.id.value2);
verticalSeekbar[2] = findViewById(R.id.verticalSeekbar3);
slider_labels[2] = findViewById(R.id.tvFreq3);
slider_value[2] = findViewById(R.id.value3);
verticalSeekbar[3] = findViewById(R.id.verticalSeekbar4);
slider_labels[3] = findViewById(R.id.tvFreq4);
slider_value[3] = findViewById(R.id.value4);
verticalSeekbar[4] = findViewById(R.id.verticalSeekbar5);
slider_labels[4] = findViewById(R.id.tvFreq5);
slider_value[4] = findViewById(R.id.value5);
mEqualizer = new Equalizer(0, mediaPlayer.getAudioSessionId());
setupEqualizer();
mEqualizer.setEnabled(true);
for (short i = 0; i < 5; i++){
final short equalizerBandIndex = i;
int freq_range = mEqualizer.getCenterFreq(equalizerBandIndex);
verticalSeekbar[i].setMax(upperEqualizerBandLevel - lowerEqualizerBandLevel);
verticalSeekbar[i].setProgress(mEqualizer.getBandLevel(equalizerBandIndex));
verticalSeekbar[i].setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
mEqualizer.setBandLevel(equalizerBandIndex, (short) (progress + lowerEqualizerBandLevel ));
slider_value[equalizerBandIndex].setText(String.valueOf((progress + lowerEqualizerBandLevel) / 100) + " dB");
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
slider_labels[i].setText(formatBandLabel(freq_range));
float scale2 = getResources().getDisplayMetrics().density;
int dpAsPixels2 = (int) (8*scale2 + 0.5f);
setupEqSpinner();
}
}
在for循环中,我将频带数限制为5,因为我只想显示5个频带,所以它与我的xml设计相匹配。
但是我的问题是当我使用时:
Log.i(TAG, "Number of bands: " + mEqualizer.getNumberOfBands());
它返回数字5,所以我的设备支持 5个均衡器频段,对吗?
但是我还有另一个mediaplayer应用程序,它显示7个频段,频率不是 60Hz,230Hz,910Hz,3kHz,14kHz ,而是 50Hz,130Hz,320Hz,800Hz,2kHz,5kHz和12.5kHz。
那么即使均衡器仅支持 5个频段,应用程序也可能显示 7个频段?
谢谢