Java Code Examples for javax.sound.midi.MidiSystem#write()

The following examples show how to use javax.sound.midi.MidiSystem#write() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SequencerState.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a new InputStream containing a Sequence for testing.
 *
 * @return an InputStream containing a dummy Sequence, or null, if a problem
 *         occured while creating the InputStream
 */
private static InputStream createSequenceInputStream() {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Sequence sequence = createSequence();
    if (sequence == null) {
        return null;
    }
    try {
        MidiSystem.write(sequence, 0, baos);
        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        return bais;
    } catch (IOException e) {
        return null;
    }
}
 
Example 2
Source File: MidiSequenceBuilder.java    From mpcmaid with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void save(File file) throws IOException {
	MidiSystem.write(sequence, 0, file);
}