MIDI to WAVE - Windows Edition

by tridecagon in Circuits > Microsoft

1327 Views, 4 Favorites, 0 Comments

MIDI to WAVE - Windows Edition

midi_select.jpg

A while ago, I posted a Ubuntu MIDI to WAVE Converter. I have finally sat here and wrote a BATCH script (Windows) that can do the same. It wasn't easy as BATCH is weird. But I finally got it done. So here we go.

Requirements

You will need Zenity and Timidity. I assume you know how to set up Timidity. That is all you need. Well, a text editor, but you should already have that.

The Script

The script, apparently, doesn't support spaces in the filenames. I do not know why, and I do not want to fix it. But take the following code and copy/paste it into your text editor. Make sure to save it with a ".bat" extension under "All Files" or else you will have a text file. I also recommend saving it in its own folder.

|-----EDIT-----|
I have figured out how to fix the problem with spaces not being supported. I have updated the code to include these changes.

@echo off
if exist timidity.txt GOTO get_tdir
zenity --file-selection --directory --title="Directory for timidity.exe" > timidity.txt

:get_tdir
set /p tdir=
for /f "delims=" %%a in ('zenity --file-selection --title="MIDI File"') do @set midi=%%a
start /wait zenity.exe
IF ["%midi%"] == [] GOTO cancelled

for /f "delims=" %%a in ('zenity --file-selection --save --title="Save"') do @set save=%%a
start /wait zenity.exe
IF ["%save%"] == [] GOTO cancelled

cd %tdir%

timidity "%midi%" -Ow -o "%save%".wav | zenity --progress --pulsate
start /wait timidity.exe

zenity --alert --text="Finished Conversion"
start /wait zenity.exe
EXIT

:cancelled
zenity --info --text="Cancelled the Conversion"
start /wait zenity.exe

How to Use the Script

midi_select.jpg
save.jpg
done.jpg
file.jpg

The script requires a text file (.txt)(see below) to operate. When you first run the script, it will ask for where you where timidity.exe. The default location is "C:\timidity". Choose the timidity folder itself. If you installed timidity.exe somewhere else, choose it's folder. The chosen location will then be stored in a text file in the same folder as the script. If you chose the wrong directory, you can edit the text file itself or delete it. The script will always look for this file and create it should it not see it.

When this file exists, it will ask for a MIDI file to convert (I'm not sure if spaces are supported in folder/file names). Upon choosing one, it will ask for where to save the wave file and what to save it as. The ".wav" is appended automagically.