Fully automatic 5.1 mastering pipeline for localhost deployment
mastering-app/
├── backend/
│ └── main.py # FastAPI server (entry point)
├── core/
│ └── pipeline/
│ ├── base.py # Pipeline stage interface
│ ├── manager.py # Pipeline orchestrator
│ ├── stage_01_analysis.py
│ ├── stage_02_track_cut.py
│ ├── stage_03_stem_sep.py
│ ├── stage_04_upmix.py
│ ├── stage_05_studio_chain.py
│ ├── stage_06_loudness.py
│ └── stage_07_encode.py
├── config/
│ └── constants.py # Configuration & presets
├── frontend/
│ ├── index.html
│ ├── css/
│ │ └── styles.css
│ └── js/
│ ├── app.js # Main entry point
│ ├── api.js # HTTP client
│ ├── pipeline.js # Pipeline UI
│ ├── tuning.js # Studio tuning
│ └── export.js # Export manager
├── output/ # Generated files
├── temp/ # Processing temp files
├── uploads/ # Uploaded audio files
├── requirements.txt
└── start.bat
This codebase follows DOGE Mode engineering principles:
- Zero-Defect Code — Full implementations, no placeholders
- Hardware-First Reasoning — Memory-aware processing, GPU optimization
- Engineering Minimalism — Single responsibility modules (<500 lines)
- Fail-Fast Policy — Immediate error reporting with fallbacks
- Modular Architecture — Separation of concerns (config/core/services)
- Python 3.10+ (64-bit)
- FFmpeg (for audio processing)
- 8+ GB RAM (16 GB recommended)
- NVIDIA GPU (optional, for GPU acceleration)
-
Clone or download this repository
-
Install Python dependencies:
pip install -r requirements.txt
-
Install FFmpeg (if not already installed):
- Windows: Download from ffmpeg.org, extract, add
bin/to PATH - macOS:
brew install ffmpeg - Linux:
sudo apt install ffmpeg
- Windows: Download from ffmpeg.org, extract, add
-
Install Demucs (for stem separation):
pip install -U demucs
Option 1: Use the startup script (Windows)
start.batOption 2: Manual start
python backend\main.pyOption 3: With uvicorn directly
uvicorn backend.main:app --host 127.0.0.1 --port 8000 --reloadOpen your browser to:
http://127.0.0.1:8000
| Stage | Name | Processing | Resources |
|---|---|---|---|
| 01 | Input Preparation & Analysis | Resample, normalize, spectral scan, true-peak detection | CPU, ~0.5 GB RAM |
| 02 | Track Cutting | RMS envelope, silence detection, zero-crossing alignment | CPU, ~1 GB RAM |
| 03 | Stem Separation | Demucs v4 htdemucs_6s, 6 stems, GPU accelerated | GPU (6-8 GB VRAM), ~6 GB RAM |
| 04 | 5.1 Upmix | Channel assignment, pan law, LFE crossover | CPU, ~4 GB RAM |
| 05 | Studio Chain | Console emulation, tape, bus comp, EQ, exciter | CPU, ~5 GB RAM |
| 06 | Loudness Normalization | EBU R128, integrated LUFS, true-peak | CPU, ~2 GB RAM |
| 07 | Encode & Export | 6-ch WAV, AC-3, DTS, metadata embed | CPU, ~3 GB RAM |
Access via ⚙ Studio Tuning button (top-right):
- Genre Presets: Pop, Rock, Electronic, Jazz, Hip-Hop, Cinematic
- Analog Color: Tape saturation, harmonic drive, console emulation
- Dynamics: Bus compression, transient punch, parallel crush
- Tonal Shape: Low-end punch, mid presence, air/sparkle
- 5.1 Spatial: Stereo width, rear depth, room reverb, LFE crossover
Files are organized by playback destination:
- 🗄 Archival — Lossless masters for studio handoff
- 🚗 Car Audio — Dolby AC-3 / DTS for head units
- 🎧 Headphones — Binaural HRTF renders for IEMs
- 🎵 Fan Downloads — FLAC/MP3 for Bandcamp stores
- 📡 Streaming — Stereo downmix for DSPs
| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Serve frontend |
GET |
/api/status |
Get pipeline status |
GET |
/api/hardware |
Get hardware utilization |
POST |
/api/upload |
Upload audio file |
POST |
/api/configure |
Configure pipeline |
POST |
/api/studio-config |
Set studio tuning |
POST |
/api/studio-preset/{name} |
Apply studio preset |
POST |
/api/run |
Start pipeline |
POST |
/api/abort |
Abort running pipeline |
GET |
/api/export/{session_id} |
Get exported files |
GET |
/api/download/{session_id}/{filename} |
Download file |
GET |
/api/download-archive/{session_id} |
Download ZIP archive |
Edit config/constants.py to customize:
# Audio defaults
DEFAULT_SAMPLE_RATE = 48000
DEFAULT_BIT_DEPTH = 24
DEFAULT_TARGET_LUFS = -23.0 # EBU R128
DEFAULT_TRUE_PEAK_LIMIT = -1.0 # dBTP
DEFAULT_LFE_CROSSOVER = 80 # Hz
# Server
HOST = "127.0.0.1"
PORT = 8000
MAX_UPLOAD_SIZE_MB = 500- Ensure FFmpeg is installed and in your system PATH
- Restart terminal after adding to PATH
- Verify with:
ffmpeg -version
- Reduce batch size or use CPU mode
- Close other GPU applications
- Use smaller stem model:
htdemucs_ft
- Kill existing process:
taskkill /F /IM python.exe - Or change port in
backend/main.py
- GPU acceleration requires NVIDIA GPU with 6+ GB VRAM
- CPU-only mode is significantly slower for stem separation
- Ensure adequate RAM (16 GB recommended)
Following DOGE Mode standards:
- Files < 500 lines — Refactor if larger
- Functions < 50 lines — Extract complex logic
- Single responsibility — Each module does ONE thing well
- No placeholders — Full implementations only
- Comments for WHY — Code explains what, comments explain why
- Added "Abort Processing" Button: Implemented a backend-cancellable
asynciotask and a red UI button to safely stop long-running stem separation mid-process. - Improved "Export All" ZIP Logic: Refactored the archive download to use blob-based fetching and dynamic naming (
{song_name}_Master.zip). - Critical DSP Fixes: Resolved bass pumping (bus comp sidechain HPF @ 150Hz), removed de-esser "robotic" distortion, and fixed phase cancellation in shelving EQs.
- Retuned Hip-Hop Presets: Adjusted
hiphopandspotify_hiphopto reduce aggressive ducking and soften harsh clap transients. - Added Spotify Genre Presets: Pop, Hip-Hop, R&B, and Rock configurations targeting Spotify LUFS/TP standards.
- FLAC Lossless Output Support: Native 5.1 FLAC export with dynamic range preservation.
MIT License — See LICENSE file
Built with:
- FastAPI — Modern Python web framework
- Demucs — State-of-the-art music source separation
- FFmpeg — Audio processing powerhouse
- PyTorch — GPU-accelerated tensor operations
Last Updated: March 24, 2026
Version: 1.1.0