Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DJ Track Session Manager

A service-oriented DJ session manager simulation written in C++.

The system emulates backend workflows found in professional DJ software (for example, rekordbox/Serato-style flows): library ownership, hardware-like caching, and two-deck instant transitions.

Supported Formats

  • MP3 (compressed, ID3 metadata, bitrate-aware)
  • WAV (uncompressed, high sample-rate/bit-depth support)

Why This Project

This codebase intentionally avoids STL smart pointers for core ownership paths to demonstrate low-level C++ engineering:

  • Manual memory management with strict ownership boundaries
  • Rule of 5 across polymorphic audio models
  • RAII-based custom pointer wrapper (PointerWrapper<T>)
  • Leak-free object lifecycle across Library, Cache, and Mixer layers

High-Level Flow

  1. Parse dj_config.txt into tracks and playlists.
  2. DJLibraryService creates canonical track objects (single source of truth).
  3. DJSession orchestrates playlist playback requests.
  4. DJControllerService checks LRUCache by track title.
  5. On cache miss, clone from library and insert (evict LRU if full).
  6. On cache hit, promote entry to MRU.
  7. Controller provides a clone to MixingEngineService.
  8. Mixer loads inactive deck, applies BPM sync, and performs transition.
  9. Previous deck unloads safely and releases resources.

Architecture

DJSession (Orchestrator)

Coordinates parsing, control flow, error handling, and service interactions.

DJLibraryService (Canonical Ownership)

  • Owns canonical AudioTrack objects.
  • Parses/constructs MP3Track and WAVTrack polymorphically.

DJControllerService (LRU Cache)

  • Simulates limited device memory.
  • Manages cached CacheSlot entries.
  • Evicts and destroys least-recently-used entries safely.

MixingEngineService (Two-Deck Engine)

  • Simulates Deck A/Deck B behavior.
  • Supports instant transition policy.
  • Performs BPM compatibility checks and tempo sync.

Memory Safety Model

PointerWrapper<T>

Custom RAII wrapper used for cross-service ownership transfer.

  • Copy construction/assignment are deleted.
  • Move semantics enable explicit ownership transfer.
  • Pointer operators (*, ->) provide ergonomic access.
  • release() is used only at clear ownership handoff boundaries.

Rule of 5 + Polymorphic Cloning

Tracks contain heap-allocated waveform-like data. To prevent aliasing/double-free issues:

  • Hierarchy implements virtual clone().
  • Rule of 5 is enforced in relevant classes.
  • Deep copy is guaranteed for duplicated waveform buffers.

Error Handling

Before each transition, the system validates:

  • Configuration integrity
  • Track presence in library
  • Successful clone/load operations

On failure, the session logs an error, skips the faulty track, and continues without corrupting cache/mixer state.

Performance Notes

  • Caching reduces expensive reload and analysis work.
  • Move semantics minimize unnecessary deep copies.
  • Cache lookup is O(n) (array-based design), while deck switch logic remains constant-time in practice.

Memory behavior is validated with Valgrind under load to keep the project leak-free.

Build & Run

Prerequisites

  • GCC/G++ (C++11 or newer)
  • make
  • Optional: valgrind

Build

make release

Debug build:

make debug

Run

Interactive mode:

./bin/dj_manager -I

Automatic mode (sequential playlist processing):

./bin/dj_manager -I -A

Leak Check

make test-leaks

Author

Implemented by Noam Sannanes

About

A high-performance DJ Session Manager simulation in C++, focusing on safe memory management, RAII, custom smart pointers, and LRU caching.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages