Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

Some Music Libraries for Kotlin Dotnet Users Migration Path (DUMP) to Kotlin atsushieno

Slide 3

Slide 3 text

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)

Slide 4

Slide 4 text

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)

Slide 5

Slide 5 text

Managed language for DAWs? Yes, Java is used

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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)

Slide 8

Slide 8 text

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)

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

make it compile from VSCodium extension The compiler package is up on npm using npm-publish

Slide 11

Slide 11 text

compose-audio-controls maybe the coolest one mine 🤣

Slide 12

Slide 12 text

ImageStripKnob Pick any image strip from 2400+ knobs from KnobGallery (based on image strip)

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

DiatonicKeyboard Aligns with Android Accessibility Guideline drag to naturally play next note, or pitch bend horizontally or vertically (per-note)

Slide 15

Slide 15 text

Demo, if time permits

Slide 16

Slide 16 text

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