Skip to content

Instantly share code, notes, and snippets.

@sigmadeltasoftware
Created March 21, 2017 13:32
Show Gist options
  • Save sigmadeltasoftware/319560fc45437dcea82f047a65743d86 to your computer and use it in GitHub Desktop.
Save sigmadeltasoftware/319560fc45437dcea82f047a65743d86 to your computer and use it in GitHub Desktop.
Android Low-Latency Audio Post-Processing with Superpowered - AudioPlayer Gist
...
...
private class EffectAudioTrack extends AudioTrack {
public EffectAudioTrack(int streamType, int sampleRateInHz, int channelConfig, int audioFormat, int bufferSizeInBytes, int mode) throws IllegalArgumentException {
super(streamType, sampleRateInHz, channelConfig, audioFormat, bufferSizeInBytes, mode);
}
public EffectAudioTrack(int streamType, int sampleRateInHz, int channelConfig, int audioFormat, int bufferSizeInBytes, int mode, int sessionId) throws IllegalArgumentException {
super(streamType, sampleRateInHz, channelConfig, audioFormat, bufferSizeInBytes, mode, sessionId);
}
public EffectAudioTrack(AudioAttributes attributes, AudioFormat format, int bufferSizeInBytes, int mode, int sessionId) throws IllegalArgumentException {
super(attributes, format, bufferSizeInBytes, mode, sessionId);
}
@Override
public int write(@NonNull ByteBuffer audioData, int sizeInBytes, int writeMode) {
renderEffectNative(audioData, audioProps.getNrChannels());
return super.write(audioData, sizeInBytes, writeMode);
}
}
private native void renderEffectNative(ByteBuffer data, int channelCount);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment