用于显示均衡器频段的代码
mEqualizer = new Equalizer(0, mediaPlayer.getAudioSessionId());
final short lowerEqualizerBandLevel = mEqualizer.getBandLevelRange()[0];
final short upperEqualizerBandLevel = mEqualizer.getBandLevelRange()[1];
//VerticalSeekBar1
int freq_range0 = mEqualizer.getCenterFreq((short)0);
verticalSeekbar[0].setMax(upperEqualizerBandLevel - lowerEqualizerBandLevel);
verticalSeekbar[0].setProgress(mEqualizer.getBandLevel((short)0));
verticalSeekbar[0].setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
mEqualizerBandLevel0 = progress;
mEqualizer.setBandLevel((short) 0, (short) (progress + lowerEqualizerBandLevel ));
slider_value[0].setText(String.valueOf((progress + lowerEqualizerBandLevel) / 100 + " dB"));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
slider_labels[0].setText(formatBandLabel(freq_range0));
verticalSeekbar [0]:是第一个均衡器频段,我有5个均衡器频段,所以verticalSeekbar [1] ...依此类推,直到[4]。
用于显示设备支持的预设的微调器的代码。
final ArrayList<String> eqPresets = new ArrayList<>();
ArrayAdapter<String> eqPresetsAdapter = new ArrayAdapter<>(this,R.layout.spinner_item, eqPresets);
eqPresetsAdapter.setDropDownViewResource(R.layout.spin_item);
Spinner eqSpinner = findViewById(R.id.mPresetsSpinner);
for (short i = 0; i < mEqualizer.getNumberOfPresets(); i++){
eqPresets.add(mEqualizer.getPresetName(i));
}
eqSpinner.setAdapter(eqPresetsAdapter);
现在我要实现的是创建一个自定义预设,以便保存每个均衡器频段的频段级别。
customPreset = new CustomPreset();
customPreset.setPresetName(input.getText().toString());
customPreset.setmEqualizerBandLevel0(mEqualizerBandLevel0);
customPreset.setmEqualizerBandLevel1(mEqualizerBandLevel1);
customPreset.setmEqualizerBandLevel2(mEqualizerBandLevel2);
customPreset.setmEqualizerBandLevel3(mEqualizerBandLevel3);
customPreset.setmEqualizerBandLevel4(mEqualizerBandLevel4);
customPresets.add(customPreset);
我尝试通过保存所有搜索栏的进度值,然后使用
设置新的频段级别来进行尝试mEqualizer.setBandLevel((short) 0, (short) (customPresets.get(position).getmEqualizerBandLevel0() + lowerEqualizerBandLevel ));
选择了自定义预设后,但我不知道如何在 Preset Spinner 中显示这些自定义预设,因为微调器的数组列表具有类型字符串,我也无法为字符串添加数组列表对象。