Read, Write

Read a MIDI or XML File into a Score

You can read a MIDI file into your program using the Read.midi() function.  Similarly, you can read an XML file into your program using the Read.xml() function  Either function expects an empty score and the name of a MIDI (or XML) file.

This file should be stored in the same folder as your program.

For example,

inputs the musical data from the MIDI file “song.mid”, and stores them into score. Once the file has been read in, then you can manipulate or playback the score. For example,

A Score created from an external MIDI (or XML) file may not be as nicely structured (in terms of Parts, Phrases, and Notes) as a Score created manually through your program.  However, you can still use Score.getPartList(), Part.getPhraseList(), and Phrase.getNoteList() to extract its musical material, and use it as you see fit.

Function Description
Read.midi(score, file) Reads musical material from the MIDI file into the score.
Read.xml(score, file) Reads musical material from the XML file into the score.

 

Write a Score to a MIDI or XML File

You can create a MIDI file from your program using the Write.midi() function. Similarly, you can create an XML file from your program using the Write.xml() function. Either function expects the musical material (Score, Part, Phrase, or Note) and a file name.

This file is saved in the same folder as your program. If a file with that name already exists, it will be overwritten.

For example,

writes the musical material into the MIDI file called “song.mid”.

Function Description
Write.midi(material, file) Writes musical material (Score, Part, Phrase, or Note) into the MIDI file. If the file exists it will be overwritten.
Write.xml(material, file) Writes musical material (Score, Part, Phrase, or Note) into the XML file. If the file exists it will be overwritten.