Skip to content

koernergb/MP3-to-MIDI

Repository files navigation

Audio Stem Separator and MIDI Converter

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.

Features

  • 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

Prerequisites

  • Python 3.7+
  • Basic-Pitch CLI tool
  • Required Python packages (install via requirements.txt):
    • torch
    • demucs
    • midiutil
    • mido

Installation

  1. Create and activate a virtual environment:

    python -m venv venv
    source venv/bin/activate # On Windows: venv\Scripts\activate
  2. Install required packages:

    pip install -r requirements.txt
  3. Download the Basic-Pitch CLI tool:

    pip install basic-pitch

Usage

  1. Place your MP3 files in the data/ directory

  2. Run the script:

    python stem_and_convert_new_mp3s.py
  3. 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

Output Structure

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

MIDI Channel Assignments

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)

Notes

  • 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published