Skip to content

Instantly share code, notes, and snippets.

@TAbdiukov
Created April 1, 2019 00:18
Show Gist options
  • Save TAbdiukov/ee81283d547441a8aaeeefb9718bd8be to your computer and use it in GitHub Desktop.
Save TAbdiukov/ee81283d547441a8aaeeefb9718bd8be to your computer and use it in GitHub Desktop.
wraps up midi2audio
#pip install midi2audio
from midi2audio import FluidSynth
import os, sys, string
from pathlib import Path
def main():
PROGRAM_NAME = "midi2audio_wrap"
if len(sys.argv) < 3: #-1
print("USAGE: python "+PROGRAM_NAME+".py <file.mid(i)> <target_format>")
print("For example: python "+PROGRAM_NAME+".py 1270.mid FLAC")
else:
# get midi name
input = str(sys.argv[1])
target = str(sys.argv[2]).lower().split(".")[-1]
file = Path(input)
fs = FluidSynth()
# Path of file for object copy (ambiguous behaviour in Python pathlib)
#print(file.resolve())
#print(Path(file).with_suffix("."+target).resolve())
fs.midi_to_audio(file.resolve(), (Path(file).with_suffix("."+target).resolve()))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment