Python tool for pitch-shifting MP3 files to MIDI files.
- Clone the GitHub repo to your computer with
git clone https://github.com/sonofthomp/midi-harmonizer.git
. Runcd midi-harmonizer
to enter the directory. - Install the package requirements with
pip install -r requirements.txt
- The harmonization happens in two steps. First, generate a "tone file" -- this will be an MP3 file which you should use a guide to sing the melody of the song to. You can generate this with:
python3 gen_tone.py <path to MIDI file, should end with .mid> <path you want the tone outputted to, should end with .mp3>
- Record yourself singing along to the "tone file" generated from the MIDI file. Store this in a file somewhere on your computer and take note of its location.
- From the same directory as the cloned repo, run
python3 gen_harmonies.py <path to MIDI file, should end with .mid> <path to you singing, should end with .mp3> <path you want the pitch-corrected version outputed to, should end with .mp3>
- "The Longest Time" (Billy Joel)
- "Nobody Loves You Like Me" (Jonathan Coulton)
- "Auld Lang Syne" (traditional)
- "Doin' it Right" (Daft Punk)
- "Hide and Seek" (Imogen Heap)
- "Lift Every Voice And Sing" (James Weldon Johnson and J. Rosamond Johnson)
- "The Wellerman" (traditional, arr. The Longest Johns)
The algorithm used for pitch-shifting is called PSOLA, specifically Max Morrison's Python implementation of it. The program first reads a MIDI file and extracts the note times from it, then groups these into separate vocal tracks, and then pitch-corrects the MP3 file to each track using the PSOLA library. These harmonized tracks are then summed and the result is outputted to an MP3 file.