1Mega Drone
2==========
3Ever wondered what 100 square waves sound like when played together? Well now you can find out!
4
5Mega Drone is an app which creates 100 oscillators, combines their output in a mixer and plays the resulting sound.
6
7This sample demonstrates how to obtain the lowest latency and optimal computational throughput by:
8
91) Leaving Oboe to choose the best default stream properties for the current device
102) Setting performance mode to LowLatency
113) Setting sharing mode to Exclusive
124) Setting the buffer size to 2 bursts
135) Using the `-Ofast` compiler optimization flag, even when building the `Debug` variant
146) Using [`getExclusiveCores`](https://developer.android.com/reference/android/os/Process#getExclusiveCores()) (API 24+) and thread affinity to bind the audio thread to the best available CPU core(s)
157) Using a `StabilizedCallback` which aims to spend a fixed percentage of the callback time to avoid CPU frequency scaling ([video explanation](https://www.youtube.com/watch?v=C0BPXZIvG-Q&feature=youtu.be&t=1158))
16
17
18This code was presented at [AES Milan](http://www.aes.org/events/144/) and [Droidcon Berlin](https://www.de.droidcon.com/) as part of a talk on Oboe.
19
20The [following article explaining how to debug CPU performance problems](https://medium.com/@donturner/debugging-audio-glitches-on-android-ed10782f9c64) may also be useful when looking at this code.
21
22Implementation details
23---
24The stream properties are left to Oboe as such the app must output audio data in a format which matches that of the stream.
25
26Four different formats are supported:
27
28|Channel count|Format|
29|-------------|------|
30|1 - Mono|16-bit int|
31|2 - Stereo|16-bit int|
32|1 - Mono|Float|
33|1 - Stereo|Float|
34
35The signal chain for mono streams is:
36
37    Oscillators->Mixer
38
39For stereo chains a mono to stereo converter is added to the end of the chain:
40
41    Oscillators->Mixer->MonoToStereo
42
43The compiler optimization flag `-Ofast` can be found in [CMakeLists.txt](CMakeLists.txt).
44
45Screenshots
46-----------
47![megadrone-screenshot](megadrone-screenshot.png)