Android Audio代码分析23 - attachAuxEffect函数
今天来看看如何将AudioEffect与AudioTrack关联起来。
*****************************************源码*************************************************
//Test case 1.7: test auxiliary effect attachement on AudioTrack
@LargeTest
public void test1_7AuxiliaryOnAudioTrack() throws Exception {
boolean result = false;
String msg = "test1_7AuxiliaryOnAudioTrack()";
try {
AudioTrack track = new AudioTrack(
AudioManager.STREAM_MUSIC,
44100,
AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT,
AudioTrack.getMinBufferSize(44100,
AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT),
AudioTrack.MODE_STREAM);
assertNotNull(msg + ": could not create AudioTrack", track);
AudioEffect effect = new AudioEffect(AudioEffect.EFFECT_TYPE_ENV_REVERB,
AudioEffect.EFFECT_TYPE_NULL,
0,
0);
track.attachAuxEffect(effect.getId());
track.setAuxEffectSendLevel(1.0f);
result = true;
effect.release();
track.release();
} catch (IllegalArgumentException e) {
msg = msg.concat(": Equalizer not found");
loge(msg, ": Equalizer not found");
} catch (UnsupportedOperationException e) {
msg = msg.concat(": Effect library not loaded");
loge(msg, ": Effect library not loaded");
}
assertTrue(msg, result);
}
**********************************************************************************************
源码路径:
frameworks\base\media\tests\mediaframeworktest\src\com\android\mediaframeworktest\functional\MediaAudioEffectTest.java
#######################说明################################
//Test case 1.7: test auxiliary effect attachement on AudioTrack
@LargeTest
public void test1_7AuxiliaryOnAudioTrack() throws Exception {
boolean result = false;
String msg = "test1_7AuxiliaryOnAudioTrack()";
try {
AudioTrack track = new AudioTrack(
AudioManager.STREAM_MUSIC,
44100,
AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT,
AudioTrack.getMinBufferSize(44100,
&nbs
补充:移动开发 , Android ,