Audio Effects: added methods to effects java classes to store and load current effect settings in

a single call.

Addional changes:
- Fixed simulator build
- Use effect interface UUIDs from OpenSL ES includes when available
- Added cleanspec rules to remove now obsolete test effect libraries
- Fixed bug in AudioEffect JNI setParameter function.

Change-Id: Ic25ddb135e2cec5a68c181d727321f5ac7a1ab6b
This commit is contained in:
Eric Laurent
2010-07-23 00:19:11 -07:00
parent 2b989e1f7d
commit ca57d1cc89
18 changed files with 661 additions and 115 deletions

View File

@@ -19,13 +19,15 @@ package android.media;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.media.AudioEffect;
import android.os.Bundle;
import android.util.Log;
import java.nio.ByteOrder;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.util.StringTokenizer;
import android.media.AudioEffect;
/**
* An audio virtualizer is a general name for an effect to spatialize audio channels. The exact
@@ -211,4 +213,82 @@ public class Virtualizer extends AudioEffect {
}
}
}
/**
* The Settings class regroups all virtualizer parameters. It is used in
* conjuntion with getProperties() and setProperties() methods to backup and restore
* all parameters in a single call.
*/
public static class Settings {
public short strength;
public Settings() {
}
/**
* Settings class constructor from a key=value; pairs formatted string. The string is
* typically returned by Settings.toString() method.
* @throws IllegalArgumentException if the string is not correctly formatted.
*/
public Settings(String settings) {
StringTokenizer st = new StringTokenizer(settings, "=;");
int tokens = st.countTokens();
if (st.countTokens() != 3) {
throw new IllegalArgumentException("settings: " + settings);
}
String key = st.nextToken();
if (!key.equals("Virtualizer")) {
throw new IllegalArgumentException(
"invalid settings for Virtualizer: " + key);
}
try {
key = st.nextToken();
if (!key.equals("strength")) {
throw new IllegalArgumentException("invalid key name: " + key);
}
strength = Short.parseShort(st.nextToken());
} catch (NumberFormatException nfe) {
throw new IllegalArgumentException("invalid value for key: " + key);
}
}
@Override
public String toString() {
String str = new String (
"Virtualizer"+
";strength="+Short.toString(strength)
);
return str;
}
};
/**
* Gets the virtualizer properties. This method is useful when a snapshot of current
* virtualizer settings must be saved by the application.
* @return a Virtualizer.Settings object containing all current parameters values
* @throws IllegalStateException
* @throws IllegalArgumentException
* @throws UnsupportedOperationException
*/
public Virtualizer.Settings getProperties()
throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException {
Settings settings = new Settings();
short[] value = new short[1];
checkStatus(getParameter(PARAM_STRENGTH, value));
settings.strength = value[0];
return settings;
}
/**
* Sets the virtualizer properties. This method is useful when virtualizer settings have to
* be applied from a previous backup.
* @throws IllegalStateException
* @throws IllegalArgumentException
* @throws UnsupportedOperationException
*/
public void setProperties(Virtualizer.Settings settings)
throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException {
checkStatus(setParameter(PARAM_STRENGTH, settings.strength));
}
}