Skip to content

LanguageIdiomaภาษา

Open sourceCódigo abiertoโอเพนซอร์ส

KlarinetKlarinetKlarinet

Designed and built the shared Kotlin API, native platform backends, C++ DSP layer, publishing workflow, and documentation.Diseñé y construí la API compartida en Kotlin, los backends nativos de cada plataforma, la capa DSP en C++, el flujo de publicación y la documentación.ออกแบบและสร้าง API ภาษา Kotlin ที่ใช้ร่วมกัน แบ็กเอนด์เนทีฟของแต่ละแพลตฟอร์ม เลเยอร์ DSP ภาษา C++ ขั้นตอนการเผยแพร่ และเอกสาร

An open-source Kotlin Multiplatform audio SDK with native Android and Apple backends plus a shared C++ DSP core for real-time effects.SDK de audio de código abierto en Kotlin Multiplatform, con backends nativos para Android y Apple y un núcleo DSP en C++ para efectos en tiempo real.SDK เสียงโอเพนซอร์สบน Kotlin Multiplatform มีแบ็กเอนด์เนทีฟของ Android และ Apple พร้อมคอร์ DSP ภาษา C++ ที่ใช้ร่วมกันสำหรับเอฟเฟกต์เรียลไทม์

Kotlin MultiplatformAudioKMPOpen SourceOboeC++
Klarinet audio SDK logo

The problem, my role and the resultEl problema, mi papel y el resultadoปัญหา บทบาทของผม และผลลัพธ์

ProblemProblemaปัญหา
Kotlin Multiplatform can share UI and business logic, but serious audio still forced two native implementations and endless parity work.Kotlin Multiplatform puede compartir interfaz y lógica de negocio, pero el audio serio seguía obligando a dos implementaciones nativas y a un trabajo de paridad sin fin.Kotlin Multiplatform แชร์ UI และลอจิกธุรกิจได้ แต่งานเสียงจริงจังยังบังคับให้มีสองการทำให้แบบเนทีฟ และงานรักษาพาริตีที่ไม่สิ้นสุด
My contributionMi contribuciónส่วนที่ผมทำ
Designed one Kotlin-facing API, implemented the native Android and Apple backends, and built the shared C++ DSP core and release pipeline.Diseñé una API de cara a Kotlin, implementé los backends nativos de Android y de Apple, y construí el núcleo DSP compartido en C++ y el proceso de publicación.ออกแบบ API ที่หันหน้าเข้า Kotlin หนึ่งชุด ทำให้แบ็กเอนด์เนทีฟของ Android และ Apple และสร้างคอร์ DSP ภาษา C++ ที่ใช้ร่วมกันกับไปป์ไลน์การปล่อย
ApproachEnfoqueแนวทาง
One idiomatic Kotlin API that delegates to Google Oboe on Android and AVAudioEngine on Apple, with a shared C++ DSP core for lock-free, hot-swappable effects.Una API idiomática en Kotlin que delega en Google Oboe en Android y en AVAudioEngine en Apple, con un núcleo DSP compartido en C++ para efectos libres de cerrojos e intercambiables en caliente.API ภาษา Kotlin ที่เป็นธรรมชาติหนึ่งชุด ซึ่งส่งต่อให้ Google Oboe บน Android และ AVAudioEngine บน Apple พร้อมคอร์ DSP ภาษา C++ ที่ใช้ร่วมกัน สำหรับเอฟเฟกต์ที่ปราศจากล็อกและสลับได้ขณะทำงาน
OutcomeResultadoผลลัพธ์
Open-source low-latency audio SDK published on Maven Central and listed on klibs.io, with a single code path for playback, recording, and real-time effects.SDK de audio de baja latencia y de código abierto, publicado en Maven Central y listado en klibs.io, con una sola ruta de código para reproducción, grabación y efectos en tiempo real.SDK เสียงเวลาแฝงต่ำแบบโอเพนซอร์ส ที่เผยแพร่บน Maven Central และมีรายการบน klibs.io โดยมีเส้นทางโค้ดเดียวสำหรับการเล่น การบันทึก และเอฟเฟกต์เรียลไทม์
StackTecnologíasเทคโนโลยี
  • Kotlin Multiplatform
  • Oboe
  • AVAudioEngine
  • C++
  • Maven Central

The audio layer Kotlin Multiplatform was missing

Cross-platform UI is largely solved: Compose Multiplatform lets you share screens, navigation, and business logic across Android and iOS. Audio was left behind. If your app needs to play a tone, record from a mic, decode a file, or apply reverb, you write platform-specific code twice and keep both sides in sync forever.

Klarinet fills that gap. You write your audio code once in Kotlin, and the library delegates to the best native backend on each platform: Google Oboe (AAudio / OpenSL ES) on Android, AVAudioEngine on Apple. The point is that you don’t pay an abstraction tax for going cross-platform. Each backend is the one the platform vendor recommends for serious audio work, so you get native latency and native behavior while still writing the calling code once.

What’s inside

  • Low-latency playback and recording behind a single AudioEngine API, with a callback that runs directly on the native audio thread. Keeping that callback on the real audio thread is what makes sub-10ms latency achievable, since the audio buffer never has to bounce back through the JVM or a managed dispatcher to get filled.
  • 16 built-in effects powered by a shared C++ DSP core: gain, pan, compressor, limiter, noise gate, 8-band parametric EQ, low/high/band-pass filters, delay, reverb, chorus, flanger, phaser, and tremolo. Putting the DSP in C++ means the exact same processing math runs on Android and Apple, so a reverb sounds the same on both platforms instead of drifting apart between two separate implementations.
  • Hot-swappable effect chains. Add, remove, or reorder effects while audio is streaming, with every parameter update lock-free and audio-thread safe. Lock-free matters here because taking a mutex on the audio thread is how you get glitches and dropouts, so parameter changes are published to the running graph without ever blocking it.
  • Real-time metering through Kotlin Flows (levelFlow()) and raw PCM access for FFT, pitch detection, or custom signal processing. The Flow-based metering fits naturally into Compose and coroutine code, and the raw PCM tap is the escape hatch for anything Klarinet doesn’t do for you out of the box.

Built for real apps

Music production tools, voice and communication apps, games, audio analysers, and accessibility tools that need live passthrough with sub-10ms latency. These are the cases where the two-implementations approach hurts most: audio bugs are hard to reproduce, and having one code path instead of two means a fix lands on both platforms at once. One API, two platform families, no parity drift.

Install

Klarinet is open source and published to Maven Central, so pulling it in is a single Gradle dependency with no extra repositories to configure:

implementation("com.vectencia.klarinet:klarinet:0.0.1")

The current release is Klarinet 0.6.0. It keeps this API and moves the shared DSP core to Rust.

Source is on GitHub, and the package listing lives on klibs.io.

Frequently Asked Questions

What is Klarinet?

Klarinet is an open-source Kotlin Multiplatform audio SDK. It gives you one idiomatic Kotlin API for low-latency playback, recording, file I/O, and real-time effects, so you write your audio code once and run it across Android and Apple platforms.

What platforms does Klarinet support?

Android and Apple platforms. On each one it delegates to the native backend the platform vendor recommends: Google Oboe (AAudio / OpenSL ES) on Android, and AVAudioEngine on Apple.

What is Klarinet built with?

An idiomatic Kotlin API on top of native audio backends, with a shared C++ DSP core that powers the 16 built-in effects. Metering is exposed through Kotlin Flows via levelFlow(), and raw PCM access is available for FFT, pitch detection, or custom signal processing.

Is Klarinet open source, and how do I install it?

Yes. The source is on GitHub, and the library is published to Maven Central. You add it with a single Gradle dependency: implementation("com.vectencia.klarinet:klarinet:0.0.1").

La capa de audio que le faltaba a Kotlin Multiplatform

La interfaz multiplataforma está en gran parte resuelta: Compose Multiplatform permite compartir pantallas, navegación y lógica de negocio entre Android e iOS. El audio se quedó atrás. Si la app tiene que reproducir un tono, grabar del micrófono, decodificar un fichero o aplicar reverberación, escribes código específico de cada plataforma dos veces y mantienes ambos lados sincronizados para siempre.

Klarinet cubre ese hueco. Escribes el código de audio una sola vez en Kotlin, y la biblioteca delega en el mejor backend nativo de cada plataforma: Google Oboe (AAudio / OpenSL ES) en Android y AVAudioEngine en Apple. La idea es que no pagas un peaje de abstracción por ir a multiplataforma. Cada backend es el que el fabricante de la plataforma recomienda para el audio serio, así que obtienes latencia nativa y comportamiento nativo escribiendo el código que llama una sola vez.

Qué incluye

  • Reproducción y grabación de baja latencia detrás de una sola API AudioEngine, con un callback que se ejecuta directamente en el hilo de audio nativo. Mantener ese callback en el hilo de audio real es lo que hace alcanzable una latencia por debajo de 10 ms, porque el búfer de audio no tiene que volver a rebotar por la JVM ni por un despachador gestionado para llenarse.
  • 16 efectos incluidos, impulsados por un núcleo DSP compartido en C++: ganancia, panorama, compresor, limitador, puerta de ruido, ecualizador paramétrico de 8 bandas, filtros paso bajo, paso alto y paso banda, delay, reverberación, chorus, flanger, phaser y trémolo. Poner el DSP en C++ significa que las mismas matemáticas de procesado corren en Android y en Apple, así que una reverberación suena igual en las dos plataformas en lugar de irse separando entre dos implementaciones distintas.
  • Cadenas de efectos intercambiables en caliente. Añadir, quitar o reordenar efectos mientras el audio está en curso, con cada actualización de parámetro libre de cerrojos y segura para el hilo de audio. Que sea libre de cerrojos importa porque tomar un mutex en el hilo de audio es como se producen chasquidos y cortes, así que los cambios de parámetro se publican al grafo en ejecución sin bloquearlo nunca.
  • Medición en tiempo real mediante Kotlin Flows (levelFlow()) y acceso al PCM en bruto para FFT, detección de tono o procesado de señal a medida. La medición basada en Flow encaja de forma natural en Compose y en el código con corrutinas, y la toma de PCM en bruto es la vía de escape para cualquier cosa que Klarinet no haga de serie.

Hecho para apps reales

Herramientas de producción musical, apps de voz y de comunicación, juegos, analizadores de audio y herramientas de accesibilidad que necesitan un paso directo en vivo con latencia por debajo de 10 ms. Son los casos en los que más duele el enfoque de dos implementaciones: los fallos de audio son difíciles de reproducir, y tener una ruta de código en lugar de dos significa que una corrección aterriza en las dos plataformas a la vez. Una API, dos familias de plataforma, sin deriva de paridad.

Instalación

Klarinet es de código abierto y está publicado en Maven Central, así que incorporarlo es una sola dependencia de Gradle, sin repositorios extra que configurar:

implementation("com.vectencia.klarinet:klarinet:0.0.1")

La versión actual es Klarinet 0.6.0. Mantiene esta API y pasa el núcleo DSP compartido a Rust.

El código está en GitHub, y la ficha del paquete vive en klibs.io.

Preguntas frecuentes

¿Qué es Klarinet?

Klarinet es un SDK de audio de código abierto en Kotlin Multiplatform. Ofrece una API idiomática en Kotlin para reproducción de baja latencia, grabación, E/S de ficheros y efectos en tiempo real, de modo que escribes el código de audio una vez y lo ejecutas en Android y en las plataformas de Apple.

¿Qué plataformas admite Klarinet?

Android y las plataformas de Apple. En cada una delega en el backend nativo que recomienda el fabricante: Google Oboe (AAudio / OpenSL ES) en Android y AVAudioEngine en Apple.

¿Con qué está hecho Klarinet?

Con una API idiomática en Kotlin sobre backends de audio nativos, y un núcleo DSP compartido en C++ que impulsa los 16 efectos incluidos. La medición se expone mediante Kotlin Flows con levelFlow(), y hay acceso al PCM en bruto para FFT, detección de tono o procesado de señal a medida.

¿Klarinet es de código abierto y cómo se instala?

Sí. El código está en GitHub y la biblioteca está publicada en Maven Central. Se añade con una sola dependencia de Gradle: implementation("com.vectencia.klarinet:klarinet:0.0.1").

เลเยอร์เสียงที่ Kotlin Multiplatform ยังขาด

UI ข้ามแพลตฟอร์มส่วนใหญ่แก้ได้แล้ว: Compose Multiplatform ให้แชร์หน้าจอ การนำทาง และลอจิกธุรกิจข้าม Android และ iOS ได้ เสียงถูกทิ้งไว้ข้างหลัง ถ้าแอปของคุณต้องเล่นโทน บันทึกจากไมโครโฟน ถอดรหัสไฟล์ หรือใส่รีเวิร์บ คุณเขียนโค้ดเฉพาะแพลตฟอร์มสองครั้ง และทำให้ทั้งสองฝั่งตรงกันตลอดไป

Klarinet เติมช่องว่างนั้น คุณเขียนโค้ดเสียงครั้งเดียวใน Kotlin แล้วไลบรารีส่งต่อให้แบ็กเอนด์เนทีฟที่ดีที่สุดบนแต่ละแพลตฟอร์ม: Google Oboe (AAudio / OpenSL ES) บน Android, AVAudioEngine บน Apple ประเด็นคือคุณไม่ต้องจ่ายต้นทุนแอบสแตรกชันเพื่อไปข้ามแพลตฟอร์ม แบ็กเอนด์แต่ละตัวคือตัวที่ผู้ผลิตแพลตฟอร์มแนะนำสำหรับงานเสียงจริงจัง ดังนั้นคุณได้เวลาแฝงแบบเนทีฟและพฤติกรรมแบบเนทีฟ ขณะที่ยังเขียนโค้ดที่เรียกใช้เพียงครั้งเดียว

มีอะไรข้างใน

  • การเล่นและการบันทึกเวลาแฝงต่ำ ภายใต้ API AudioEngine เดียว พร้อมคอลแบ็กที่รันตรงบนเธรดเสียงเนทีฟ การคงคอลแบ็กนั้นไว้บนเธรดเสียงจริง คือสิ่งที่ทำให้เวลาแฝงต่ำกว่า 10 มิลลิวินาทีเป็นไปได้ เพราะบัฟเฟอร์เสียงไม่ต้องเด้งกลับผ่าน JVM หรือดิสแพตเชอร์แบบจัดการ เพื่อที่จะถูกเติม
  • เอฟเฟกต์ในตัว 16 ตัว ที่ขับด้วยคอร์ DSP ภาษา C++ ที่ใช้ร่วมกัน: gain, pan, compressor, limiter, noise gate, EQ พาราเมตริก 8 แบนด์, ฟิลเตอร์ low-pass, high-pass และ band-pass, delay, reverb, chorus, flanger, phaser และ tremolo การวาง DSP ไว้ใน C++ หมายความว่าคณิตศาสตร์การประมวลผลชุดเดียวกันเป๊ะรันบน Android และ Apple ดังนั้นรีเวิร์บจึงฟังเหมือนกันบนทั้งสองแพลตฟอร์ม แทนที่จะค่อยๆ เหลื่อมออกจากกันระหว่างสองการทำให้ที่แยกกัน
  • เชนเอฟเฟกต์ที่สลับได้ขณะทำงาน เพิ่ม ตัดออก หรือจัดลำดับเอฟเฟกต์ใหม่ได้ขณะที่เสียงกำลังสตรีม โดยทุกการอัปเดตพารามิเตอร์ปราศจากล็อกและปลอดภัยบนเธรดเสียง ความปราศจากล็อกสำคัญตรงนี้ เพราะการจับ mutex บนเธรดเสียงคือวิธีที่ทำให้เกิดเสียงกระตุกและเสียงขาดช่วง ดังนั้นการเปลี่ยนพารามิเตอร์จึงถูกส่งเข้ากราฟที่กำลังรัน โดยไม่บล็อกมันเลย
  • มิเตอร์แบบเรียลไทม์ผ่าน Kotlin Flows (levelFlow()) และการเข้าถึง PCM ดิบ สำหรับ FFT, การตรวจจับพิทช์ หรือการประมวลผลสัญญาณที่ทำเอง มิเตอร์ที่อิง Flow เข้ากับโค้ดของ Compose และคอรูทีนได้ตามธรรมชาติ และจุดดึง PCM ดิบคือทางออกสำหรับสิ่งที่ Klarinet ไม่ทำให้มาให้

สร้างมาสำหรับแอปจริง

เครื่องมือผลิตดนตรี, แอปเสียงและการสื่อสาร, เกม, ตัววิเคราะห์เสียง และเครื่องมือการเข้าถึงที่ต้องการพาสทรูแบบสดด้วยเวลาแฝงต่ำกว่า 10 มิลลิวินาที นี่คือกรณีที่แนวทางสองการทำให้เจ็บที่สุด: บั๊กเสียงทำให้เกิดซ้ำได้ยาก และการมีเส้นทางโค้ดเส้นเดียวแทนสองเส้น หมายความว่าการแก้หนึ่งครั้งลงทั้งสองแพลตฟอร์มพร้อมกัน API เดียว สองตระกูลแพลตฟอร์ม ไม่มีความคลาดของพาริตี

การติดตั้ง

Klarinet เป็นโอเพนซอร์สและเผยแพร่ไปยัง Maven Central ดังนั้นการดึงเข้ามาคือดีเพนเดนซี Gradle รายการเดียว โดยไม่มีรีพอสิทอรีเพิ่มที่ต้องตั้งค่า:

implementation("com.vectencia.klarinet:klarinet:0.0.1")

รุ่นปัจจุบันคือ Klarinet 0.6.0 มันคง API นี้ไว้ และย้ายคอร์ DSP ที่ใช้ร่วมกันไปเป็น Rust

ซอร์สอยู่บน GitHub และรายการแพ็กเกจอยู่บน klibs.io

คำถามที่พบบ่อย

Klarinet คืออะไร?

Klarinet คือ SDK เสียงโอเพนซอร์สบน Kotlin Multiplatform มันให้ API ภาษา Kotlin ที่เป็นธรรมชาติหนึ่งชุด สำหรับการเล่นเวลาแฝงต่ำ การบันทึก การอ่านเขียนไฟล์ และเอฟเฟกต์เรียลไทม์ ดังนั้นคุณเขียนโค้ดเสียงครั้งเดียว แล้วรันข้าม Android และแพลตฟอร์ม Apple

Klarinet รองรับแพลตฟอร์มใด?

Android และแพลตฟอร์ม Apple บนแต่ละตัวมันส่งต่อให้แบ็กเอนด์เนทีฟที่ผู้ผลิตแพลตฟอร์มแนะนำ: Google Oboe (AAudio / OpenSL ES) บน Android และ AVAudioEngine บน Apple

Klarinet สร้างด้วยอะไร?

API ภาษา Kotlin ที่เป็นธรรมชาติ บนแบ็กเอนด์เสียงเนทีฟ พร้อมคอร์ DSP ภาษา C++ ที่ใช้ร่วมกันซึ่งขับเอฟเฟกต์ในตัว 16 ตัว มิเตอร์ถูกเปิดผ่าน Kotlin Flows ด้วย levelFlow() และมีการเข้าถึง PCM ดิบสำหรับ FFT, การตรวจจับพิทช์ หรือการประมวลผลสัญญาณที่ทำเอง

Klarinet เป็นโอเพนซอร์สหรือไม่ และติดตั้งอย่างไร?

ใช่ ซอร์สอยู่บน GitHub และไลบรารีเผยแพร่ไปยัง Maven Central คุณเพิ่มมันด้วยดีเพนเดนซี Gradle รายการเดียว: implementation("com.vectencia.klarinet:klarinet:0.0.1")

Need this kind of work on your app?¿Necesitas este tipo de trabajo en tu app?ต้องการงานแบบนี้ในแอปของคุณไหม