Skip to content
YuHaiboPublic

About

Zero Music: local music and MyGo Music-compatible plugins for Cardputer Zero

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

Zero Music running in the desktop simulator

Zero Music

A Cardputer Zero music player: local files and MyGo Music plugins, with a keyboard-first LVGL interface.

SDL3 CMake LVGL Raspberry Pi

Zero Music is two processes: a Go core (library, player, plugins, settings) and a C++/LVGL UI that talks to it over a Unix-socket JSON-RPC protocol. Desktop builds use an SDL simulator; the device builds against Linux fbdev/evdev.

Music sources and plugins

Important

Zero Music does not provide, host, bundle or distribute any music source. The application contains no music catalogue and no streaming service credentials. Local files can be played without any plugin. Network music is only available after installing a MyGo Music-compatible plugin.

Zero Music reuses part of the source code of MyGo Music and is compatible with its plugin system. The packages under core/internal/music, core/internal/plugin, core/internal/player, core/internal/local, core/internal/lyrics and core/internal/i18n are adapted from that project, which is licensed under AGPL-3.0. See NOTICE for details.

Plugins are separate third-party software. They are not part of MyGo Music or Zero Music, and this project does not control, review, endorse or support them. A plugin may contact its own services, require its own account, and run JavaScript with the permissions you grant through the Plugins page. Only install plugins whose source and operator you trust.

Plugin directory:

Writing your own plugin:

You are responsible for making sure that the plugins you install and the music you access are legal in your jurisdiction and comply with the services' terms.

Project Overview

In this example project, we used small MVVM-style structure around LVGL:

  • UI layer: screens and widgets are implemented with LVGL objects. BaseScreen owns the page root, status bar, and page content. Widgets derive from BaseWidgets and expose a build() entry point.
  • Data model: BaseModel stores the current page, connection state, track and playback state.
  • View model: BaseViewModel owns the IPC client, publishes model state as LVGL subjects, and sends player commands to the core.
  • Reactive/data binding: src/reactive wraps LVGL observer subjects and common bindings so labels, styles, flags, widget values, and events can be connected to application state.
  • Data flow: user input triggers widget callbacks, callbacks update BaseViewModel, view model publishes subjects, and bound UI objects refresh automatically through LVGL observers.
  • Platform layer: platform code owns Linux input integration, screenshots and hardware status.
  • Core: core/ is a Go module with the local library, player, plugin host, settings and the socket server. See docs/implementation-status.md.

Current UI:

  • Home: current album cover, active source, and entries for Now Playing, Recent, Browse, Search, Settings, Plugins and Help.
  • Now Playing: cover, title, artist, album, progress, volume, LIKE and scrolling lyrics.
  • Keys: Q/Space play-pause, W previous, E next, Left/Right seek -/+10s, Up/Down volume, 4 Now Playing, 5 previous, 6 play-pause, 7 next, 8 repeat, 9 queue, 0 lyrics, L like, short ESC back, hold ESC exit, Fn+H help, Fn+J screenshot.
  • Plugins: Enter selects a source, Tab filters, D twice removes, S signs in, O signs out, P edits settings, I installs. Local Files is a built-in, non-removable source. Plugins that support login show Login * or Logged in.
  • F/Z/X/C are Up/Left/Down/Right without Fn on lists and menus; while a search, install or plugin-setting field is being edited they type their letters instead. Arrow keys always navigate.
  • Pages: Browse and Search list the active source and play from the focused row; Settings changes volume, quality, cache, language, local music folders and rescans; Plugins picks the active source, filters, grants process access and starts sign-in.

Repository Layout

.
├── assets/                 # Runtime assets used by the app
│   ├── applications/       # Desktop/app launcher metadata
│   ├── audio/              # Audio resources
│   ├── fonts/              # TTF fonts loaded through FreeType
│   └── images/             # Image resources
├── screenshot/             # Simulator screenshots for supported desktop platforms
├── src/
│   ├── app/                # Application lifecycle, asset loading, screen management
│   ├── config/             # LVGL config headers for desktop and device builds
│   ├── logger/             # Project logging wrapper
│   ├── model/              # Base application data model
│   ├── platform/           # Platform input/hardware integration
│   ├── reactive/           # LVGL observer subjects and binding helpers
│   ├── view/               # Theme, UI constants, screens, and widgets
│   │   ├── screens/        # Page-level LVGL screens
│   │   └── widgets/        # Reusable LVGL widgets such as nav bar and icon button
│   ├── viewmodel/          # BaseViewModel and UI-facing actions/state subjects
│   └── main.cpp            # Program entry point
├── CMakeLists.txt          # Build graph, dependencies, options, targets
├── CMakePresets.json       # Desktop/device configure and build presets
└── README.md

Modules

  • src/app/asset_manager.*: resolves runtime assets from the optional CMake asset root, source tree assets/, and installed /usr/share/<APP_NAME>/ path.
  • src/app/screen_namager.cpp: switches LVGL screens when the current page subject changes.
  • src/app/desktop_simulator_frame.*: owns the desktop SDL window, renderer, high-resolution shell textures, input, and LVGL texture composition.
  • src/config/lv_conf_desktop.h: desktop LVGL rendering settings.
  • src/config/lv_conf_cm0.h: embedded Linux/CardputerZero LVGL settings.
  • src/platform/linux_input.*: Linux evdev keypad support and desktop SDL keyboard routing for nav buttons.
  • src/reactive/subjects.*: typed wrappers around LVGL subjects.
  • src/reactive/bindings.*: helper bindings for labels, theme, widget values, flags, states, and events.
  • src/view/widgets/navbar.*: bottom navigation bar and icon-button action mapping.
  • src/view/widgets/icon_button.*: transparent icon button with font/color/theme support.

Build Options

Common CMake cache options:

Option Default Description
USE_DESKTOP ON Build SDL desktop simulator when ON; build embedded Linux target when OFF.
APP_NAME zero-music Application name used by installed asset lookup.
APP_ASSETS_ROOT empty Optional runtime asset root. Expected layout includes fonts/, images/, etc.
APP_CONFIG_FILE platform default Optional config path. Defaults to config/template-app.conf for desktop builds and /etc/template-app.conf for device builds.
APP_KEY_INPUT_DEVICE empty Optional Linux evdev device path, e.g. /dev/input/event0. Empty means auto-scan /dev/input/event*.
APP_FRAMEBUFFER_DEVICE /dev/fb0 Linux framebuffer device used by embedded builds when APP_USE_DRM=OFF.
APP_USE_DRM OFF Use LVGL's Linux DRM/KMS backend instead of fbdev for embedded builds.
APP_DRM_DEVICE /dev/dri/card0 DRM device path used when APP_USE_DRM=ON.
APP_DRM_CONNECTOR_ID -1 DRM connector id used when APP_USE_DRM=ON; -1 auto-selects.

Asset lookup order:

  1. APP_ASSETS_ROOT when provided by CMake
  2. source-tree assets/ for development
  3. /usr/share/<APP_NAME>/ for installed deployments

Theme startup behavior is configured in config/template-app.conf:

[application]
dark_mode=yes

Set dark_mode to yes or no. The parser also accepts true/false and 1/0. Installed device builds use /etc/template-app.conf as the system default. Changing the theme from the navigation bar (keyboard shortcut 6) writes a per-user override to $XDG_CONFIG_HOME/template-app/template-app.conf, or ~/.config/template-app/template-app.conf when XDG_CONFIG_HOME is not set. The per-user file takes precedence on the next launch.

Desktop Builds

Desktop builds are intended for fast UI development. LVGL renders at the device-native 320x170 resolution, while SDL composites that texture into a hardware-accelerated, high-DPI simulator window with the full-resolution device shell.

Current dependencies info:

Dependency Version Source Notes
LVGL v9.5.0 CMakeLists.txt FetchContent Main GUI framework.
fmt 12.1.0 System package manager or vcpkg.json override Logging and formatted strings.
libpng 1.6.48 System package manager or vcpkg.json override PNG image decoding support for LVGL.
libjpeg-turbo 3.1.3 System package manager or vcpkg.json override JPEG image decoding support for LVGL.
zlib 1.3.1 System package manager or vcpkg.json override Compression dependency used by image libraries.
SDL2 2.32.54 System package manager or vcpkg.json override Desktop simulator display and input backend.
FreeType 2.13.3 System package manager or vcpkg.json override Runtime TTF font rendering.

Windows vcpkg installs use the versions above through manifest mode, with the registry baseline pinned in vcpkg-configuration.json.

Linux Desktop

Debian/Ubuntu dependencies:

sudo apt update
sudo apt install -y \
  build-essential \
  cmake \
  ninja-build \
  libpng-dev \
  libjpeg-dev \
  libfmt-dev \
  libsdl2-dev \
  libfreetype-dev \
  zlib1g-dev

Note

Minimal CMake version is 3.31.0 (in coordinate with Debian 13 trixie), for Ubuntu user you can install latest cmake via snap and run following cmake command with /snap/bin/cmake.

Configure:

cmake --preset linux-x86-64

Build:

cmake --build --preset linux-x86-64-dbg
# alternatively, you can run release build
# cmake --build --preset linux-x86-64-rel

Run:

./build/linux-x86-64/Debug/zero-music-ui
# or launch release build
# ./build/linux-x86-64/Release/zero-music-ui

macOS Desktop

Install the Apple command-line tools:

xcode-select --install

Install dependencies with Homebrew:

brew install \
  cmake \
  ninja \
  libpng \
  jpeg \
  fmt \
  sdl2 \
  freetype \
  dpkg \
  zlib

Configure for Apple Silicon:

cmake --preset darwin-arm64

Build:

cmake --build --preset darwin-arm64-dbg
# alternatively, you can run release build
# cmake --build --preset darwin-arm64-rel

The build also compiles core/ with Go 1.27 or newer. Configure with -DZERO_MUSIC_BUILD_CORE=OFF to skip it. The UI alone is build/darwin-arm64/Debug/zero-music-ui; from a checkout, run it with the wrapper (packaging/zero-music) so the core starts and stops with it.

Run:

./build/darwin-arm64/Debug/zero-music-ui
# or launch release build
# ./build/darwin-arm64/Release/zero-music-ui

For Intel macOS, use the darwin-x86-64 configure preset and matching build preset:

cmake --preset darwin-x86-64
cmake --build --preset darwin-x86-64-dbg
# alternatively, you can run release build
# cmake --build --preset darwin-x86-64-rel
./build/darwin-x86-64/Debug/zero-music-ui
# or launch release build
# ./build/darwin-x86-64/Release/zero-music-ui

Windows Desktop

Install CMake and Ninja:

winget install Kitware.CMake
winget install Ninja-build.Ninja

Install a C++ toolchain. Choose one of the following.

MSVC Build Tools:

winget install Microsoft.VisualStudio.BuildTools

In the Visual Studio installer, enable Desktop development with C++ and make sure MSVC and a Windows SDK are selected.

MinGW-w64:

winget install BrechtSanders.WinLibs.POSIX.UCRT

Alternatively, you can download from winlibs.

Install vcpkg:

git clone https://github.com/microsoft/vcpkg.git C:\vcpkg
C:\vcpkg\bootstrap-vcpkg.bat -disableMetrics

Configure environmental variables for current terminal:

$env:VCPKG_ROOT="C:\vcpkg"
$env:PATH="$env:VCPKG_ROOT;$env:PATH"

Tip

Change VCPKG_ROOT to your vcpkg installation directory if it is located elsewhere.

These environment variables are session-scoped, meaning they only apply to the current terminal session. Once the terminal is closed, the variables will be lost and need to be set again in a new session. If you want to a persist environment variable

setx VCPKG_ROOT "C:\vcpkg"

Configure and build with MSVC:

Important

These steps require launching CMake from a Developer Command Prompt or Developer PowerShell provided by Visual Studio.

This ensures that the MSVC environment (compiler, linker, and Windows SDK paths) is properly initialized.

Without this environment setup, CMake may fail to detect or correctly configure the MSVC toolchain.

cmake --preset win32-msvc
cmake --build --preset win32-msvc-dbg
.\build\msvc\Debug\zero-music-ui.exe

# alternatively for release build
# cmake --build --preset win32-msvc-rel
# .\build\msvc\Release\zero-music-ui.exe

Configure and build with MinGW-w64:

Important

These steps require a properly configured MinGW-w64 toolchain in your system PATH.

Please ensure the following compilers are available in the current terminal session:

  • gcc
  • g++
  • ld
  • ar

You can verify the setup by running:

gcc --version
g++ --version

If these commands are not recognized, you must add MinGW-w64 bin directory to your PATH before configuring CMake.

cmake --preset win32-mingw64
cmake --build --preset win32-mingw64-dbg
.\build\mingw64\Debug\zero-music-ui.exe

# alternatively for release build
# cmake --build --preset win32-mingw64-rel
#.\build\mingw64\Release\zero-music-ui.exe

Note

VCPKG will handle the dependencies during CMake configuration process automatically, this may take several minutes depend on you network connection.

CardputerZero Cross Build

This preset builds an aarch64 Linux target from a host machine with an aarch64-linux-gnu-gcc/g++ toolchain. The BSP at .cache/sdk_bsp-src is treated as a sysroot: headers, libraries, startup objects, and pkg-config metadata are resolved from that directory first. If that directory does not exist on the first configure, the toolchain downloads and extracts sdk_bsp.tar.gz automatically before CMake runs compiler checks.

Install a cross compile toolchain:

  • Debian
sudo apt install crossbuild-essential-arm64
  • MacOS
brew install aarch64-unknown-linux-gnu

Note

On Windows, it's recommended to use WSL for cross build or you can download cross compile tools and configure the PATH yourself

Configure:

cmake --preset cp0-cross

Build:

cmake --build --preset cp0-cross-dbg
# or release build
# cmake --build --preset cp0-cross-rel

Deploy the release package to your device after filling in your device user and IP:

REMOTE_USER=<user> REMOTE_HOST=<device-ip> ./deploy.sh

By default, the debian package is copied to '$HOME' folder, normally it's under '/home/<user>'.

On your device, install the copied package with apt and replace the package file name with the one you copied:

sudo apt install --no-install-recommends ./zero-music_1.0.0_rev1_arm64.deb

Development Guide

Navigation Keys

The first page bottom nav bar maps hardware/keyboard keys from left to right:

Key Nav item
4 First icon button
5 Second icon button
6 Third icon button
7 Fourth icon button
8 Fifth icon button
ESC First icon button / quit

The counter page uses direct keyboard shortcuts:

Key Action
ESC Return to the first page
Left Decrease the counter
Right Increase the counter

Adding a Screen

  1. Add a new page enum value in src/model/base_model.h.
  2. Add the page transition/state logic in BaseModel and BaseViewModel.
  3. Create a screen under src/view/screens/ deriving from BaseScreen.
  4. Extend ScreenManager to load the new screen when the page subject changes.
  5. Update NavBar icons and callbacks as needed.

Adding a Widget

  1. Derive from BaseWidgets.
  2. Implement build() and create LVGL objects under parent_.
  3. Use reactive::bind_* helpers for text, style, state, or event bindings.
  4. Keep LVGL observer lifetimes object-bound whenever possible with lv_subject_add_observer_obj or reactive::observe_obj.

Fonts and Assets

Device builds use Noto Sans CJK Medium for the default bold text and Noto Sans CJK Regular for regular-weight text. They are loaded through FreeType from:

/usr/share/fonts/opentype/noto/NotoSansCJK-Medium.ttc
/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc

When either system font is unavailable, the UI falls back to LVGL's built-in Montserrat fonts. Desktop builds always use the fallback fonts. Runtime icon and other asset fonts remain under:

assets/fonts/
/usr/share/<APP_NAME>/fonts/

You can also provide an asset root at configure time:

cmake --preset darwin-arm64 -DAPP_ASSETS_ROOT=/path/to/assets

Debian Package

Debian packages are produced with CPack and written to dist/. The package file name follows:

<AppName>_<Version>_<Revision>_arm64.deb

Default example:

dist/zero-music_1.0.0_rev1_arm64.deb

Package layout:

Path Content
/usr/bin/zero-music Application executable.
/etc/template-app.conf System-default application settings, including the startup theme.
/usr/share/zero-music/ Runtime assets: fonts, images, audio.
/usr/share/APPLaunch/applications/zero-music.desktop APPLaunch launcher entry.
/usr/share/APPLaunch/share/images/zero-music*.png APPLaunch launcher icons/fallbacks.
/usr/lib/systemd/system/zero-music.service Optional systemd service for embedded autostart.
/usr/share/doc/zero-music/ README and third-party asset license notes.

Build and package:

cmake --preset cp0-cross
cmake --build --preset cp0-cross-rel
cpack --preset cp0-cross-deb

Or run the full configure, release build, and package flow with one workflow preset:

cmake --workflow --preset cp0-cross-package

Note

Use Debian based Linux host with CPack generator as other OS may not resolve the dependencies correctly no full dpkg, dpkg-shlibdeps, objdump and readelf support

Contributing

If you have better framework designs on Embedded Linux or build system practice, feel free to let us know.

License

Zero Music is distributed as a combined work under the GNU Affero General Public License, version 3 only (AGPL-3.0-only). The full license text is in LICENSE.

Why "only": the project includes code adapted from MyGo Music, which is offered under AGPL-3.0. This project therefore does not claim a later-version option for the combined work. The C++/LVGL application began from CardputerZero/Template; those MIT licensed portions retain their MIT notices.

Third-party components and their licenses are recorded in THIRD_PARTY_LICENSES.md, NOTICE, and assets/fonts/LICENSE.txt.

If you distribute a binary, you must also make the complete corresponding source available under the AGPL. Keep the source in a public repository and offer it from the same place as the binary.

About

Zero Music: local music and MyGo Music-compatible plugins for Cardputer Zero

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages