android.media.audiofx.AudioEffect Java Examples

The following examples show how to use android.media.audiofx.AudioEffect. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MusicService.java    From Muzesto with GNU General Public License v3.0 6 votes vote down vote up
public void pause() {
    if (D) Log.d(TAG, "Pausing playback");
    synchronized (this) {
        mPlayerHandler.removeMessages(FADEUP);
        if (mIsSupposedToBePlaying) {
            final Intent intent = new Intent(
                    AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
            intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
            intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
            sendBroadcast(intent);

            mPlayer.pause();
            notifyChange(META_CHANGED);
            setIsSupposedToBePlaying(false, true);
        }
    }
}
 
Example #2
Source File: AudioRecordJNI.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private static boolean isGoodAudioEffect(AudioEffect effect){
	Pattern globalImpl=makeNonEmptyRegex("adsp_good_impls"), globalName=makeNonEmptyRegex("adsp_good_names");
	AudioEffect.Descriptor desc=effect.getDescriptor();
	VLog.d(effect.getClass().getSimpleName()+": implementor="+desc.implementor+", name="+desc.name);
	if(globalImpl!=null && globalImpl.matcher(desc.implementor).find()){
		return true;
	}
	if(globalName!=null && globalName.matcher(desc.name).find()){
		return true;
	}
	if(effect instanceof AcousticEchoCanceler){
		Pattern impl=makeNonEmptyRegex("aaec_good_impls"), name=makeNonEmptyRegex("aaec_good_names");
		if(impl!=null && impl.matcher(desc.implementor).find())
			return true;
		if(name!=null && name.matcher(desc.name).find())
			return true;
	}
	if(effect instanceof NoiseSuppressor){
		Pattern impl=makeNonEmptyRegex("ans_good_impls"), name=makeNonEmptyRegex("ans_good_names");
		if(impl!=null && impl.matcher(desc.implementor).find())
			return true;
		if(name!=null && name.matcher(desc.name).find())
			return true;
	}
	return false;
}
 
Example #3
Source File: AudioRecordJNI.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private static boolean isGoodAudioEffect(AudioEffect effect){
	Pattern globalImpl=makeNonEmptyRegex("adsp_good_impls"), globalName=makeNonEmptyRegex("adsp_good_names");
	AudioEffect.Descriptor desc=effect.getDescriptor();
	VLog.d(effect.getClass().getSimpleName()+": implementor="+desc.implementor+", name="+desc.name);
	if(globalImpl!=null && globalImpl.matcher(desc.implementor).find()){
		return true;
	}
	if(globalName!=null && globalName.matcher(desc.name).find()){
		return true;
	}
	if(effect instanceof AcousticEchoCanceler){
		Pattern impl=makeNonEmptyRegex("aaec_good_impls"), name=makeNonEmptyRegex("aaec_good_names");
		if(impl!=null && impl.matcher(desc.implementor).find())
			return true;
		if(name!=null && name.matcher(desc.name).find())
			return true;
	}
	if(effect instanceof NoiseSuppressor){
		Pattern impl=makeNonEmptyRegex("ans_good_impls"), name=makeNonEmptyRegex("ans_good_names");
		if(impl!=null && impl.matcher(desc.implementor).find())
			return true;
		if(name!=null && name.matcher(desc.name).find())
			return true;
	}
	return false;
}
 
Example #4
Source File: GaplessPlayer.java    From odyssey with GNU General Public License v3.0 5 votes vote down vote up
private void dumpAudioEffectsState() {
    AudioEffect.Descriptor[] effects = AudioEffect.queryEffects();
    Log.v(TAG, "Found audio effects: " + effects.length);
    for (AudioEffect.Descriptor effect : effects) {
        Log.v(TAG, "AudioEffect: " + effect.name + " connect mode: " + effect.connectMode + " implementor: " + effect.implementor);
    }
}
 
Example #5
Source File: MultiPlayer.java    From MusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param player The {@link MediaPlayer} to use
 * @param path   The path of the file, or the http/rtsp URL of the stream
 *               you want to play
 * @return True if the <code>player</code> has been prepared and is
 * ready to play, false otherwise
 */
private boolean setDataSourceImpl(@NonNull final MediaPlayer player, @NonNull final String path) {
    if (context == null) {
        return false;
    }
    try {
        player.reset();
        player.setOnPreparedListener(null);
        if (path.startsWith("content://")) {
            player.setDataSource(context, Uri.parse(path));
        } else {
            player.setDataSource(path);
        }
        player.setAudioStreamType(AudioManager.STREAM_MUSIC);
        player.prepare();
    } catch (Exception e) {
        return false;
    }
    player.setOnCompletionListener(this);
    player.setOnErrorListener(this);
    final Intent intent = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION);
    intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
    intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, context.getPackageName());
    intent.putExtra(AudioEffect.EXTRA_CONTENT_TYPE, AudioEffect.CONTENT_TYPE_MUSIC);
    context.sendBroadcast(intent);
    return true;
}
 
Example #6
Source File: StandardAudioEffect.java    From android-openslmediaplayer with Apache License 2.0 5 votes vote down vote up
@Override
public void onEnableStatusChange(AudioEffect effect, boolean enabled) {
    final IAudioEffect ieffect = mRefEffect.get();
    final IAudioEffect.OnEnableStatusChangeListener listener = mListener;

    if (ieffect != null && listener != null) {
        listener.onEnableStatusChange(ieffect, enabled);
    }
}
 
Example #7
Source File: MediaPlaybackService.java    From coursera-android with MIT License 5 votes vote down vote up
@Override
public void onDestroy() {
    // Check that we're not being destroyed while something is still playing.
    if (isPlaying()) {
        Log.e(LOGTAG, "Service being destroyed while still playing.");
    }
    // release all MediaPlayer resources, including the native player and wakelocks
    Intent i = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
    i.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
    i.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
    sendBroadcast(i);
    mPlayer.release();
    mPlayer = null;

    mAudioManager.abandonAudioFocus(mAudioFocusListener);
    //mAudioManager.unregisterRemoteControlClient(mRemoteControlClient);
    
    // make sure there aren't any other messages coming
    mDelayedStopHandler.removeCallbacksAndMessages(null);
    mMediaplayerHandler.removeCallbacksAndMessages(null);

    if (mCursor != null) {
        mCursor.close();
        mCursor = null;
    }

    unregisterReceiver(mIntentReceiver);
    if (mUnmountReceiver != null) {
        unregisterReceiver(mUnmountReceiver);
        mUnmountReceiver = null;
    }
    mWakeLock.release();
    super.onDestroy();
}
 
Example #8
Source File: MultiPlayer.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param player The {@link MediaPlayer} to use
 * @param path   The path of the file, or the http/rtsp URL of the stream
 *               you want to play
 * @return True if the <code>player</code> has been prepared and is
 * ready to play, false otherwise
 */
private boolean setDataSourceImpl(@NonNull final MediaPlayer player, @NonNull final String path) {
    if (context == null) {
        return false;
    }
    try {
        player.reset();
        player.setOnPreparedListener(null);
        if (path.startsWith("content://")) {
            player.setDataSource(context, Uri.parse(path));
        } else {
            player.setDataSource(path);
        }
        player.setAudioStreamType(AudioManager.STREAM_MUSIC);
        player.prepare();
    } catch (Exception e) {
        return false;
    }
    player.setOnCompletionListener(this);
    player.setOnErrorListener(this);
    final Intent intent = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION);
    intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
    intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, context.getPackageName());
    intent.putExtra(AudioEffect.EXTRA_CONTENT_TYPE, AudioEffect.CONTENT_TYPE_MUSIC);
    context.sendBroadcast(intent);
    return true;
}
 
Example #9
Source File: Util.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
public static boolean hasEqualizer() {
    for (AudioEffect.Descriptor effect : AudioEffect.queryEffects()) {
        if (EQUALIZER_UUID.equals(effect.type)) {
            return true;
        }
    }
    return false;
}
 
Example #10
Source File: MultiPlayer.java    From VinylMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param player The {@link MediaPlayer} to use
 * @param path   The path of the file, or the http/rtsp URL of the stream
 *               you want to play
 * @return True if the <code>player</code> has been prepared and is
 * ready to play, false otherwise
 */
private boolean setDataSourceImpl(@NonNull final MediaPlayer player, @NonNull final String path) {
    if (context == null) {
        return false;
    }
    try {
        player.reset();
        player.setOnPreparedListener(null);
        if (path.startsWith("content://")) {
            player.setDataSource(context, Uri.parse(path));
        } else {
            player.setDataSource(path);
        }
        player.setAudioStreamType(AudioManager.STREAM_MUSIC);
        player.prepare();
    } catch (Exception e) {
        return false;
    }
    player.setOnCompletionListener(this);
    player.setOnErrorListener(this);
    final Intent intent = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION);
    intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
    intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, context.getPackageName());
    intent.putExtra(AudioEffect.EXTRA_CONTENT_TYPE, AudioEffect.CONTENT_TYPE_MUSIC);
    context.sendBroadcast(intent);
    return true;
}
 
Example #11
Source File: SettingsActivity.java    From VinylMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
private boolean hasEqualizer() {
    final Intent effects = new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL);
    if (getActivity() != null) {
        PackageManager pm = getActivity().getPackageManager();
        ResolveInfo ri = pm.resolveActivity(effects, 0);
        return ri != null;
    }
    return false;
}
 
Example #12
Source File: NavigationUtil.java    From VinylMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
public static void openEqualizer(@NonNull final Activity activity) {
    final int sessionId = MusicPlayerRemote.getAudioSessionId();
    if (sessionId == AudioEffect.ERROR_BAD_VALUE) {
        Toast.makeText(activity, activity.getResources().getString(R.string.no_audio_ID), Toast.LENGTH_LONG).show();
    } else {
        try {
            final Intent effects = new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL);
            effects.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, sessionId);
            effects.putExtra(AudioEffect.EXTRA_CONTENT_TYPE, AudioEffect.CONTENT_TYPE_MUSIC);
            activity.startActivityForResult(effects, 0);
        } catch (@NonNull final ActivityNotFoundException notFound) {
            Toast.makeText(activity, activity.getResources().getString(R.string.no_equalizer), Toast.LENGTH_SHORT).show();
        }
    }
}
 
Example #13
Source File: MusicService.java    From Muzesto with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onDestroy() {
    if (D) Log.d(TAG, "Destroying service");
    super.onDestroy();
    // Remove any sound effects
    final Intent audioEffectsIntent = new Intent(
            AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
    audioEffectsIntent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
    audioEffectsIntent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
    sendBroadcast(audioEffectsIntent);


    mAlarmManager.cancel(mShutdownIntent);

    mPlayerHandler.removeCallbacksAndMessages(null);

    if (TimberUtils.isJellyBeanMR2())
        mHandlerThread.quitSafely();
    else mHandlerThread.quit();

    mPlayer.release();
    mPlayer = null;

    mAudioManager.abandonAudioFocus(mAudioFocusListener);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        mSession.release();

    getContentResolver().unregisterContentObserver(mMediaStoreObserver);

    closeCursor();

    unregisterReceiver(mIntentReceiver);
    if (mUnmountReceiver != null) {
        unregisterReceiver(mUnmountReceiver);
        mUnmountReceiver = null;
    }

    mWakeLock.release();
}
 
Example #14
Source File: DownloadService.java    From Audinaut with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();
    instance = null;

    if (currentPlaying != null) currentPlaying.setPlaying(false);
    lifecycleSupport.onDestroy();

    Intent i = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
    i.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, audioSessionId);
    i.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
    sendBroadcast(i);

    mediaPlayer.release();
    if (nextMediaPlayer != null) {
        nextMediaPlayer.release();
    }
    mediaPlayerLooper.quit();
    shufflePlayBuffer.shutdown();
    effectsController.release();

    if (bufferTask != null) {
        bufferTask.cancel();
        bufferTask = null;
    }
    if (nextPlayingTask != null) {
        nextPlayingTask.cancel();
        nextPlayingTask = null;
    }
    if (proxy != null) {
        proxy.stop();
        proxy = null;
    }
    Notifications.hidePlayingNotification(this, this, handler);
    Notifications.hideDownloadingNotification(this, this, handler);

    unregisterReceiver(audioNoisyReceiver);
}
 
Example #15
Source File: MusicLibrary.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
/**
 * Respond to clicks on actionbar options
 */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
     case R.id.action_search:
         onSearchRequested();
         break;

     case R.id.action_settings:
     	startActivityForResult(new Intent(this, SettingsHolder.class),0);
         break;

     case R.id.action_eqalizer:
 	    final Intent intent = new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL);
         if (getPackageManager().resolveActivity(intent, 0) == null) {
      	startActivity(new Intent(this, SimpleEq.class));
     	}
     	else{
     		intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, MusicUtils.getCurrentAudioId());
     		startActivity(intent);
     	}
         break;

     case R.id.action_shuffle_all:
     	shuffleAll();
         break;

        default:
            return super.onOptionsItemSelected(item);
    }
    return true;
}
 
Example #16
Source File: GaplessPlayer.java    From odyssey with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Stops media playback
 */
synchronized void stop() {
    stopReleaseTask();
    // Check if a player exists otherwise there is nothing to do.
    if (mCurrentMediaPlayer != null) {
        // Check if the player for the next song exists already
        if (mNextMediaPlayer != null) {
            // Remove the next player from the currently playing one.
            mCurrentMediaPlayer.setNextMediaPlayer(null);
            // Release the MediaPlayer, not usable after this command
            mNextMediaPlayer.release();

            // Reset variables to clean internal state
            mNextMediaPlayer = null;
            mSecondPrepared = false;
            mSecondPreparing = false;
        }

        // Check if the currently active player is ready
        if (mCurrentPrepared) {
            /*
             * Signal android desire to close audio effect session
             */
            Intent audioEffectIntent = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
            audioEffectIntent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, mCurrentMediaPlayer.getAudioSessionId());
            audioEffectIntent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, mPlaybackService.getPackageName());
            mPlaybackService.sendBroadcast(audioEffectIntent);

            if (BuildConfig.DEBUG) {
                Log.v(TAG, "Closing effect for session: " + mCurrentMediaPlayer.getAudioSessionId());
            }
        }
        // Release the current player
        mCurrentMediaPlayer.release();

        // Reset variables to clean internal state
        mCurrentMediaPlayer = null;
        mCurrentPrepared = false;
    }
}
 
Example #17
Source File: StandardAudioEffect.java    From android-openslmediaplayer with Apache License 2.0 5 votes vote down vote up
@Override
public void onControlStatusChange(AudioEffect effect, boolean controlGranted) {
    final IAudioEffect ieffect = mRefEffect.get();
    final IAudioEffect.OnControlStatusChangeListener listener = mListener;

    if (ieffect != null && listener != null) {
        listener.onControlStatusChange(ieffect, controlGranted);
    }
}
 
Example #18
Source File: MultiPlayer.java    From Phonograph with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param player The {@link MediaPlayer} to use
 * @param path   The path of the file, or the http/rtsp URL of the stream
 *               you want to play
 * @return True if the <code>player</code> has been prepared and is
 * ready to play, false otherwise
 */
private boolean setDataSourceImpl(@NonNull final MediaPlayer player, @NonNull final String path) {
    if (context == null) {
        return false;
    }
    try {
        player.reset();
        player.setOnPreparedListener(null);
        if (path.startsWith("content://")) {
            player.setDataSource(context, Uri.parse(path));
        } else {
            player.setDataSource(path);
        }
        player.setAudioStreamType(AudioManager.STREAM_MUSIC);
        player.prepare();
    } catch (Exception e) {
        return false;
    }
    player.setOnCompletionListener(this);
    player.setOnErrorListener(this);
    final Intent intent = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION);
    intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
    intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, context.getPackageName());
    intent.putExtra(AudioEffect.EXTRA_CONTENT_TYPE, AudioEffect.CONTENT_TYPE_MUSIC);
    context.sendBroadcast(intent);
    return true;
}
 
Example #19
Source File: NavigationUtil.java    From Phonograph with GNU General Public License v3.0 5 votes vote down vote up
public static void openEqualizer(@NonNull final Activity activity) {
    final int sessionId = MusicPlayerRemote.getAudioSessionId();
    if (sessionId == AudioEffect.ERROR_BAD_VALUE) {
        Toast.makeText(activity, activity.getResources().getString(R.string.no_audio_ID), Toast.LENGTH_LONG).show();
    } else {
        try {
            final Intent effects = new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL);
            effects.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, sessionId);
            effects.putExtra(AudioEffect.EXTRA_CONTENT_TYPE, AudioEffect.CONTENT_TYPE_MUSIC);
            activity.startActivityForResult(effects, 0);
        } catch (@NonNull final ActivityNotFoundException notFound) {
            Toast.makeText(activity, activity.getResources().getString(R.string.no_equalizer), Toast.LENGTH_SHORT).show();
        }
    }
}
 
Example #20
Source File: EqualizerVolumePanel.java    From Noyze with Apache License 2.0 5 votes vote down vote up
/** @see android.media.audiofx.AudioEffect.Descriptor#uuid */
protected boolean hasFeature(UUID uuid) {
    // Build of array of UUIDs to search through.
    if (null == uuids || uuids.length == 0) {
        uuids = new UUID[descriptors.length];
        int i = -1;
        for (AudioEffect.Descriptor descriptor : descriptors)
            uuids[++i] = descriptor.uuid;
    }
    return (Arrays.binarySearch(uuids, uuid) >= 0);
}
 
Example #21
Source File: EqualizerVolumePanel.java    From Noyze with Apache License 2.0 5 votes vote down vote up
/** @see android.media.audiofx.AudioEffect.Descriptor#name */
protected String[] getDescriptorNames() {
    // Build of array of UUIDs to search through.
    String[] names = new String[descriptors.length];
    int i = -1;
    for (AudioEffect.Descriptor descriptor : descriptors)
        names[++i] = descriptor.name;
    return names;
}
 
Example #22
Source File: EqualizerVolumePanel.java    From Noyze with Apache License 2.0 5 votes vote down vote up
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();
    }
}
 
Example #23
Source File: Util.java    From Jockey with Apache License 2.0 5 votes vote down vote up
public static Intent getSystemEqIntent(Context c) {
    Intent systemEq = new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL);
    systemEq.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, c.getPackageName());

    ActivityInfo info = systemEq.resolveActivityInfo(c.getPackageManager(), 0);
    if (info != null && !info.name.startsWith("com.android.musicfx")) {
        return systemEq;
    } else {
        return null;
    }
}
 
Example #24
Source File: Util.java    From Jockey with Apache License 2.0 5 votes vote down vote up
/**
 * Checks whether the current device is capable of instantiating and using an
 * {@link android.media.audiofx.Equalizer}
 * @return True if an Equalizer may be used at runtime
 */
public static boolean hasEqualizer() {
    for (AudioEffect.Descriptor effect : AudioEffect.queryEffects()) {
        if (EQUALIZER_UUID.equals(effect.type)) {
            return true;
        }
    }
    return false;
}
 
Example #25
Source File: RadioPlaybackService.java    From Sky31Radio with Apache License 2.0 5 votes vote down vote up
private void sendPlayingStatusChangedBroadcast(boolean isPlaying){
    if(isPlaying){
        final Intent audioEffectIntent = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION);
        audioEffectIntent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, player.mediaPlayer.getAudioSessionId());
        audioEffectIntent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
        sendBroadcast(audioEffectIntent);
    }

    buildNotification();

    Intent statusChangedIntent = new Intent();
    statusChangedIntent.setAction(ACTION_PLAYING_STATUS_CHANGED);
    statusChangedIntent.putExtra(RadioPlaybackService.KEY_IS_PLAYING, isPlaying);
    sendBroadcast(statusChangedIntent);
}
 
Example #26
Source File: EqualizerVolumePanel.java    From Noyze with Apache License 2.0 5 votes vote down vote up
/** @see android.media.audiofx.AudioEffect.Descriptor#uuid */
protected boolean hasFeature(UUID uuid) {
    // Build of array of UUIDs to search through.
    if (null == uuids || uuids.length == 0) {
        uuids = new UUID[descriptors.length];
        int i = -1;
        for (AudioEffect.Descriptor descriptor : descriptors)
            uuids[++i] = descriptor.uuid;
    }
    return (Arrays.binarySearch(uuids, uuid) >= 0);
}
 
Example #27
Source File: EqualizerVolumePanel.java    From Noyze with Apache License 2.0 5 votes vote down vote up
/** @see android.media.audiofx.AudioEffect.Descriptor#name */
protected String[] getDescriptorNames() {
    // Build of array of UUIDs to search through.
    String[] names = new String[descriptors.length];
    int i = -1;
    for (AudioEffect.Descriptor descriptor : descriptors)
        names[++i] = descriptor.name;
    return names;
}
 
Example #28
Source File: StandardLoudnessEnhancer.java    From android-openslmediaplayer with Apache License 2.0 5 votes vote down vote up
private static AudioEffect createInstance(int audioSession) throws UnsupportedOperationException {
    AudioEffect instance = S_IMPL.create(audioSession);
    if (instance == null) {
        throw new UnsupportedOperationException("LoudnessEnhancer is not supported");
    }
    return instance;
}
 
Example #29
Source File: LoudnessEnhancerCompatKitKat.java    From android-openslmediaplayer with Apache License 2.0 5 votes vote down vote up
@Override
public AudioEffect create(int audioSession) {
    try {
        return new LoudnessEnhancer(audioSession);
    } catch (RuntimeException e) {
        // NOTE: some devices doesn't support LoudnessEnhancer class and may throw an exception
        // (ME176C throws IllegalArgumentException)
        Log.w(TAG, "Failed to instantiate loudness enhancer class", e);
    }
    return null;
}
 
Example #30
Source File: WebRtcAudioEffects.java    From webrtc_android with MIT License 5 votes vote down vote up
private static boolean isAcousticEchoCancelerExcludedByUUID() {
  if (Build.VERSION.SDK_INT < 18)
    return false;
  for (Descriptor d : getAvailableEffects()) {
    if (d.type.equals(AudioEffect.EFFECT_TYPE_AEC)
        && d.uuid.equals(AOSP_ACOUSTIC_ECHO_CANCELER)) {
      return true;
    }
  }
  return false;
}