A Python-based DJ Mixer application for playback on multiple sound devices. This mixer supports loading audio files, controlling volume levels, crossfading between tracks, and managing playback across different audio outputs.
- Multi-Device Audio Support: Play audio on different sound devices simultaneously
- PyAudio with ASIO Support: Professional audio interface integration with low-latency ASIO drivers
- Audio Format Support: Compatible with MP3, WAV, OGG, FLAC, and other common formats
- Crossfading: Smooth transitions between tracks with adjustable crossfader
- Volume Control: Independent volume control per track plus master volume
- Real-time Mixing: Live control over playback and mixing parameters
- Graphical User Interface: Professional DJ mixer GUI with visual controls
- Command-Line Interface: Interactive CLI for easy mixer control
- Mock Testing: Test functionality without audio hardware
- 🤖 AI-Powered Features:
- Auto Mixing: Intelligent track analysis and automated crossfader transitions
- Key Mixing: Harmonic key analysis and compatibility recommendations
- Fader Effects: Smart effect suggestions based on track energy and context
- Gemini API Integration: Configure with your own API key for advanced AI features
- Clone the repository:
git clone https://github.com/GizzZmo/DJ.git
cd DJ- Install dependencies:
pip install -r requirements.txtNote: For the GUI interface, tkinter is required. On most systems it's included with Python. If not available:
# Ubuntu/Debian
sudo apt-get install python3-tk
# Other systems may require different packagesStart the visual DJ mixer:
python dj_gui.pyThe GUI provides:
- Dual Deck Controls: Load and control two audio tracks independently
- Visual Crossfader: Smooth transitions with real-time position display
- Volume Sliders: Individual track volumes and master volume control
- Playback Controls: Play, pause, stop buttons for each deck
- File Browser: Easy track loading with standard file dialogs
- Status Monitor: Real-time display of mixer status and track information
- 🤖 AI Assistant: Configure Gemini API for intelligent mixing features
- Auto Mixing: Start AI-powered automatic transitions between tracks
- Key Analysis: Get harmonic compatibility advice for smooth mixing
- Fader Effects: AI-suggested effects based on track characteristics
Start the interactive DJ mixer:
python dj_cli.pyBasic commands:
DJ> init # Initialize the mixer
DJ> list # Show audio files in current directory
DJ> load deck1 song1.mp3 # Load a track to deck1
DJ> load deck2 song2.wav # Load a track to deck2
DJ> play deck1 # Play deck1
DJ> volume deck1 0.8 # Set deck1 volume to 80%
DJ> crossfader 0.3 # Set crossfader position
DJ> cross deck1 deck2 # Apply crossfader between decks
DJ> status # Show mixer status
DJ> help # Show all available commands
The DJ Mixer now includes intelligent AI-powered mixing capabilities:
from ai_dj_assistant import AIDJAssistant
# Initialize AI assistant
ai = AIDJAssistant()
# Configure with Gemini API key (optional - works in mock mode without)
ai.configure_gemini("your-gemini-api-key")
# Analyze tracks for intelligent mixing
analysis = ai.analyze_track("deck1", "house_track.mp3")
print(f"Track: {analysis.tempo} BPM, Key: {analysis.key}, Energy: {analysis.energy}")
# Get AI mixing advice
advice = ai.get_auto_mixing_advice("deck1", "deck2")
print(f"Suggested crossfader position: {advice.crossfader_position}")
# Check harmonic compatibility
key_advice = ai.get_key_mixing_advice("deck1", "deck2")
print(f"Key compatibility: {key_advice['compatibility']}")
# Start automated mixing
ai.start_auto_mixing("deck1", "deck2")- Auto Mixing: Analyzes tempo, key, and energy to create smooth transitions
- Key Mixing: Provides harmonic compatibility analysis using music theory
- Fader Effects: Suggests optimal effects based on track characteristics
- Mock Mode: Full functionality without requiring API key for testing
Run the mock test to verify functionality:
python test_mixer.pyTest the GUI functionality:
python test_gui.pyRun the example demo:
python example.pyFor detailed examples and audio file information:
python example.py --infoDJ/
├── dj_mixer.py # Core DJ mixer functionality
├── dj_gui.py # Graphical user interface with AI integration
├── dj_cli.py # Interactive command-line interface
├── ai_dj_assistant.py # AI-powered mixing assistant with Gemini API
├── test_mixer.py # Mock testing without audio hardware
├── test_gui.py # GUI functionality tests
├── test_ai_assistant.py # AI assistant functionality tests
├── demo_ai_features.py # Demo of AI capabilities
├── example.py # Example usage and demos
├── requirements.txt # Python dependencies (includes google-generativeai)
└── README.md # This file
The DJ Mixer includes a professional graphical interface built with tkinter that provides visual control over all mixer functions:
- Professional Layout: Traditional DJ mixer design with dual decks and central crossfader
- File Management: Easy track loading through standard file dialogs
- Visual Feedback: Real-time status updates and visual indicators
- Touch-Friendly Controls: Large buttons and sliders for easy operation
- Status Monitoring: Comprehensive display of mixer state and track information
- Initialize Button: Start the audio mixer system
- Load Track Buttons: Browse and load audio files for each deck
- Playback Controls: Play, pause, and stop buttons for each deck
- Volume Sliders: Independent volume control for each track and master output
- Crossfader Slider: Smooth balance control between left and right decks
- Apply Crossfader: Apply the crossfader effect to the loaded tracks
- Status Panel: Real-time display of mixer status, track info, and system messages
The mixer supports two audio backend modes:
- Simple and portable audio playback
- Works out of the box on most systems
- Good for basic DJ functionality
- Limited device control
- Full control over audio devices
- ASIO driver support for professional audio interfaces
- Low-latency audio processing
- Multi-device routing capabilities
- Ideal for professional DJ setups
from enhanced_mixer import EnhancedDJMixer
# Use PyAudio with default output device
mixer = EnhancedDJMixer(use_pyaudio=True)
mixer.initialize()
# Use PyAudio with ASIO preference (professional audio interfaces)
mixer = EnhancedDJMixer(use_pyaudio=True, use_asio=True)
mixer.initialize()
# List available ASIO devices
asio_devices = mixer.get_asio_devices()
for device in asio_devices:
print(f"{device.name} - {device.host_api}")
# Use specific device by index
mixer = EnhancedDJMixer(use_pyaudio=True)
mixer.initialize(device_index=2)python demo_pyaudio_asio.pyThis demo showcases:
- Standard PyAudio mode with default output
- ASIO mode with professional audio interfaces
- Device enumeration and selection
- Comparison between pygame and PyAudio modes
- Main Output: Primary speakers or PA system
- Headphone Output: DJ monitoring and cueing
- Recording Output: For recording or broadcasting
- Additional Outputs: Extra zones or devices
- Multi-channel Interfaces: Support for professional DJ controllers with multiple outputs
- Position 0.0: Full left deck, right deck silent
- Position 0.5: Both decks at equal volume (center)
- Position 1.0: Full right deck, left deck silent
- Track Volume: Individual volume for each loaded track
- Master Volume: Global volume affecting all outputs
- Crossfader: Relative volume control between two specific tracks
If you encounter audio initialization errors:
- Check audio system availability:
# On Linux, check ALSA/PulseAudio
pulseaudio --check -v
# Test pygame audio
python -c "import pygame; pygame.mixer.init(); print('Audio OK')"- Use mock testing mode:
python test_mixer.py- Install audio dependencies:
# Ubuntu/Debian
sudo apt-get install python3-pygame libasound2-dev
# Other systems may require different audio libraries- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Commit changes:
git commit -am 'Add feature' - Push to branch:
git push origin feature-name - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Python 3.9+ (Note: Python 3.8 is not supported due to google-generativeai dependency)
- pygame >= 2.5.0
- pydub >= 0.25.1
- google-generativeai >= 0.3.0 (for AI features)
To enable full AI features:
- Get a Gemini API key from Google AI Studio
- In the GUI, enter your API key in the "AI DJ Assistant" section
- Click "Configure AI" to enable intelligent mixing
The AI assistant works in mock mode without an API key for testing and development.
- 5-Band Equalizer: Low, Mid-Low, Mid, Mid-High, High frequency control
- Filters: Low-pass, High-pass, Band-pass with adjustable cutoff and resonance
- Reverb: Room size, damping, wet/dry mix controls
- Effect Presets: Bass boost, Treble boost, Vocal enhance, Club sound, Telephone effect
- See
audio_effects.pyfor full implementation
- BPM Detection: Automatic tempo analysis
- Beat Grid: Quantized beat positions for precise mixing
- Auto-Sync: Calculate tempo adjustments needed to sync tracks
- Beat Matching: Find optimal mix points based on beat alignment
- See
beat_detection.pyfor full implementation
- Device Detection: Automatic MIDI device enumeration
- Flexible Mapping: Map any MIDI control to mixer functions
- Controller Presets: Generic DJ, Pioneer DDJ, Traktor Kontrol
- Real-time Control: Live MIDI input processing
- Mock Mode: Test without hardware
- See
midi_controller.pyfor full implementation
- Multi-Format Export: WAV, MP3, OGG, FLAC support
- Live Recording: Capture mixer output in real-time
- Audio Processing: Normalization, splitting, concatenation
- Configurable Quality: Sample rate, bit depth, and format options
- See
recording.pyfor full implementation
- Create and Organize: Multiple playlists with metadata
- Import/Export: M3U playlist support
- Smart Filtering: Filter by BPM, key, genre
- Auto-Sorting: Sort by title, artist, BPM
- Navigation: Next/previous track with looping
- See
playlist_manager.pyfor full implementation
- Waveform Generation: Create visual waveforms from audio
- Frequency Spectrum: Real-time spectrum analysis
- Peak Detection: Identify transients and beats
- Zoom and Scroll: Navigate through long tracks
- Caching: Efficient waveform storage and retrieval
- See
waveform_display.pyfor full implementation
- REST API: Full mixer control via HTTP endpoints
- WebSocket: Real-time status updates
- Modern UI: Responsive HTML/CSS/JavaScript interface
- Remote Control: Control mixer from any device on network
- Live Monitoring: Real-time track and mixer status
- See
web_interface.pyfor full implementation
from enhanced_mixer import EnhancedDJMixer
# Create enhanced mixer with all features
mixer = EnhancedDJMixer()
mixer.initialize()
# Load tracks with beat analysis
mixer.load_track("deck1", "track1.mp3", analyze_beats=True)
mixer.load_track("deck2", "track2.mp3", analyze_beats=True)
# Apply audio effects
mixer.enable_track_effects("deck1", True)
mixer.set_track_eq("deck1", low=1.5, mid=1.0, high=1.2)
mixer.set_track_filter("deck1", "lowpass", cutoff_freq=800.0)
mixer.set_track_reverb("deck1", room_size=0.6, wet_level=0.3)
# Check beat sync
sync_info = mixer.sync_tracks("deck1", "deck2")
print(f"BPM difference: {sync_info['tempo_ratio']}")
# Start recording
mixer.start_recording("my_mix.wav")
# Connect MIDI controller
mixer.connect_midi()
# Create and use playlist
playlist = mixer.create_playlist("My Set")
mixer.load_playlist_track("deck1", 0)
# Get comprehensive status
status = mixer.get_mixer_status()from web_interface import DJMixerWebServer, create_web_templates
from test_mixer import MockDJMixer
# Create web templates (only need to do once)
create_web_templates()
# Initialize mixer
mixer = MockDJMixer()
mixer.initialize()
# Start web server
server = DJMixerWebServer(mixer, port=5000)
server.start()
# Open http://localhost:5000 in your browser# Run comprehensive demo of all features
python demo_features.py
# Run individual feature tests
python test_features.py
# Run enhanced mixer demo
python enhanced_mixer.pyfrom audio_effects import AudioEffects, EffectsPresets
effects = AudioEffects(sample_rate=44100)
# Apply preset
preset = EffectsPresets.club_sound()
effects.set_eq(**preset['eq'])
effects.set_reverb(**preset['reverb'])
# Process audio
processed_audio = effects.process(audio_data)from beat_detection import BeatDetector, AutoSync
detector = BeatDetector(sample_rate=44100)
beat_info = detector.detect_beats(audio_data, duration=180.0)
print(f"BPM: {beat_info.bpm}")
print(f"Confidence: {beat_info.confidence}")
print(f"Beats: {len(beat_info.beat_positions)}")
# Auto-sync two tracks
auto_sync = AutoSync()
timing = auto_sync.suggest_mix_timing(beat1, beat2, current_position=30.0)from midi_controller import MIDIController
midi = MIDIController()
midi.connect() # Connect to first available device
# Map controls
midi.add_mapping(0, MIDIControlType.FADER, "crossfader", 0.0, 1.0)
midi.add_mapping(1, MIDIControlType.KNOB, "volume", 0.0, 1.0)
# Register callbacks
midi.register_callback("crossfader", lambda v: mixer.set_crossfader(v))
midi.register_callback("volume", lambda v: mixer.set_track_volume("deck1", v))
# Start listening
midi.start_listening()Run the comprehensive test suite:
# Test all new features
python -m pytest test_features.py -v
# Test original functionality
python test_mixer.py
# Run all tests
python -m pytest -vDJ/
├── dj_mixer.py # Core DJ mixer functionality
├── enhanced_mixer.py # 🆕 Enhanced mixer with all features
├── dj_gui.py # Graphical user interface
├── dj_cli.py # Interactive command-line interface
├── ai_dj_assistant.py # AI-powered mixing assistant
├── audio_effects.py # 🆕 Real-time audio effects (EQ, filters, reverb)
├── beat_detection.py # 🆕 Beat detection and auto-sync
├── midi_controller.py # 🆕 MIDI controller support
├── recording.py # 🆕 Recording and export functionality
├── playlist_manager.py # 🆕 Playlist management
├── waveform_display.py # 🆕 Waveform visualization
├── web_interface.py # 🆕 Web-based interface (Flask + WebSocket)
├── demo_features.py # 🆕 Comprehensive feature demonstrations
├── test_features.py # 🆕 Test suite for new features
├── test_mixer.py # Mock testing without audio hardware
├── test_gui.py # GUI functionality tests
├── test_ai_assistant.py # AI assistant functionality tests
├── example.py # Example usage and demos
└── requirements.txt # Python dependencies (updated)
- Python 3.9+ (Note: Python 3.8 is not supported due to google-generativeai dependency)
- pygame >= 2.5.0
- pydub >= 0.25.1
- numpy >= 1.24.0 🆕
- flask >= 2.3.0 🆕
- flask-socketio >= 5.3.0 🆕
- flask-cors >= 4.0.0 🆕
- mido >= 1.3.0 🆕
- python-rtmidi >= 1.5.0 🆕
- google-generativeai >= 0.3.0 (for AI features)
Real-time audio effects (EQ, filters, reverb)✅ IMPLEMENTEDMIDI controller support✅ IMPLEMENTEDRecording and export functionality✅ IMPLEMENTEDWeb-based interface✅ IMPLEMENTED- Advanced device routing with PyAudio/ASIO (In Progress)
Beat detection and auto-sync✅ IMPLEMENTEDPlaylist management✅ IMPLEMENTEDVisual waveform display✅ IMPLEMENTED- Integration of all features into main GUI
- Hardware acceleration for real-time effects
- VST plugin support