|
Reimplementation of the Audio interface for libGDX framework using Oboe and FFmpeg, which allows music to flow without any delay or another unpleasant distortion. And if you ever asked yourself "Why is my libGDX app music is so broken ?", then you've come to the right place. |
To use the library, you'll have to add it as a dependency and override the default audio engine on android:
class AndroidLauncher : AndroidApplication() {
// Magic happens here:
override fun createAudio(context: Context, config: AndroidApplicationConfiguration): AndroidAudio =
OboeAudio(context.assets)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Create an app like always
val config = AndroidApplicationConfiguration()
initialize(SomeApp(), config)
}
}Using Oboe library from Google you can create high-performance audio streams that may tweak some features in runtime to boost performance even further.
These streams are native, so there is no GC that will slow things down.
For audio decoding this library provide native tools: libavformat with MP3, OGG and WAV support only (but you can build it yourself to support more audio formats).
Such audio decoder is blazing fast and precise so combining that with oboe streams, we get responsive and fast Audio implementation.
Here is a table of known goodies and problems for certain features per file format (decoder):
| Feature | State | Description |
|---|---|---|
| Sounds | ⭐ | Per-sound soundpools. All features should be working. Although max sounds isn't read from android config, the number is infinite at the moment. |
| Music playing | ⭐ | Precise position, starts and pauses exactly when requested. |
| Music Seek | 👌 | WAV is precise, no content lost. OGG and MP3 is different: bad initial seek, but dropping frames until PTS is equal to desired seek TS. May lose some content if PTS isn't precise enough. |
| Audio Device | 👌 | Repetitive writes to audio device might produce audio artifacts (cracks). |
| Audio Recorder | 👌 | Repetitive reads bleed a little bit of cache from the last read to the buffer. Omit a few first frames when using recorded PCM. |
⭐ Works well
👌 It's alright in general but may have corner cases