Skip to content
All articles

Desktop Applications

A music library without subscriptions: Tauri, SQLite and local Whisper

Listening to music now depends entirely on the cloud, subscriptions and DRM. I wanted full control over my own archive, so I wrote a player that works offline, stores FLAC and transcribes lyrics with local AI.

Fahrettin Baştürk4 min read

Our music habits have moved entirely to the cloud in recent years. Instead of owning a song, we rent access to it; when a subscription ends or a license changes, part of the library quietly disappears. I know I'm not the only one bothered by this. So I wrote my own answer: Lain Wave.

The goal was clear: a music library that needs no internet connection, keeps all data with the user, has no telemetry and stores audio losslessly as FLAC.

What does local-first mean?

Local-first means the app's primary data source is the user's device. If there's a server, it's a helper; without it, the app still works completely. Lain Wave makes no requests to any server except for downloading media from YouTube. Playlists, artists, lyrics; everything lives in a local SQLite database.

Architecture: SvelteKit in front, Rust behind

The UI is written in SvelteKit; file-based routing (/playlist/[id], /artist/[name]) fits the natural structure of a music library very well. The backend is Rust via Tauri. I explained why Tauri and not Electron in a separate post; for a music player that sits in the background all day, memory usage really matters.

Database and concurrency

The database layer uses rusqlite. Since several Tauri commands can hit the database at the same time, the connection is wrapped in Arc<Mutex<Connection>>. For SQLite this simple approach is enough; what matters is keeping the lock short and doing long work outside it.

Backups and restores write JSON data with bulk inserts inside a transaction. Either everything is written or nothing; a half-finished restore never corrupts the library.

Downloading without freezing the UI

Downloading a song from YouTube and converting it to FLAC can take seconds, sometimes minutes. These jobs run inside spawn_blocking tasks so they never block Tauri's main event loop. yt-dlp and FFmpeg are driven directly through std::process::Command, with their output piped.

use std::os::windows::process::CommandExt;
const CREATE_NO_WINDOW: u32 = 0x0800_0000;

let status = Command::new(ffmpeg_path())
    .args(["-i", &input, "-c:a", "flac", &output])
    .creation_flags(CREATE_NO_WINDOW) // no console window flashing on Windows
    .status()?;

That tiny flag makes a big difference to the experience. Without it, a black command window flashes on screen with every download and gives the user the feeling that "this program is hiding something".

Lyrics, without sending anything to the cloud

Using a cloud API to transcribe lyrics would have contradicted the whole local-first idea. Instead I run the Whisper model locally through the whisper_rs bindings to the C++ GGML runtime. Downloaded audio is converted to 16-bit PCM (pcm_s16le) with hound and fed straight into the model. Depending on the computer, it can take a while, but the audio file never leaves the machine.

Discord status

A small feature I like: the current song shows up in your Discord status. It's entirely optional and local; it talks to the Discord client on the same computer.

What I learned

  • A local-first architecture forces you to reduce dependencies, and that makes the app sturdier.
  • Moving every long-running job off the main loop is the first rule of smoothness in desktop apps.
  • Local AI isn't an experiment anymore; with the right model for the right job, it's genuinely usable.

Writing Lain Wave, I wanted back that old feeling that my music belonged to me. Being able to listen to a song from my own disk, lossless, without asking anyone. Sometimes moving forward starts with taking back what we already had.

Fahrettin Baştürk

Software Engineer & Consultant

Share
  • Rust
  • Tauri
  • SQLite
  • Local AI

Working on a similar system or problem?Tell me about your project