本文介绍了如何在音频均衡器添加音响,高音选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我想要一个小的音频歌曲的均衡器。我想在高音它选择添加,立体声像它在后级的球员。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.我实现equlizer有5条成功是这样的: -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(); } });}}以上code是我的均衡code.it只有很短的简短不会工作只是作为一个例子,我在这里公布。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); }我用了一个inbulilt类低音增强。I used an inbulilt class for bass boost.我如何添加高音和立体声/单声道效果,我的应用程序?How can I add treble and stereo/mono effects to my app?推荐答案 为了改变低音,中,高音也没有必要使用 AudioTrack 对象(甚至是因为这个对象,你只能播放非COM pressed PCM数据)。In order to change the bass, mid, treble there's no need to use the AudioTrack object (even because with this object you could only playback non-compressed PCM data).您只需要一级使用 均衡器 对象。要获取可用频段的号码,只需拨打:You just need to adjust the proper frequency bands level using your Equalizer object. To get the number of available bands, just call:myEqualizer.getNumberOfBands()考虑可用频带的数量,你现在可以使用下面的方法设置级别每个波段:Considering the number of available bands, you can now set the level for each band using the following method:myEqualizer.setBandLevel(band, level);其中: 带:频段,将有新的收获。的编号  频带从0开始和结束于(多个波段 - 1)。 band: frequency band that will have the new gain. The numbering of the bands starts from 0 and ends at (number of bands - 1). 水平:新的增益  在millibels该将被设定为给定的频带。 getBandLevelRange()  将限定的最大和最小值。level: new gain in millibels that will be set to the given band. getBandLevelRange() will define the maximum and minimum values.每个波段的意义,由左到右,总结如下图:The meaning of each bands, from left to right, is summarized in the following image: 更新要实现一个简单的平衡的效果,只是区分播放器上的左/右音量(的MediaPlayer ,的Soundpool ,...):To implement a trivial balance effect, just differentiate the left/right volume on your player (MediaPlayer, SoundPool,...):mediaPlayer.setVolume(left, right)要获得单的效果,你可以考虑使用的虚拟器时,它提供了一个立体声扩展效果。您可以使用该方法设置的虚拟化效果的强度:To obtain a mono effect you can consider using a Virtualizer, which provides a stereo widening effect. You can set the strength of the virtualization effect using the method:virtualizer.setStrength(1000); //range is [0..1000]您需要读文档特别小心,以检查你的虚拟器的当前配置是真正支持的基础系统。You need to read the documentation carefully in order to check if the current configuration of your virtualizer is really supported by the underlying system.无论如何,这是不是一个真正的单声道输出,我想你将无法获得立体声扬声器单声道输出中不使用低级别的API,如 AudioTrack (实际上后级依赖于本地JNI库的音频管道的)。如果你想使用 AudioTrack 播放,您需要考虑它仅支持PCM数据(WAV)作为输入:这意味着你将无法发挥COM pressed的音频文件(如MP3,FLAC,...)直接因为你需要到c COM pressed音频第一档手动去$ C $。Anyway, this is not a real mono output and I think you won't be able to obtain a mono ouput on stereo speaker without using low level API such as AudioTrack (actually Poweramp relies on native JNI libraries for its audio pipeline).If you want to use an AudioTrack for playback you need to consider that it only supports PCM data (WAV) as input: this means you won't be able to play compressed audio file (like MP3, flac, ...) directly since you need to manually decode the compressed audio file first.[Compressed File (MP3)] ===> decode() ===> [PCM data] ===> customEffect() ===> AudioTrack playback()因此​​,为了为使用和发挥一个COM pressed音频AudioTrack (并最终创建一个自定义的效果),需要执行以下步骤:Thus, in order to play a compressed audio using and AudioTrack (and eventually create a custom effect) the following steps are required:使用德$ C $ 在德code中的COM pressed文件CR (没有公共系统的API提供这一点,你需要做手工!)。如果有必要,改造uncom $ P $在 PCM格式pssed数据这与AudioTrack 兼容(最终)适用于PCM数据流的转换(例如,你可以合并这两个左/右声道,并创建一个单声道的效果) 发挥使用AudioTrackdecode the compressed file using a decoder (NO PUBLIC SYSTEM API available for this, you need to do it manually!!!).if necessary, transform uncompressed data in a PCM format which is compatible with AudioTrack(eventually) apply your transformation on the PCM data stream (e.g. you can merge both L/R channels and create a mono effect)play the PCM stream using an AudioTrack我建议你跳过这个效果;)I suggest you to skip this effect ;)关于低音增强的效果,你需要检查是否支持由正在运行的设备(如虚拟器)当前的配置。看看这里以获取更多信息。Regarding the bass-boost effect, you need to check if your current configuration is supported by the the running device (like the virtualizer). Take a look here for more info on this. 这篇关于如何在音频均衡器添加音响,高音选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-23 00:51