Skip to content

Implementing a custom audio processor #8962

@OneBadNinja

Description

@OneBadNinja

Greetings,

I would like to create a music/video player app which applies a custom audio effect based on a personal C++ library that I have JNI bindings for. I am very new to Android development, and from my reading I have seen that custom audio processing is to be done within the Audio Processor interface: https://exoplayer.dev/doc/reference/com/google/android/exoplayer2/audio/AudioProcessor.html

My plan is to inject the C++ DSP code within the queueInput() method and run block-based processing there. I have been looking through example code, github and the exoplayer.dev guides but I'm struggling to get a clear picture of how to proceed with this. The first few questions i'd like to ask are the following:

  • My DSP code uses block-based processing in the frequency domain requiring a fixed audio frame size. Is there anywhere I can set this to ie (256 frames, ie 512 samples for 2 channels)? Can I set a different number of channels for the output if I needed to (ie certain samsung tablets with 4 outputs)?

  • The DSP library works with pcm float format but I've read that this is not supported for Audio Processors (ie Is it possible to get PCM float audio stream in AudioProcessor from the MP4 video? #8384 if I've understood this correctly). Should I implement my own converter or is there a native converter/configuration I can set somewhere?

  • I need to work with a fixed sample rate when initializing my DSP library classes. From what I've read the SonicAudioProcessor can be used for this, so am I correct to assume that I would be placing it before my Audio Processor in the AudioProcessorChain to get ie 48khz audio passed from it?

Finally, is there any example code with custom audio processors that could help me understand the overall setup/process? I've come across a few bits of code that seem to be outdated/contradictory ie Audio Processors are now in the Audiosink instead of Renderers Factories. I would appreciate any pointers towards the right direction

Many thanks in advance for your time!

J

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions