You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importosimportpy_midicsvaspm#MIDI folderfile_list=os.listdir(r"midi")
#Custom Pathpath=''#Create folders where to save filestry:
os.mkdir(path+"csv")
os.mkdir(path+"mid")
exceptOSError:
print ("Creation of the directory %s failed"%path)
else:
print ("Successfully created the directory %s"%path)
forfile_name_songinfile_list:
name_file_without_ext=file_name_song.rsplit('.', 1)[0]
# Load the MIDI file and parse it into CSV formatcsv_string=pm.midi_to_csv("midi/"+name_file_without_ext+".mid")
withopen("csv/"+name_file_without_ext+".csv", "w") asf:
f.writelines(csv_string)
# Parse the CSV output of the previous command back into a MIDI filemidi_object=pm.csv_to_midi(csv_string)
# Save the parsed MIDI file to diskwithopen("mid/"+name_file_without_ext+".mid", "wb") asoutput_file:
midi_writer=pm.FileWriter(output_file)
midi_writer.write(midi_object)
print("processed file name:",file_name_song)
The text was updated successfully, but these errors were encountered:
You are free to implement whatever process you like using this library, so this is as valid as any other purpose one might use this code for.
When it comes to batch-processing stuff (and potentially splitting MIDI files into their channels and tracks), I have a related project which may be interesting here.
As far as this library goes: It's a library. It's not intended to do any specific task like processing a folder full of files in a specific way. It simply provides some primitives so you can build whatever you like.
Thank you for sharing this either way, maybe somebody else will come across this in the future and find it useful.
Tree project
Implementation
The text was updated successfully, but these errors were encountered: