-
Notifications
You must be signed in to change notification settings - Fork 96
OpenSL prefixed API classes
The OpenSL* prefixed classes are wrapper of C++ Native API sets.
The OpenSLMediaPlayerFactory class is a factory class of all OpenSL* media player and audio effect classes.
The OpenSLMediaPlayerContext class is a shared object among all OpenSL* objects.
| Field name | Usage | Default |
|---|---|---|
| options | Specify logical OR of OPTION_* constants |
0 |
| streamType | Specify one of the AudioManager.STREAM_* constants |
AudioManager.STREAM_MUSIC |
| shortFadeDuration | Specify duration of short fading in milli seconds | 25 |
| longFadeDuration | Specify duration of long fading in milli seconds | 1500 |
| resamplerQuality | Specify one of the RESAMPLER_QUALITY_* constants |
RESAMPLER_QUALITY_MIDDLE |
| hqEqualizerImplType | Specify one of the HQ_EAUALIZER_IMPL_* constants |
HQ_EAUALIZER_IMPL_BASIC_PEAKING_FILTER |
| Name | Meaning |
|---|---|
OPTION_USE_BASSBOOST |
Whether to use OpenSLBassBoost |
OPTION_USE_VIRTUALIZER |
Whether to use OpenSLVirtualizer |
OPTION_USE_EQUALIZER |
Whether to use OpenSEqualizer |
OPTION_USE_ENVIRONMENAL_REVERB |
Whether to use OpenSLEnvironmentalReverb |
OPTION_USE_PRESET_REVERB |
Whether to use OpenSLPresetReverb |
OPTION_USE_VISUALIZER |
Whether to use OpenSLVisualizer |
OPTION_USE_HQ_EQUALIZER |
Whether to use OpenSLEqualizer |
OPTION_USE_PREAMP |
Whether to use OpenSLPreAmp |
OPTION_USE_HQ_VISUALIZER |
Whether to use OpenSLHQVisualizer |
| Name | Meaning |
|---|---|
RESAMPLER_QUALITY_LOW |
Low quality (better than "cubic") |
RESAMPLER_QUALITY_MIDDLE |
Middle quality (almost same as "sinc with revised coefficients") |
RESAMPLER_QUALITY_HIGH |
High quality (better than "sinc with revised coefficients") |
| Name | Meaning |
|---|---|
HQ_EAUALIZER_IMPL_BASIC_PEAKING_FILTER |
Basic implementation using cascaded peaking filters |
HQ_EAUALIZER_IMPL_FLAT_GAIN_RESPOINSE |
Better gain response implementation using cascaded shelf filters |
Corresponding Android's class is android.media.MediaPlayer.
Specify logical OR of these values for the second argument.
| Flag name | Effects |
|---|---|
OPTION_USE_FADE |
Enable fade in/out |
This method is not supported. Please use OpenSLMediaPlayerContext.Parameters.streamType instead.
This method is not supported and always returns 0.
This method is not supported and throws IllegalStateException.
Send level is shared among all OpenSLMediaPlayer instances created from the same factory instance.
- Instantiation of this class is limited to 4 instances per each factory object
The OpenSLBassBoost class uses SLBassBoostItf internally.
The OPTION_USE_BASSBOOST flag is required when creating OpenSLMediaPlayerContext object to instantiate this class.
Corresponding Android's class is android.media.audiofx.BassBoost.
- This class may not work on some devices which has CyanogenMod's DSP Manager
- OnParameterChangeListener is not supported
- OnControlStatusChangeListener is not supported
- OnEnableStatusChangeListener is not supported
The OpenSLVirtualizer class uses SLVirtualizerItf internally.
The OPTION_USE_VIRTUALIZER flag is required when creating OpenSLMediaPlayerContext object to instantiate this class.
Corresponding Android's class is android.media.audiofx.Virtualizer.
- This class may not work on some devices which has CyanogenMod's DSP Manager
- OnParameterChangeListener is not supported
- OnControlStatusChangeListener is not supported
- OnEnableStatusChangeListener is not supported
The OpenSLEqualizer class is a 5 bands graphic equalizer and it uses SLEqualizerItf internally.
The OPTION_USE_EQUALIZER flag is required when creating OpenSLMediaPlayerContext object to instantiate this class.
Corresponding Android's class is android.media.audiofx.Equalizer.
- This class may not work on some devices which has CyanogenMod's DSP Manager
- OnParameterChangeListener is not supported
- OnControlStatusChangeListener is not supported
- OnEnableStatusChangeListener is not supported
The OpenSLVisualizer class enables to capture mixed out audio signal. This class does NOT use SLVisualizationtItf internally.
The OPTION_USE_VISUALIZER flag is required when creating OpenSLMediaPlayerContext object to instantiate this class.
Corresponding Android's class is android.media.audiofx.Visualizer.
The OpenSLEnvironmentalReverb class is a configurable reverb and it uses SLEnvironmentalReverbItf internally.
The OPTION_USE_ENVIRONMENAL_REVERB flag is required when creating OpenSLMediaPlayerContext object to instantiate this class.
Corresponding Android's class is android.media.audiofx.EnvironmentalReverb.
- OnParameterChangeListener is not supported
- OnControlStatusChangeListener is not supported
- OnEnableStatusChangeListener is not supported
The OpenSLEnvironmentalReverb class is a reverb which has simple interface and it uses SLPresetReverbItf internally.
The OPTION_USE_PRESET_REVERB flag is required when creating OpenSLMediaPlayerContext object to instantiate this class.
Corresponding Android's class is android.media.audiofx.PresetReverb.
- OnParameterChangeListener is not supported
- OnControlStatusChangeListener is not supported
- OnEnableStatusChangeListener is not supported
The OpenSLHQEqualizer class is 10 bands graphic equalizer class. This class implements IEqualizer as same as the OpenSLEqualizer class.
The OPTION_USE_HQ_EQUALIZER flag is required when creating OpenSLMediaPlayerContext object to instantiate this class.
- OnParameterChangeListener is not supported
- OnControlStatusChangeListener is not supported
- OnEnableStatusChangeListener is not supported
The OpenSLPreAmp class is preamplifier of mixed out audio. This class can be used to avoid clipping when using OpenSLHQEqualizer.
The OPTION_USE_PREAMP flag is required when creating OpenSLMediaPlayerContext object to instantiate this class.
The OpenSLHQVisualizer class is advanced class. This class implements IHQVisualizer, so it's different from OpenSLVisualizer class.
The OPTION_USE_HQ_VISUALIZER flag is required when creating OpenSLMediaPlayerContext object to instantiate this class.
| OpenSLHQVisualizer | OpenSLVisualizer / StandardVisualizer | |
|---|---|---|
| Super interface | IHQVisualizer | IVisualizer |
| Wave form capture format | float, stereo | byte (unsigned 8 bit), monaural |
| FFT capture format | float, stereo | byte (signed 8 bit), monaural |
| Min. capture data size | 128 frames | 128 frames |
| Max. capture data size | 32768 frames | 1024 frames |
| Min. capture data rate | 0.1 Hz | 0.1 Hz |
| Max. capture data rate | 60 Hz | 20 Hz |
| getWaveform() method | not supported | supported |
| getFft() method | not supported | supported |
| getMeasurementPeakRms() method | not supported | supported (getMeasurementPeakRmsCompat()) |
| setScalingMode() method | not supported | supported (setScalingModeCompat()) |
| Callback context | from native capturing thread | from Handler's thread (main thread) |
| System volume setting | not affected | affected |