Search code examples
pythonaudiomidimusic21

How to save output in music21 as a MIDI file?


How do I save audio output in Python using the music21 module? I have read the entire [user's guide](http://music21.readthedocs.org/en/latest/usersGuide/index.html] of said module, but I couldn't find any information about saving output as an audio file that can be recognised by windows without any additional software (MIDI for example).


Solution

  • If s is your Stream, just call:

    fp = s.write('midi', fp='pathToWhereYouWantToWriteIt')

    or to hear it immediately

    s.show('midi')