o
odinpkg.dev
packages / library / odin-music-player

odin-music-player

5f92e0clibrary

A music player build using odin and miniaudio

No license · updated 11 months ago

Music Player

A simple, modular music player application built as a hobby project. It supports loading songs from a directory, creating playlists, and basic playback controls. Currently, it's designed and tested only for Windows, with potential for cross-platform expansion in the future.

Features

  • Load and display songs from a local folder (MP3 support via backend).
  • Create and manage playlists.
  • Playback controls: play, pause, volume adjustment.
  • ImGui-based UI for intuitive interaction.
  • Modular design: Audio playback is decoupled, allowing swaps to other libraries (e.g., SDL_mixer) without major rewrites.

Tech Stack

This project leverages modern, lightweight tools for efficient development:

  • Odin: The primary programming language, chosen for its simplicity, performance, and ease of use in systems programming. Odin handles the core logic, state management, and integration of all components.
  • ImGui: Used for the user interface, providing immediate-mode GUI that's quick to prototype and responsive. Integrated with GLFW and OpenGL for rendering.
  • OpenGL: Handles graphics rendering, working in tandem with ImGui for drawing the UI.
  • GLFW: Manages window creation, input handling, and the main event loop. It's cross-platform but currently configured for Windows.
  • Miniaudio: The default audio backend for playback and management, selected for its single-header simplicity and no external dependencies. The architecture allows easy replacement with alternatives like Raylib or SDL.
  • Vendor libraries are managed via Odin's built-in vendor system for seamless imports.

As a hobby project, the focus is on learning and experimentation with these technologies, prioritizing clean architecture over full production features.

Requirements

  • Odin programming language (latest version recommended).
  • Vendor libraries (included via Odin's vendor system):
    • GLFW
    • ImGui (with GLFW/OpenGL backend)
    • OpenGL
    • Miniaudio (initial audio backend; can be replaced)
  • Windows SDK (required for building and running on Windows).
  • A music folder with MP3 files for testing.

Building

  1. Clone the repository or set up the project structure as described in the architecture.
  2. Vend the required libraries (e.g., odin vendor collect if using Odin's vendor tool).
  3. Build with Odin:
    odin build main.odin -out:player.exe
    
    • For release: Add -opt:2 -no-bounds-check.
    • To switch audio backends: Use build defines, e.g., -define:AUDIO_BACKEND=SDL (after implementing the backend).

Running

  1. Place your music files in a folder (e.g., path/to/music/folder – update in core/state.odin if needed).
  2. Run the executable:
    <!-- make debug (default)  -->
    make
    make release
    
  3. Use the ImGui window to browse songs, create playlists, and control playback.

Architecture Overview

  • app: Manages app state (songs, playlists) in app/app.odin.
  • Audio: Abstract interface in audio/interface.odin with concrete backends (e.g., miniaudio.odin).
  • UI: ImGui rendering in /imgui_ui.odin.
  • Main: Ties everything together, handles the main loop and state-audio sync.

For details on swapping audio backends or extending features, see the source code comments.

License