Here you can find the source of saveMidiFile(Sequence sequence, String filename)
Sequence
to a file.
Parameter | Description |
---|---|
sequence | The <code>Sequence</code> to save. |
filename | The path to the file to save to. Relative paths are relative to the program's running directory. |
Parameter | Description |
---|---|
IOException | If there was a problem saving the file. |
public static void saveMidiFile(Sequence sequence, String filename) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.IOException; import javax.sound.midi.MidiSystem; import javax.sound.midi.Sequence; public class Main { /**//w ww . ja v a 2s . c o m * Saves a <code>Sequence</code> to a file. * * @param sequence The <code>Sequence</code> to save. * @param filename The path to the file to save to. Relative paths are * relative to the program's running directory. * @throws IOException If there was a problem saving the file. */ public static void saveMidiFile(Sequence sequence, String filename) throws IOException { int[] fileTypes = MidiSystem.getMidiFileTypes(sequence); File file = new File(filename); MidiSystem.write(sequence, fileTypes[0], file); } }