use of android.media.audiofx.AudioEffect in project android_frameworks_base by DirtyUnicorns.
the class MediaAudioEffectTest method test1_7AuxiliaryOnAudioTrack.
//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);
}
use of android.media.audiofx.AudioEffect in project android_frameworks_base by DirtyUnicorns.
the class MediaAudioEffectTest method test3_4SetParameterIntArrayIntArray.
//Test case 3.4: test setParameter(int[], int[])
@LargeTest
public void test3_4SetParameterIntArrayIntArray() throws Exception {
boolean result = false;
String msg = "test3_4SetParameterIntArrayIntArray()";
AudioEffect effect = null;
try {
effect = new AudioEffect(AudioEffect.EFFECT_TYPE_ENV_REVERB, AudioEffect.EFFECT_TYPE_NULL, 0, 0);
assertNotNull(msg + ": could not create AudioEffect", effect);
int[] param = new int[1];
int[] value = new int[1];
param[0] = EnvironmentalReverb.PARAM_DECAY_TIME;
value[0] = 0;
if (effect.setParameter(param, value) == AudioEffect.SUCCESS) {
result = true;
}
} catch (IllegalArgumentException e) {
msg = msg.concat(": Bad parameter value");
loge(msg, "Bad parameter value");
} catch (UnsupportedOperationException e) {
msg = msg.concat(": setParameter() rejected");
loge(msg, "setParameter() rejected");
} catch (IllegalStateException e) {
msg = msg.concat("setParameter() called in wrong state");
loge(msg, "setParameter() called in wrong state");
} finally {
if (effect != null) {
effect.release();
}
}
assertTrue(msg, result);
}
use of android.media.audiofx.AudioEffect in project android_frameworks_base by DirtyUnicorns.
the class MediaAudioEffectTest method test4_0GetParameterByteArrayByteArray.
//-----------------------------------------------------------------
// 4 - get parameters
//----------------------------------
//Test case 4.0: test getParameter(byte[], byte[])
@LargeTest
public void test4_0GetParameterByteArrayByteArray() throws Exception {
boolean result = false;
String msg = "test4_0GetParameterByteArrayByteArray()";
AudioEffect effect = null;
try {
effect = new AudioEffect(AudioEffect.EFFECT_TYPE_EQUALIZER, AudioEffect.EFFECT_TYPE_NULL, 0, 0);
assertNotNull(msg + ": could not create AudioEffect", effect);
byte[] param = intToByteArray(Equalizer.PARAM_CURRENT_PRESET);
byte[] value = new byte[2];
if (!AudioEffect.isError(effect.getParameter(param, value))) {
result = true;
}
} catch (IllegalArgumentException e) {
msg = msg.concat(": Bad parameter value");
loge(msg, "Bad parameter value");
} catch (UnsupportedOperationException e) {
msg = msg.concat(": getParameter() rejected");
loge(msg, "getParameter() rejected");
} catch (IllegalStateException e) {
msg = msg.concat("getParameter() called in wrong state");
loge(msg, "getParameter() called in wrong state");
} finally {
if (effect != null) {
effect.release();
}
}
assertTrue(msg, result);
}
use of android.media.audiofx.AudioEffect in project android_frameworks_base by DirtyUnicorns.
the class MediaAudioEffectTest method test1_5AuxiliaryOnMediaPlayer.
//Test case 1.5: test auxiliary effect attachement on MediaPlayer
@LargeTest
public void test1_5AuxiliaryOnMediaPlayer() throws Exception {
boolean result = false;
String msg = "test1_5AuxiliaryOnMediaPlayer()";
try {
MediaPlayer mp = new MediaPlayer();
mp.setDataSource(MediaNames.SHORTMP3);
AudioEffect effect = new AudioEffect(AudioEffect.EFFECT_TYPE_ENV_REVERB, AudioEffect.EFFECT_TYPE_NULL, 0, 0);
assertNotNull(msg + ": could not create AudioEffect", effect);
mp.attachAuxEffect(effect.getId());
mp.setAuxEffectSendLevel(1.0f);
result = true;
effect.release();
mp.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");
} catch (Exception e) {
loge(msg, "Could not create media player:" + e);
}
assertTrue(msg, result);
}
use of android.media.audiofx.AudioEffect in project android_frameworks_base by DirtyUnicorns.
the class MediaAudioEffectTest method test4_1GetParameterIntIntArray.
//Test case 4.1: test getParameter(int, int[])
@LargeTest
public void test4_1GetParameterIntIntArray() throws Exception {
boolean result = false;
String msg = "test4_1GetParameterIntIntArray()";
AudioEffect effect = null;
try {
effect = new AudioEffect(AudioEffect.EFFECT_TYPE_ENV_REVERB, AudioEffect.EFFECT_TYPE_NULL, 0, 0);
assertNotNull(msg + ": could not create AudioEffect", effect);
int[] value = new int[1];
if (!AudioEffect.isError(effect.getParameter(EnvironmentalReverb.PARAM_DECAY_TIME, value))) {
result = true;
}
} catch (IllegalArgumentException e) {
msg = msg.concat(": Bad parameter value");
loge(msg, "Bad parameter value");
} catch (UnsupportedOperationException e) {
msg = msg.concat(": getParameter() rejected");
loge(msg, "getParameter() rejected");
} catch (IllegalStateException e) {
msg = msg.concat("getParameter() called in wrong state");
loge(msg, "getParameter() called in wrong state");
} finally {
if (effect != null) {
effect.release();
}
}
assertTrue(msg, result);
}
Aggregations