Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Some Music Libraries for Kotlin (with some .NET...

Some Music Libraries for Kotlin (with some .NET -> Kotlin migration stories)

10 min. KotlinConf LT at Kotlin Foundation booth

Avatar for Atsushi Eno

Atsushi Eno

May 22, 2025
Tweet

More Decks by Atsushi Eno

Other Decks in Technology

Transcript

  1. ktmidi Versatile MIDI processing library Provides access to MIDI 1.0

    and/or UMP (MIDI 2.0) devices Can create virtual devices (not doable in javax.sound.midi) Supports MIDI 2.0 UMP (a handful of libraries do) and MIDI-CI sessions (only JUCE in C++ and ktmidi in Kotlin do)
  2. MIDI? Is it still popular? MIDI 2.0: 2020 2023 updates

    - 7 bits => 32 bits - 16 channels => 16 channels x 16 groups - bidirectional like HTTP/3 Not for composition outputs, but it is used everywhere. - MIDI keyboards - within many cross-platform instrument plugins (implementation details) - in many audio plugin APIs: AudioUnit, CLAP (MIDI2 since around 2022)
  3. platform MIDI access: there are many backends • ALSA •

    WinMM ◦ Windows MIDI Services in the future • CoreMIDI • rtmidi, libremidi, portmidi... • Android MIDI API (android.media.midi) • Web MIDI API
  4. surviving native interop hell (did I ...?) managed-midi (~2018) •

    P/Invoke (winmm, alsa, portmidi, rtmidi) • Managed API ◦ UWP ◦ xamarin-macios ◦ xamarin-android simple-ish overall (no WebMIDI atm) Someday we get some universal solution w/ cinterop...? 🥹 • Kotlin/JVM ◦ LibreMidiAccess (LibreMidi) - panama ◦ AlsaMidiAccess - javacpp ◦ AndroidMidiAccess ◦ JvmMidiAccess (javax.sound.midi) • Kotlin/Native ◦ CoreMidiAccess (cinterop) ◦ RtMidiNativeAccess (cinterop) • Kotlin/JS ◦ JzzMidiAccess - Jazz-Soft/JZZ (npm) • Kotlin/Wasm ◦ WebMidiAccess - (webmidi)
  5. Text to Music files I had a compiler tool for

    my own language (variant of Music Macro Language) text => MIDI 2.0 song => DAW project file (using Tracktion_Engine OSS)
  6. Text to Music files Text to MIDI - antlr-kotlin to

    parse its syntax (in C# it was jay) - generates standard MIDI file (SMF), or SMF2-alike - embeddable to any Kotlin app MIDI to some XML-based DAW project files - ended up building my own .NET XML API ports (XmlReader, XmlWriter, XLinq) - XmlSerializer... no reflection in Kotlin, so codegen w/ KSP
  7. ImageStripKnob Compact yet mobile-friendly - sizes: align with Android UI

    Accessibility Guidelines - drag to move your finger away horizontally without value changes - adjust value vertically - hold to switch to fine-tuning mode No value change Value change
  8. DiatonicKeyboard Aligns with Android Accessibility Guideline drag to naturally play

    next note, or pitch bend horizontally or vertically (per-note)
  9. Repos https://github.com/atsushieno/ktmidi/ - MIDI library https://github.com/atsushieno/mugene-ng - text to MIDI

    compiler https://github.com/atsushieno/augene-ng - ... to DAW XML project compiler https://github.com/atsushieno/missing-dot - .NET XML API ports https://github.com/atsushieno/compose-audio-controls/ - audio controls in KMP https://github.com/atsushieno/kmdsp/ - visual MIDI player in KMP