1*05767d91SRobert WuMega Drone 2*05767d91SRobert Wu========== 3*05767d91SRobert WuEver wondered what 100 square waves sound like when played together? Well now you can find out! 4*05767d91SRobert Wu 5*05767d91SRobert WuMega Drone is an app which creates 100 oscillators, combines their output in a mixer and plays the resulting sound. 6*05767d91SRobert Wu 7*05767d91SRobert WuThis sample demonstrates how to obtain the lowest latency and optimal computational throughput by: 8*05767d91SRobert Wu 9*05767d91SRobert Wu1) Leaving Oboe to choose the best default stream properties for the current device 10*05767d91SRobert Wu2) Setting performance mode to LowLatency 11*05767d91SRobert Wu3) Setting sharing mode to Exclusive 12*05767d91SRobert Wu4) Setting the buffer size to 2 bursts 13*05767d91SRobert Wu5) Using the `-Ofast` compiler optimization flag, even when building the `Debug` variant 14*05767d91SRobert Wu6) 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) 15*05767d91SRobert Wu 16*05767d91SRobert WuThis 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. 17*05767d91SRobert Wu 18*05767d91SRobert WuThe [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. 19*05767d91SRobert Wu 20*05767d91SRobert WuImplementation details 21*05767d91SRobert Wu--- 22*05767d91SRobert WuThe stream properties are left to Oboe as such the app must output audio data in a format which matches that of the stream. 23*05767d91SRobert Wu 24*05767d91SRobert WuFour different formats are supported: 25*05767d91SRobert Wu 26*05767d91SRobert Wu|Channel count|Format| 27*05767d91SRobert Wu|-------------|------| 28*05767d91SRobert Wu|1 - Mono|16-bit int| 29*05767d91SRobert Wu|2 - Stereo|16-bit int| 30*05767d91SRobert Wu|1 - Mono|Float| 31*05767d91SRobert Wu|2 - Stereo|Float| 32*05767d91SRobert Wu 33*05767d91SRobert WuThe signal chain for mono streams is: 34*05767d91SRobert Wu 35*05767d91SRobert Wu Oscillators->Mixer 36*05767d91SRobert Wu 37*05767d91SRobert WuFor stereo chains a mono to stereo converter is added to the end of the chain: 38*05767d91SRobert Wu 39*05767d91SRobert Wu Oscillators->Mixer->MonoToStereo 40*05767d91SRobert Wu 41*05767d91SRobert WuThe compiler optimization flag `-Ofast` can be found in [CMakeLists.txt](CMakeLists.txt). 42*05767d91SRobert Wu 43*05767d91SRobert WuScreenshots 44*05767d91SRobert Wu----------- 45*05767d91SRobert Wu 46