本文整理汇总了Java中android.media.audiofx.Equalizer类的典型用法代码示例。如果您正苦于以下问题:Java Equalizer类的具体用法?Java Equalizer怎么用?Java Equalizer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Equalizer类属于android.media.audiofx包,在下文中一共展示了Equalizer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: EqualizerController
import android.media.audiofx.Equalizer; //导入依赖的package包/类
public EqualizerController(Context context, MediaPlayer mediaPlayer)
{
this.context = context;
try
{
if (mediaPlayer == null)
{
return;
}
audioSessionId = mediaPlayer.getAudioSessionId();
equalizer = new Equalizer(0, audioSessionId);
}
catch (Throwable x)
{
equalizer = null;
Log.w(TAG, "Failed to create equalizer.", x);
}
}
示例2: getEqualizer
import android.media.audiofx.Equalizer; //导入依赖的package包/类
public Equalizer getEqualizer()
{
if (released)
{
released = false;
try
{
equalizer = new Equalizer(0, audioSessionId);
}
catch (Throwable x)
{
equalizer = null;
Log.w(TAG, "Failed to create equalizer.", x);
}
}
return equalizer;
}
示例3: EqualizerSettings
import android.media.audiofx.Equalizer; //导入依赖的package包/类
public EqualizerSettings(Equalizer equalizer)
{
enabled = equalizer.getEnabled();
bandLevels = new short[equalizer.getNumberOfBands()];
for (short i = 0; i < equalizer.getNumberOfBands(); i++)
{
bandLevels[i] = equalizer.getBandLevel(i);
}
try
{
preset = equalizer.getCurrentPreset();
}
catch (Exception x)
{
preset = -1;
}
}
示例4: isEqualizerSupported
import android.media.audiofx.Equalizer; //导入依赖的package包/类
public static boolean isEqualizerSupported() {
int noOfBands = 0;
int noOfPresents = 0;
try {
Equalizer equalizer = new Equalizer(0, 0);
noOfBands = equalizer.getNumberOfBands();
noOfPresents = equalizer.getNumberOfPresets();
equalizer.release();
equalizer = null;
} catch (Exception e) {
}
return noOfBands > 0 && noOfPresents > 0 && !isHTC();
}
示例5: initEq
import android.media.audiofx.Equalizer; //导入依赖的package包/类
public static void initEq(int audioID) {
EndEq();
try {
equalizer = new Equalizer(0, audioID);
preset = (short) Extras.getInstance().saveEq().getInt(SAVE_PRESET, 0);
if (preset < equalizer.getNumberOfPresets()){
usePreset(preset);
}else {
for (short b = 0; b < equalizer.getNumberOfBands(); b++) {
short level = (short) Extras.getInstance().saveEq().getInt(BAND_LEVEL + b, 0);
setBandLevel(b, level);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例6: restoreEqualizer
import android.media.audiofx.Equalizer; //导入依赖的package包/类
private void restoreEqualizer() {
mEqualizer = new Equalizer(Integer.MAX_VALUE, mSessionId);
synchronized (SETTINGS_LOCK) {
final EffectsProto.EqualizerSettings proto = mEqualizerSettings;
if (proto.curPreset != 0
|| proto.numBands != 0
|| proto.bandValues.length != 0) {
final Equalizer.Settings settings = new Equalizer.Settings();
settings.curPreset = (short) proto.curPreset;
settings.numBands = (short) proto.numBands;
settings.bandLevels = new short[proto.bandValues.length];
for (int i = 0; i < settings.bandLevels.length; i++) {
settings.bandLevels[i] = (short) proto.bandValues[i];
}
try {
mEqualizer.setProperties(settings);
} catch (IllegalArgumentException e) {
Log.wtf(TAG, "Failed restoring equalizer settings", e);
}
}
}
mEqualizer.setEnabled(true);
}
示例7: saveEqualizerSettings
import android.media.audiofx.Equalizer; //导入依赖的package包/类
void saveEqualizerSettings(@NonNull final Equalizer.Settings settings) {
synchronized (SETTINGS_LOCK) {
final EffectsProto.EqualizerSettings proto = mEqualizerSettings;
proto.curPreset = settings.curPreset;
proto.numBands = settings.numBands;
final short[] bandLevels = settings.bandLevels;
proto.bandValues = new int[bandLevels != null ? bandLevels.length : 0];
if (bandLevels != null) {
for (int i = 0; i < bandLevels.length; i++) {
proto.bandValues[i] = bandLevels[i];
}
}
}
persistEqualizerSettingsAsync();
}
示例8: release
import android.media.audiofx.Equalizer; //导入依赖的package包/类
private void release(AudioEffect effect) {
if (null != effect) {
effect.setControlStatusListener(null);
effect.setEnableStatusListener(null);
if (effect instanceof Equalizer) {
((Equalizer) effect).setParameterListener(null);
} else if (effect instanceof BassBoost) {
((BassBoost) effect).setParameterListener(null);
} else if (effect instanceof Virtualizer) {
((Virtualizer) effect).setParameterListener(null);
}
effect.release();
}
}
示例9: ImmutablePreferenceStore
import android.media.audiofx.Equalizer; //导入依赖的package包/类
public ImmutablePreferenceStore(ReadOnlyPreferenceStore preferencesStore) {
mShowFirstStart = preferencesStore.showFirstStart();
mAllowLogging = preferencesStore.allowLogging();
mUseMobileNetwork = preferencesStore.useMobileNetwork();
mOpenNowPlayingOnNewQueue = preferencesStore.openNowPlayingOnNewQueue();
mEnableNowPlayingGestures = preferencesStore.enableNowPlayingGestures();
mDefaultPage = preferencesStore.getDefaultPage();
mPrimaryColor = preferencesStore.getPrimaryColor();
mAccentColor = preferencesStore.getAccentColor();
mBaseColor = preferencesStore.getBaseColor();
mIconColor = preferencesStore.getIconColor();
mResumeOnHeadphonesConnect = preferencesStore.resumeOnHeadphonesConnect();
mShuffled = preferencesStore.isShuffled();
mPreviousSleepTimerDurationMillis = preferencesStore.getLastSleepTimerDuration();
mRepeatMode = preferencesStore.getRepeatMode();
mEqualizerPresetId = preferencesStore.getEqualizerPresetId();
mEqualizerEnabled = preferencesStore.getEqualizerEnabled();
Equalizer.Settings eqSettings = preferencesStore.getEqualizerSettings();
if (eqSettings != null) {
mEqualizerSettings = eqSettings.toString();
} else {
mEqualizerSettings = null;
}
}
示例10: EqualizerController
import android.media.audiofx.Equalizer; //导入依赖的package包/类
public EqualizerController(Context context, MediaPlayer mediaPlayer) {
this.context = context;
try {
audioSessionId = mediaPlayer.getAudioSessionId();
equalizer = new Equalizer(0, audioSessionId);
} catch (Throwable x) {
LOG.warn("Failed to create equalizer.", x);
}
}
示例11: getEqualizer
import android.media.audiofx.Equalizer; //导入依赖的package包/类
public Equalizer getEqualizer() {
if(released) {
released = false;
try {
equalizer = new Equalizer(0, audioSessionId);
} catch (Throwable x) {
equalizer = null;
LOG.warn("Failed to create equalizer.", x);
}
}
return equalizer;
}
示例12: EqualizerSettings
import android.media.audiofx.Equalizer; //导入依赖的package包/类
public EqualizerSettings(Equalizer equalizer) {
enabled = equalizer.getEnabled();
bandLevels = new short[equalizer.getNumberOfBands()];
for (short i = 0; i < equalizer.getNumberOfBands(); i++) {
bandLevels[i] = equalizer.getBandLevel(i);
}
try {
preset = equalizer.getCurrentPreset();
} catch (Exception x) {
preset = -1;
}
}
示例13: apply
import android.media.audiofx.Equalizer; //导入依赖的package包/类
public void apply(Equalizer equalizer)
{
for (short i = 0; i < bandLevels.length; i++)
{
equalizer.setBandLevel(i, bandLevels[i]);
}
if (preset >= 0 && preset < equalizer.getNumberOfPresets())
{
equalizer.usePreset(preset);
}
equalizer.setEnabled(enabled);
}
示例14: EqualizerHelper
import android.media.audiofx.Equalizer; //导入依赖的package包/类
public EqualizerHelper(int audioSessionId1, boolean equalizerEnabled) throws RuntimeException {
mEqualizer = new Equalizer(0, audioSessionId1);
mEqualizer.setEnabled(equalizerEnabled);
mVirtualizer = new Virtualizer(0, audioSessionId1);
mVirtualizer.setEnabled(equalizerEnabled);
mBassBoost = new BassBoost(0, audioSessionId1);
mBassBoost.setEnabled(equalizerEnabled);
mPresetReverb = new PresetReverb(0, audioSessionId1);
mPresetReverb.setEnabled(equalizerEnabled);
}
示例15: init
import android.media.audiofx.Equalizer; //导入依赖的package包/类
private void init() {
equalizer = new Equalizer(0, audioSessionId);
bass = new BassBoost(0, audioSessionId);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
loudnessAvailable = true;
loudnessEnhancerController = new LoudnessEnhancerController(context, audioSessionId);
}
}