musikcube Documentation

repository·master·Indexed 26 days ago

https://github.com/clangen/musikcube

A cross-platform, terminal-based audio engine, library, player, and server written in C++. Supports Windows, macOS, Linux, and Raspberry Pi. Features include a built-in streaming audio server with WebSocket and HTTP services, a C++ SDK for extensions, MPRIS support for Linux, and remote control via the musikdroid Android application.

Tokens
5.4K
Snippets
9
Records
37
Agent score
89%

What's inside musikcube

  1. Overview of the musikcube server plugin

    master

    The musikcube server plugin acts as a playback remote and streaming audio server. It enables remote control and audio streaming for musikcube instances using WebSockets and vanilla HTTP.

    Supported platforms for the musikcube core include:

    • Windows
    • macOS
    • Linux
    • FreeBSD

    Compatible clients include:

    • musikdroid: An Android-based client implementation.
    • Web-based or custom clients connecting via the Remote API.
  2. Enable MPRIS support on Linux

    master

    The MPRIS support plugin enables a MPRIS D-Bus interface for musikcube on Linux systems. This allows other applications to control musikcube playback via D-Bus.

    Requirement: The system must have systemd available (and consequently libsystemd) for the D-Bus client to function.

  3. Build musikdroid locally

    master

    Since musikdroid uses Fabric.io for crash reporting and the API keys are not included in the repository, you must remove the Fabric dependencies to build the project locally.

    Follow these steps to prepare the project for a local build:

    1. Open Application.kt and remove the line: Fabric.with(this, Crashlytics()).
    2. Open app/build.gradle and remove the line: apply plugin: 'io.fabric'.

    The project is currently built using Android Studio 3.

  4. Install the cross-compile toolchain

    master

    Standard Debian/Ubuntu toolchains often lack full armv6 support. To support older Raspberry Pi devices, use the docker-arm-cross-toolchain from GitHub. This process installs the tools and populates them using the sysroot.tar generated in the previous step.

    1. Navigate to your build directory: cd /build.
    2. Copy your generated sysroot: cp /path/to/generated/sysroot/sysroot.tar ..
    3. Run the installation script: node /build/musikcube/script/install-crosscompile-tools.js.
    cd /build
    cp /path/to/generated/sysroot/sysroot.tar .
    node /build/musikcube/script/install-crosscompile-tools.js
  5. Install musikcube

    master

    musikcube can be installed via pre-compiled binaries from the GitHub releases page or through various package managers depending on your operating system.

    macOS

    Use Homebrew:

    brew install musikcube

    FreeBSD

    Use pkg:

    pkg install musikcube

    OpenBSD

    Use pkg_add:

    pkg_add install musikcube

    Windows

    Use Chocolatey:

    choco install musikcube

    After installation on Windows, you can run the application by typing musikcube or mcube in the Start Menu, using the Win+R dialog, or via a shell.

    brew install musikcube
  6. Build the main musikcube app for Raspberry Pi

    master

    Once dependencies are compiled and the toolchain is installed, build the main application using the standalone archive script. You must specify the target architecture via CROSSCOMPILE and provide the version number as an argument.

    cd /build/musikcube
    CROSSCOMPILE=rpi-armv6 ./script/archive-standalone-nix.sh 3.0.2
  7. Remote control musikcube with musikdroid

    master
    While the main musikcube application runs in the terminal, you can stream audio from and remotely control the engine using the musikdroid Android application. The APK can be downloaded from the project's releases section.
  8. Build PDCurses for WinGUI

    master

    To build PDCurses for the Win32 graphics mode (WinGUI), select the appropriate makefile for your compiler and run the build command.

    Available Makefiles

    • Makefile.bcc: Borland C++ 4.0.2+
    • Makefile.dmc: Digital Mars
    • Makefile.lcc: LCC-Win32
    • Makefile.mng: MinGW, Cygnus GNU Compiler
    • Makefile.vc: Microsoft Visual C++ 2.0+ or later & Intel(R) compiler
    • Makefile.wcc: Watcom 10.6+ or OpenWATCOM

    Build Commands

    Use make -f <makefile> to build. Note that Watcom users should use wmake and MSVC users should use nmake.

    Build Options

    • Wide-character (Unicode) support: Add WIDE=Y.
    • UTF-8 support: Add UTF8=Y (requires WIDE=Y to be set).
    • Build as DLL: Add DLL=Y (supported with Visual C++, MinGW, or Cygwin).
    • 32-bit code (MSVC/Intel): Add IX86=Y (defaults to 64-bit for Makefile.vc).
    • Intel(R) compiler: Use Makefile.vc and add ICC=Y.
    • 64-bit code (Linux cross-compiling): Add _w64=1 (defaults to 32-bit).
  9. Install system dependencies for musikcube build

    master

    To prepare a Debian Buster environment for building musikcube, install the following packages using apt-get:

    sudo apt update
    sudo apt dist-upgrade
    sudo apt install build-essential g++ gcc git libasound2-dev libev-dev libncurses-dev libopus-dev libopus-dev libopus0 libpulse-dev libsndio-dev libssl-dev libsystemd-dev libvorbis-dev libvorbis-dev libvorbis0a libvorbisenc2 portaudio19-dev rpm wget zlib1g-dev libdbus-1-dev libudev-dev libglib2.0-dev patchelf libstdc++6-i386-cross nodejs
    sudo apt update
    sudo apt dist-upgrade
    sudo apt install build-essential g++ gcc git libasound2-dev libev-dev libncurses-dev libopus-dev libopus-dev libopus0 libpulse-dev libsndio-dev libssl-dev libsystemd-dev libvorbis-dev libvorbis-dev libvorbis0a libvorbisenc2 portaudio19-dev rpm wget zlib1g-dev libdbus-1-dev libudev-dev libglib2.0-dev patchelf libstdc++6-i386-cross nodejs
  10. Setup a Raspberry Pi Buster chroot environment

    master

    This guide outlines how to create an architectural chroot environment for faster compilation and deployment on a Raspberry Pi using a Debian Buster ARMHF image. This involves downloading a disk image, expanding its partitions, mounting it via loopback, and using qemu-arm-static to allow execution of ARM binaries on an x86 host.

    1. Install Dependencies

    Install the necessary tools for image manipulation and QEMU emulation:

    sudo apt install qemu-kvm qemu-user-static binfmt-support qemu-utils kpartx e2fsprogs

    2. Prepare the Disk Image

    1. Create a working directory:
      mkdir rpi-buster-chroot
    2. **Download and extract the image:**
       ```bash
    # Download (example URL)
    wget https://downloads.raspberrypi.org/raspios_oldstable_lite_armhf/images/raspios_oldstable_lite_armhf-2023-05-03/2023-05-03-raspios-buster-armhf-lite.img.xz
    
    # Extract
    xz -d -v 2023-05-03-raspios-buster-armhf-lite.img.xz
    1. Expand the image file size:
      qemu-img resize -f raw 2023-05-03-raspios-buster-armhf-lite.img 16G
    4. **Expand the partition within the image:**
       Use `fdisk` to recreate the Linux partition with the new space:
       - `fdisk 2023-05-03-raspios-buster-armhf-lite.img`
       - `p` (Print table; note the 'Start' value of partition #2)
       - `d` (Delete)
       - `2` (Select partition #2)
       - `n` (New)
       - `p` (Primary)
       - `2` (Partition number)
       - `<START_VALUE>` (Enter the start value noted earlier)
       - `<ENTER>` (Accept default end value)
       - `N` (Do **NOT** remove the ext4 signature)
       - `w` (Write changes)
    
    ### 3. Mount and Configure the Chroot
    1. **Mount the partitions:**
       ```bash
    mkdir os-mount
    sudo kpartx -a -v 2023-05-03-raspios-buster-armhf-lite.img
    
    # Identify the mapper device (e.g., /dev/mapper/loop4p2) from kpartx output
    sudo mount /dev/mapper/loop4p2 ./os-mount
    
    # Resize the filesystem to fill the new partition size
    sudo /sbin/resize2fs /dev/mapper/loop4p2
    1. Inject QEMU and bind system directories:
      sudo cp /usr/bin/qemu-arm-static ./os-mount/usr/bin
      sudo mount -o bind /dev ./os-mount/dev
      sudo mount -o bind /proc ./os-mount/proc
      sudo mount -o bind /sys ./os-mount/sys
    3. **Register the ARM interpreter:**
       You must run this as root (not via `sudo` for the echo command to work correctly on the proc filesystem):
       ```bash
    su
    echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm-static:' > /proc/sys/fs/binfmt_misc/register
    exit

    4. Usage and Cleanup

    Enter the chroot:

    sudo chroot ./os-mount /usr/bin/qemu-arm-static /usr/bin/bash
    # If /usr/bin/bash is not found, try:
    # sudo chroot ./os-mount /usr/bin/qemu-arm-static /bin/bash

    Shutdown and Unmount:

    sudo umount ./os-mount/dev
    sudo umount ./os-mount/proc
    sudo umount ./os-mount/sys
    sudo umount ./os-mount
    sudo kpartx -d -v 2023-05-03-raspios-buster-armhf-lite.img
  11. Gather dependencies for Raspberry Pi cross-compilation

    master

    To compile musikcube for Raspberry Pi, you must collect the necessary headers and libraries from a Raspbian Buster environment (either via chroot or a physical device). This process generates a sysroot.tar file used to populate the cross-compile toolchain.

    1. Enter the chroot environment or boot your device.
    2. Update the system: apt-get update and sudo apt-get dist-upgrade.
    3. Navigate to the sysroot directory: cd /build/sysroot.
    4. Run the collection script: node /build/musikcube/script/create-crosscompile-sysroot.js.

    The resulting sysroot.tar file is required for the next step.