Create seamless DJ-style mixes from a folder of audio tracks, mimicking Apple Music's Automix feature with intelligent transitions, tempo matching, and crossfading.
🎵 Smart Track Analysis
- Automatic tempo detection
- Key detection for harmonic mixing
- Energy level analysis
- Spectral feature analysis
🔄 Intelligent Transitions
- Equal-power crossfading
- Tempo adjustment for better transitions
- Track reordering for optimal flow
- Compatibility scoring between tracks
🎛️ Professional Mixing
- Configurable crossfade duration
- Audio normalization
- Support for multiple audio formats
- High-quality output
- Clone or download this script
- Install Python dependencies:
pip install -r requirements.txt
- MP3
- WAV
- FLAC
- M4A
- AAC
- OGG
python automix.py /path/to/your/music/folderpython automix.py /path/to/music -o "my_mix.wav" -c 6.0 -s 48000| Argument | Description | Default |
|---|---|---|
input_folder |
Path to folder containing audio tracks | Required |
-o, --output |
Output filename | automix_output.wav |
-c, --crossfade |
Crossfade duration in seconds | 8.0 |
-s, --sample-rate |
Sample rate for processing | 44100 |
python automix.py ~/Music/MyPlaylistpython automix.py ~/Music/PartyMix -o "party_night_mix.wav" -c 10.0python automix.py ~/Music/ChillOut -o "chill_mix.wav" -c 12.0 -s 48000The script analyzes each track for:
- Tempo (BPM): For beat-matching
- Musical Key: For harmonic compatibility
- Energy Level: For smooth energy transitions
- Spectral Characteristics: For timbral matching
Tracks are automatically reordered using a compatibility algorithm that considers:
- Tempo similarity
- Key relationships (circle of fifths)
- Energy level progression
- Spectral characteristics
- Equal-power crossfading: Maintains consistent volume
- Tempo adjustment: Slight tempo changes for better sync
- Beat alignment: Crossfades happen at musical boundaries
- Audio normalization: Prevents clipping and volume jumps
The script creates:
- A single mixed audio file with all tracks seamlessly blended
- Detailed logging showing the mixing process
- Compatibility scores for each transition
- Use tracks from similar genres for best results
- Ensure good audio quality (avoid heavily compressed files)
- Include 4-8 tracks for optimal mix length
- Similar BPM ranges work best (±20 BPM)
- Tracks in related keys create smoother transitions
- Consider energy progression (start calm, build energy, wind down)
- Short crossfades (4-6s): For energetic, quick mixes
- Long crossfades (10-15s): For ambient, chill mixes
- Higher sample rates: For audiophile-quality output
"No audio files found"
- Check that your folder contains supported audio formats
- Verify folder path is correct
"Error analyzing [filename]"
- File may be corrupted or in unsupported format
- Try with different audio files
Memory issues with large files
- Process smaller batches of tracks
- Use lower sample rates for testing
- Use WAV/FLAC for best quality
- Limit to 10-15 tracks per mix for reasonable processing time
- Close other applications if memory usage is high
- librosa: Audio analysis and processing
- soundfile: Audio file I/O
- numpy: Numerical computations
- scipy: Signal processing
- Feature Extraction: Extract musical features from each track
- Compatibility Matrix: Calculate transition scores between all track pairs
- Optimal Ordering: Use greedy algorithm to find best track sequence
- Crossfade Generation: Create smooth transitions with equal-power curves
- Final Assembly: Combine all tracks with transitions into final mix
This script is provided as-is for educational and personal use. Ensure you have rights to the audio files you're processing.
Feel free to improve the script by:
- Adding more sophisticated beat-matching
- Implementing different crossfade curves
- Adding support for more audio formats
- Improving the track ordering algorithm
Enjoy creating professional-quality mixes with the power of Python! 🎧