Processing a file with Oboe

389 Views Asked by At

I'd like to build something a little like the LiveEffect sample in the Google/Oboe library.

However, I want to affect the audio selected from a file chosen by the user rather than the microphone input. I do not need the input.

There's no example in the Google/Oboe repo of how to operate on a file.

Does anyone have an example or guidance so I can let the user choose a file from their local storage, then (and this is the bit I'm missing) pass the audio across the JNI bridge to my oboe app?

I do the need low-latency capability of Oboe as I'm going to affect the audio in response to motion data.

Any guidance gratefully recieved.

1

There are 1 best solutions below

0
On

For anyone passing by in search of a similar solution, here's how I solved this

  1. On the Java/Kotlin side pick up the audio file (i used a WAV in this case) with an intent
  2. Use a contentResolver on the audio file to create an inputStream
  3. read the data from the inputStream into a byteArray
  4. pass the byteArray over the JNI bridge to the native code
  5. wrap the byteArray in a MemInputStream from the PARSELIB example
  6. wrap the MemInputStream in a WavStreamReader, also from the PARSELIB example
  7. create a SampleBuffer, from the IOLIB example, and load the WavStreamReader into it
  8. create SampleSource, from the IOLIB example, and give it the SampleBuffer
  9. give the SampleSource and SampleBuffer to the SimplePlayer from the IOLIB example
  10. do the processing in the SampleSource's mixAudio() method bearing in mind all the rules for real-time processing in Oboe.

I also needed to do this on the block because I have a fixed window operation. to do this, I adapted the SampleBuffer class to add a method that would pull block data into mixAudio(), but that's only specific to some cases.

I hope that helps someone in the future.