HyperMusic: Navigate your music collection as a graph of interconnected phrases. DJ-oriented music navigation and performance system for macOS.
Primary Focus: MusicMill's HyperMusic system transforms your music collection into a navigable graph of interconnected musical phrases. Instead of playing songs linearly, you can branch between compatible phrases from different tracks, enabling seamless DJ-style transitions across your entire collection.
Core Concept: Music is analyzed and broken into structural phrases (intro, verse, chorus, drop, outro). Each phrase is connected to compatible phrases from other tracks based on musical similarity (tempo, key, energy, spectral characteristics). Navigate the graph to create unique mixes that flow naturally between tracks.
-
Analysis: Your music collection is analyzed to extract:
- Musical phrases/segments (detected via structure analysis)
- Tempo (BPM) and key information
- Energy levels and spectral characteristics
- Beat grids and downbeat positions
- RGB waveforms for visual feedback
-
Graph Construction: Phrases are connected into a weighted graph where edges represent musical compatibility:
- Tempo compatibility: Same BPM, half-time, or double-time relationships
- Key compatibility: Same key, relative major/minor, or circle of fifths neighbors
- Energy matching: Similar energy levels or complementary builds/drops
- Spectral similarity: Timbral matching via spectral centroid
-
Navigation: Play songs normally or tap any compatible phrase to branch to a different track:
- Same Track Sequential: Gapless playback within the same song
- Cross-Track Transition: Switch to compatible phrases from other tracks at phrase boundaries
- Beat-aligned cuts: (Future) Immediate transitions synchronized to beats
- Phrase Graph Analysis: Analyzes music collection and builds navigable phrase graph
- Musical Compatibility Scoring: Links phrases based on tempo, key, energy, and spectral similarity
- Graph Navigation Interface: Visual timeline with branch options to compatible phrases
- Dual-Deck DJ Controls: Professional mixing interface with cue/preview deck
- RGB Waveform Display: DJ-style waveform visualization (bass/mid/high frequencies)
- Beat Grid Visualization: Shows beat positions and phrase boundaries
- Phrase Boundary Transitions: Smooth switching between tracks at phrase boundaries
- Persistent Graph Storage: Saves phrase graph to disk for fast loading
- ML Classification: Style/genre classification models (early experiments)
- Granular Synthesis: Real-time grain-based audio generation (experimental)
- RAVE Neural Synthesis: Deep learning audio generation via PyTorch MPS (research)
- Real-time Generative Synthesis: Generate new audio based on style/tempo/energy controls (future)
- DRM-protected files (Apple Music M4A) cannot be analyzed
- Beat-aligned immediate cuts not yet implemented (phrase boundary transitions work)
- DJ-style transitions (crossfade, EQ swap, filter sweep) reserved for future implementation
The HyperMusic system consists of three main components:
-
Analysis Pipeline (
scripts/analyze_library.py,scripts/build_phrase_graph.py):- Scans music collection for audio files (MP3, AAC, WAV, AIFF, M4A)
- Extracts musical phrases/segments via structure analysis
- Computes tempo, key, energy, spectral features, and beat grids
- Builds weighted phrase graph with compatibility links
- Generates RGB waveforms for visual display
-
Phrase Database (
MusicMill/Analysis/PhraseDatabase.swift):- Manages phrase graph persistence (JSON format)
- Provides graph queries (find compatible phrases, get links, etc.)
- Handles graph loading and caching
-
Playback & Performance Interface (
MusicMill/Performance/HyperPhraseView.swift,MusicMill/Generation/HyperPhrasePlayer.swift):- Graph-aware playback engine with phrase navigation
- Dual-deck DJ interface with cue/preview capabilities
- Real-time waveform visualization
- Transition engine (reserved for future DJ-style transitions)
- macOS 13.0 or later
- Xcode 14.0 or later
- Swift 5.9 or later
- M3 Mac (optimized for Apple Silicon)
MusicMill/
├── MusicMill/
│ ├── App/ # App entry point and main views
│ ├── Analysis/ # Audio analysis and phrase graph
│ │ ├── PhraseDatabase.swift # Graph data model and queries
│ │ ├── FeatureExtractor.swift # Tempo, key, energy, spectral features
│ │ ├── StructureAnalyzer.swift # Phrase/segment detection
│ │ └── ...
│ ├── Generation/ # Playback engines
│ │ ├── HyperPhrasePlayer.swift # Graph-aware phrase playback
│ │ ├── TransitionEngine.swift # DJ-style transitions (future)
│ │ └── ...
│ ├── Performance/ # Performance interface
│ │ ├── HyperPhraseView.swift # Main graph navigation UI
│ │ ├── WaveformView.swift # RGB waveform display
│ │ ├── Deck.swift # Dual-deck DJ controls
│ │ └── ...
│ ├── ML/ # ML experiments (classification)
│ └── Training/ # Training UI (for ML models)
├── scripts/
│ ├── analyze_library.py # Music collection analysis
│ ├── build_phrase_graph.py # Phrase graph construction
│ ├── rave_server.py # RAVE inference (experimental)
│ └── ...
├── docs/
│ ├── plans/hypermusic_playback.md # HyperMusic documentation
│ └── ...
└── README.md
-
Analyze Your Collection: Run the analysis script to build the phrase graph:
python3 scripts/analyze_library.py /path/to/your/music/collection python3 scripts/build_phrase_graph.py
-
Open in Xcode: Build and run the MusicMill app
-
Load the Graph: The app will automatically load the phrase graph from
~/Documents/MusicMill/Analysis/ -
Navigate: Use the HyperPhraseView to navigate through your collection as a graph
-
Analyze Library: Run
scripts/analyze_library.pyto extract features from your music collection- Detects phrases/segments, tempo, key, energy, beat grids
- Outputs analysis JSON files
-
Build Graph: Run
scripts/build_phrase_graph.pyto construct the phrase graph- Creates weighted links between compatible phrases
- Generates RGB waveforms for visualization
- Outputs
phrase_graph.json
- Start Playback: The app loads the phrase graph and starts playing from a random phrase
- View Timeline: See the current phrase in the center with compatible branches
- Navigate: Tap any compatible phrase to queue a transition at the next phrase boundary
- DJ Controls: Use dual-deck controls for cue/preview and professional mixing
- Waveform Visualization: Monitor RGB waveforms showing bass/mid/high frequencies
Phrases are linked in the graph based on weighted compatibility scores:
- Tempo Score: Same BPM (±5%), half-time, or double-time relationships
- Key Score: Same key, relative major/minor, or circle of fifths neighbors
- Energy Score: Similar energy levels or complementary builds/drops
- Spectral Score: Timbral matching via spectral centroid similarity
Each link has a total weight (0-1) and suggested transition type (crossfade, EQ swap, cut, filter).
- Style/genre classification using MLSoundClassifier
- Can be used for filtering or organizing phrases by style
- See
MusicMill/ML/for implementation
- Granular Synthesis: Real-time grain-based audio generation (experimental)
- RAVE Neural Synthesis: Deep learning audio generation via PyTorch MPS (research)
- See
docs/RAVE_INTEGRATION.mdfor technical details - Runs at 291x realtime on M3 Max via MPS
- Experimental control mapping: style interpolation, energy scaling, tempo stretching
- See
- Audio Analysis: Uses librosa (Python) for tempo, key, energy, spectral analysis, and phrase detection
- Graph Storage: Phrase graph stored as JSON in
~/Documents/MusicMill/Analysis/ - Playback: AVFoundation for real-time audio playback with phrase boundary detection
- UI: SwiftUI for the performance interface with Combine for reactive updates
- Waveforms: RGB waveform extraction (bass/mid/high frequency bands) for DJ-style visualization
The analysis pipeline generates:
- Per-track analysis: Tempo, key, energy contour, beat grid, phrase boundaries
- Phrase graph: Weighted graph with compatibility links between phrases
- Waveform data: RGB waveforms for visual display (150 points per phrase)
- Metadata: Track names, segment types, time ranges
- Beat-aligned Immediate Cuts: Quick switch mode with beat synchronization
- DJ-style Transitions: Crossfade, EQ swap, filter sweep, echo out
- Transition Controls: Duration selector, transition type, manual crossfader
- Loop Current Phrase: Repeat current phrase for extended mixing
- Relationship Tracking: Learn from your transitions to improve compatibility scoring
- RAVE Training Pipeline: Train custom models on your DJ collection (research)
- ML Classification: Improve style/genre classification for filtering
- Recording and Export: Save HyperMusic navigation sessions as mixes
- MIDI Integration: Map external controllers to graph navigation