'Processing a file with Oboe
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.
Solution 1:[1]
For anyone passing by in search of a similar solution, here's how I solved this
- On the Java/Kotlin side pick up the audio file (i used a WAV in this case) with an intent
- Use a contentResolver on the audio file to create an inputStream
- read the data from the inputStream into a byteArray
- pass the byteArray over the JNI bridge to the native code
- wrap the byteArray in a MemInputStream from the PARSELIB example
- wrap the MemInputStream in a WavStreamReader, also from the PARSELIB example
- create a SampleBuffer, from the IOLIB example, and load the WavStreamReader into it
- create SampleSource, from the IOLIB example, and give it the SampleBuffer
- give the SampleSource and SampleBuffer to the SimplePlayer from the IOLIB example
- 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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | garrilla |
