This tool processes MP3 files by separating them into stems (drums, bass, vocals, and other) and converting each stem into MIDI format. It uses Demucs for stem separation and Basic-Pitch for audio-to-MIDI conversion.
- Separates audio files into four stems:
- Drums
- Bass
- Vocals
- Other instruments
- Converts each stem to MIDI
- Creates a combined MIDI file with appropriate instrument assignments
- Organizes output in a clear folder structure
- Python 3.7+
- Basic-Pitch CLI tool
- Required Python packages (install via requirements.txt):
- torch
- demucs
- midiutil
- mido
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install required packages:
pip install -r requirements.txt
-
Download the Basic-Pitch CLI tool:
pip install basic-pitch
-
Place your MP3 files in the
data/directory -
Run the script:
python stem_and_convert_new_mp3s.py
-
Find the processed files in the
out/directory. Each processed song will have its own folder containing:- Separated audio stems (WAV format)
- Individual MIDI files for each stem
- Combined MIDI file with appropriate instrument assignments
out/ song_name/ drums.wav drums_basic_pitch.mid bass.wav bass_basic_pitch.mid vocals.wav vocals_basic_pitch.mid other.wav other_basic_pitch.mid combined.mid
The combined MIDI file uses the following channel assignments:
- Drums: Channel 10 (standard MIDI drum channel)
- Bass: Channel 1 (Electric Bass)
- Vocals: Channel 2 (Voice Oohs)
- Other: Channel 3 (Acoustic Grand Piano)
- The script only processes new MP3 files that haven't been processed before
- Existing output files will not be overwritten unless the processing is forced
- Processing time depends on the length of the audio files and your computer's specifications