A Python pipeline that converts audio files to MIDI format optimized for organ music, using Demucs for audio separation and BasicPitch for transcription.
- Audio Separation: Uses Demucs to separate vocals and instrumental parts
- MIDI Transcription: Converts audio to MIDI using BasicPitch
- Organ Optimization: Maps tracks to organ channels (Great, Swell, Pedal)
- UV Package Management: Uses UV for fast dependency management
-
Install UV (if not already installed):
curl -LsSf https://astral.sh/uv/install.sh | sh -
Install dependencies:
make install # or uv sync -
Add your audio file to the
originals/directory:cp /path/to/your/audio.mp3 originals/your_song.mp3
Run the pipeline:
# Using default file (originals/mrbrightside.mp3)
make run
# Or specify a different file
uv run python pipeline.py originals/your_song.mp3This will:
- Separate the audio file into 4 stems using Demucs (drums, bass, vocals, other)
- Save separated audio files to
stems/<song_name>/directory - Transcribe each stem to MIDI using BasicPitch
- Save individual MIDI files to
midi_files/<song_name>/directory - Merge the MIDI files with organ channel mapping
- Output final
midi_files/<song_name>/combined.mid
After running the pipeline, you'll get:
midi_files/<song_name>/combined.mid- Final merged MIDI file optimized for organ
stems/<song_name>/<song_name>_drums.wav- Separated drums audiostems/<song_name>/<song_name>_bass.wav- Separated bass audiostems/<song_name>/<song_name>_vocals.wav- Separated vocals audiostems/<song_name>/<song_name>_other.wav- Separated other instruments audiomidi_files/<song_name>/drums.mid- MIDI transcription of drumsmidi_files/<song_name>/bass.mid- MIDI transcription of bassmidi_files/<song_name>/vocals.mid- MIDI transcription of vocalsmidi_files/<song_name>/other.mid- MIDI transcription of other instruments
The generated MIDI file will have:
- Channel 0 (Pedal): Drums - Bass drum sounds
- Channel 1 (Pedal): Bass - Acoustic bass sounds
- Channel 2 (Swell): Vocals - Piano sounds in melody range
- Channel 3 (Great): Other - Piano sounds for accompaniment
- demucs==4.0.0
- basic-pitch==0.3.0
- torch
- torchaudio
- mido
- pretty_midi