Overview
Csound for Android 7.0 consists of:- Csound core library
- OpenSL ES audio backend
- Java interface (csnd7 package)
- JNI bindings
- Plugin libraries
- Example applications
Requirements
- Android Studio: https://developer.android.com/studio/
- Android NDK: http://developer.android.com/tools/sdk/ndk/
Directory structure
Building from source
Prerequisites
Set environment variables:Download dependencies
Build the library
- JNI libs in
./CsoundAndroid/libs - Java sources in
./CsoundAndroid/src
Update Android Studio project
Using in Android Studio
Add as dependency
- Import the CsoundAndroid module into your project
- Add to your app’s
build.gradle:
Initialize Csound
Load CSD from assets
Control channels
Communicate with running Csound code:Score events
Send real-time score events:OpenSL ES audio backend
Csound for Android uses OpenSL ES for low-latency audio:Permissions
Add toAndroidManifest.xml:
MIDI support
Android MIDI API integration:Performance optimization
Use native sample rate
Match device’s native sample rate:Optimal buffer size
Background processing
Keep audio running in background:Example application
SeeCsoundForAndroid/CsoundAndroidExamples for complete examples including:
- Basic synthesis
- Audio file playback
- Real-time control
- MIDI input
- UI integration
Kotlin usage
Using Csound in Kotlin:Create release package
Generate a release package:Troubleshooting
NDK version mismatch
EnsureANDROID_NDK_ROOT points to a compatible NDK version (r21 or later recommended).
Audio glitches
Try adjusting buffer sizes:Library not loaded
Ensure native libraries are included in APK. Checkbuild.gradle: