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.
MP3(compressed, ID3 metadata, bitrate-aware)WAV(uncompressed, high sample-rate/bit-depth support)
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
- Parse
dj_config.txtinto tracks and playlists. DJLibraryServicecreates canonical track objects (single source of truth).DJSessionorchestrates playlist playback requests.DJControllerServicechecksLRUCacheby track title.- On cache miss, clone from library and insert (evict LRU if full).
- On cache hit, promote entry to MRU.
- Controller provides a clone to
MixingEngineService. - Mixer loads inactive deck, applies BPM sync, and performs transition.
- Previous deck unloads safely and releases resources.
Coordinates parsing, control flow, error handling, and service interactions.
- Owns canonical
AudioTrackobjects. - Parses/constructs
MP3TrackandWAVTrackpolymorphically.
- Simulates limited device memory.
- Manages cached
CacheSlotentries. - Evicts and destroys least-recently-used entries safely.
- Simulates Deck A/Deck B behavior.
- Supports instant transition policy.
- Performs BPM compatibility checks and tempo sync.
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.
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.
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.
- 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.
- GCC/G++ (
C++11or newer) make- Optional:
valgrind
make releaseDebug build:
make debugInteractive mode:
./bin/dj_manager -IAutomatic mode (sequential playlist processing):
./bin/dj_manager -I -Amake test-leaksImplemented by Noam Sannanes