CrossFade ML is a Python-based tool for intelligent audio crossfading. It leverages machine learning to predict optimal fade durations between two songs based on their BPM (beats per minute), and applies a smooth crossfade. The project is designed for DJs, audio engineers, and music enthusiasts who want to automate and optimize the process of transitioning between tracks.
- Automatic BPM Detection: Uses signal processing to estimate the BPM of audio tracks.
- Machine Learning Model: Trains a Gradient Boosting Regressor to predict ideal fade durations based on BPM.
- Energy Analysis: Calculates and compares the energy of the output and control tracks.
- Batch Processing: Can process a folder of audio files for model training.
- Crossfade Application: Applies a smooth crossfade between two selected tracks.
project.py: Main script containing all logic for BPM detection, model training, crossfading, and energy analysis.crossfades/: Directory for storing generated crossfaded audio files.edm_hse_id_001-004_wav/: Example folder containing training audio files (WAV format).Output.wav,Control.wav: Example output and control audio files.Output.txt,Control.txt: Text files containing energy values for output and control tracks.
- Python 3.7+
- All Python dependencies are listed in
requirements.txt.
Install dependencies with:
It is recommended to use a virtual environment:
python3 -m venv .venv
source .venv/bin/activate # On Windows use: .venv\Scripts\activate
pip install -r requirements.txt-
Prepare your audio files:
- Place your training WAV files in a folder (e.g.,
edm_hse_id_001-004_wav/). - Place the two songs you want to crossfade (e.g.,
paathshala.wav,sunshine.wav) in the project root. - Place a control track as
Control.wavif you want to compare energy.
- Place your training WAV files in a folder (e.g.,
-
Run the script:
python project.py
This will:
- Train the model on the training folder.
- Predict fade durations for the two selected songs.
- Apply the crossfade and save the result as
Output.wav. - Calculate and save energy values for both the output and control tracks.
-
Check Results:
- Listen to
Output.wavfor the crossfaded result. - Review
Output.txtandControl.txtfor energy analysis.
- Listen to
- To use different songs, change the
song1_pathandsong2_pathvariables inproject.py. - To use a different training folder, change the
folder_pathvariable.
This project is for educational and research purposes. Please ensure you have the rights to use any audio files you process.
Created as part of a project for Techin 513.