Java Code Examples for android.media.AudioTrack#setStereoVolume()

The following examples show how to use android.media.AudioTrack#setStereoVolume() . 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: BlockingAudioTrack.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private static void setupVolume(AudioTrack audioTrack, float volume, float pan) {
    final float vol = clip(volume, 0.0f, 1.0f);
    final float panning = clip(pan, -1.0f, 1.0f);

    float volLeft = vol;
    float volRight = vol;
    if (panning > 0.0f) {
        volLeft *= (1.0f - panning);
    } else if (panning < 0.0f) {
        volRight *= (1.0f + panning);
    }
    if (DBG) Log.d(TAG, "volLeft=" + volLeft + ",volRight=" + volRight);
    if (audioTrack.setStereoVolume(volLeft, volRight) != AudioTrack.SUCCESS) {
        Log.e(TAG, "Failed to set volume");
    }
}
 
Example 2
Source File: DefaultAudioSink.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
private static void setVolumeInternalV3(AudioTrack audioTrack, float volume) {
  audioTrack.setStereoVolume(volume, volume);
}
 
Example 3
Source File: DefaultAudioSink.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private static void setVolumeInternalV3(AudioTrack audioTrack, float volume) {
  audioTrack.setStereoVolume(volume, volume);
}
 
Example 4
Source File: DefaultAudioSink.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private static void setVolumeInternalV3(AudioTrack audioTrack, float volume) {
  audioTrack.setStereoVolume(volume, volume);
}
 
Example 5
Source File: DefaultAudioSink.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private static void setVolumeInternalV3(AudioTrack audioTrack, float volume) {
  audioTrack.setStereoVolume(volume, volume);
}
 
Example 6
Source File: DefaultAudioSink.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private static void setVolumeInternalV3(AudioTrack audioTrack, float volume) {
  audioTrack.setStereoVolume(volume, volume);
}