Skip to content
mattix

alpaca

Rust, Swift, Kotlin · Android on Google Play · macOS in progress · GPL-3.0 · mattijsf/alpaca · alpaca.fm

Alpaca, formerly Andamp, is a music player that wears real Winamp skins, classic .wsz and modern .wal, with an equalizer, an effect rack and Winamp’s visualizers.

There are two apps. The Android app is written in Kotlin and is out on Google Play. The Mac app is newer: a Swift shell on a Rust core that any later desktop version will share. Both draw every skin, classic and modern, with walkit. The Android app reaches it through walkit’s Kotlin API and doesn’t use the Rust core yet.

Alpaca on an Android phone home screen: the classic Winamp skin with main window, equalizer and playlist, playing

Alpaca on a Pixel 9 Pro with the classic base skin.

On the Mac, each of a skin’s windows is a separate borderless window on the desktop, docking and snapping the way Winamp’s did. Almost all of that lives in core/, a Rust crate that is the same on every system:

shell ──▶ ffi ──▶ app ──┬──▶ skin ──▶ host, render ──▶ walkit
(apps/mac/) ├──▶ player ──▶ decode, output ──▶ device
│ └──▶ dsp: lua ──▶ graph ──▶ rack
└──▶ settings, vis

The shell talks to app and nothing behind it. It draws, opens panels and keeps timers, and asks the app for everything else. When the app needs the system, for example to quit, show a menu or let you pick a file, it sends the shell a request. The test for where code goes: if a Windows shell would have to write it again, it belongs in the core.

ffi has no logic. Each function converts its pointers to Rust values, calls one method and converts the answer back. Only three places in the core know which system they run on: the audio device, the list of system fonts and the settings folder.

walkit comes from crates.io and isn’t changed here. What the app needs and walkit lacks is noted in the plan and worked around in skin or host.

Everything runs on the shell’s main thread except audio. A song is decoded on a separate thread into a ring buffer, and the audio device’s callback drains it, applying the equalizer, the effect rack, balance and volume.

The callback never takes a lock and never allocates. Changes from the UI reach it as atomics or as commands through a ring. When the rack swaps in a new effect chain, the old one goes back to the main thread to be dropped there.

I measure every change to the step, the renderer or the audio path with --bench, playing and idle. The baseline is the walkit example app this grew from. Measured on an M1 Max:

Baseline Now
Classic skin playing 47% of a core 5.4%
Modern skin playing 99% 5.0%
Nothing playing 4% 0.0%, no steps
Drawing one window 4 to 20 ms a frame 16 to 45 µs
Memory 75 MB 25 MB

Of the 5%, the engine’s tick and draw lists take 1.2% and drawing pixels 0.3%. The rest is the 40 wakeups a second and decoding. Only the part of a window that changed is redrawn and handed over: render::damage compares each draw list with the previous one. A large skin like Bento, with one 1196×798 window, plays at 8%.

A classic skin that walkit can’t load falls back to the app’s older sprite renderer. The classic windows live in a 275 px wide virtual canvas, scaled up by an integer factor with nearest-neighbor filtering, and stay docked as a stack until you drag them apart. Playback runs on Media3: local files, the phone’s music library and internet radio, with background playback.

Anything that isn’t on the phone comes from a music source, which is a separate APK that Alpaca binds over AIDL. Any app that answers the bind intent shows up, without registration or keys. Jellyfin, Plex, Subsonic and Librespot work this way.

phonefiles, library, radio
Played through Media3.
corePlayerFacade and queue
The UI only talks to this. The queue mixes tracks from the phone and from sources.
separate APKsmusic sources
Jellyfin, Plex, Subsonic and Librespot. Each one is an app you install next to Alpaca.

The visualizer window runs Milkdrop presets through projectM, C++ built from source with the NDK, and AVS presets on a Kotlin rewrite of Winamp’s AVS, with only its expression evaluator native. For Android Auto there’s a small companion APK, Alpaca Auto, which puts the skinned main window on the car’s screen.

An effect is one .lua file. It declares its parameters and builds a DSP graph, which Alpaca compiles into the effect rack. You add the file through the system file picker.

plugin {
id = "nl.mattix.andamp.example.gain",
name = "Gain",
version = "1.0.0",
}
local level = param.number {
id = "level", name = "Level", min = 0, max = 2, default = 1,
}
function build(g, ctx)
local out = {}
for ch = 0, ctx.channels - 1 do
out[ch] = g.mul(g.input(ch), level)
end
return out
end

The Mac app runs the same format. Its loader, checks and engine are a Rust port of the Kotlin original, with the same arithmetic.

Most of the code is written with AI assistance. On Android, every push first runs ./gradlew gate: ktlint, detekt, the JVM unit tests and golden screenshot tests with Roborazzi. Every playback backend has to pass one shared contract test.

In the core, no test opens a window or the audio device. The test player decodes and keeps time without playing anything (Player::silent()), and the same tests run on every system. For what only a shell can show, the app has --dump, which writes every window as a PNG, and --bench.

Done: the windows with docking, snapping and multiple screens; playback of MP3, AAC, ALAC, FLAC, Ogg Vorbis, WAV and AIFF, gapless, plus internet radio; the equalizer and the skin’s visualizer; media keys and Now Playing; the effect rack; and Milkdrop visualizations. Still to come: the App Store and music sources.

No trackers or cookies. Older designs of this site.