Java Code Examples for javax.sound.midi.MidiFileFormat#getResolution()

The following examples show how to use javax.sound.midi.MidiFileFormat#getResolution() . 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: StandardMidiFileReader.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public Sequence getSequence(InputStream stream) throws InvalidMidiDataException, IOException {
    SMFParser smfParser = new SMFParser();
    MidiFileFormat format = getMidiFileFormatFromStream(stream,
                                                        MidiFileFormat.UNKNOWN_LENGTH,
                                                        smfParser);

    // must be MIDI Type 0 or Type 1
    if ((format.getType() != 0) && (format.getType() != 1)) {
        throw new InvalidMidiDataException("Invalid or unsupported file type: "  + format.getType());
    }

    // construct the sequence object
    Sequence sequence = new Sequence(format.getDivisionType(), format.getResolution());

    // for each track, go to the beginning and read the track events
    for (int i = 0; i < smfParser.tracks; i++) {
        if (smfParser.nextTrack()) {
            smfParser.readTrack(sequence.createTrack());
        } else {
            break;
        }
    }
    return sequence;
}
 
Example 2
Source File: StandardMidiFileReader.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public Sequence getSequence(InputStream stream) throws InvalidMidiDataException, IOException {
    SMFParser smfParser = new SMFParser();
    MidiFileFormat format = getMidiFileFormatFromStream(stream,
                                                        MidiFileFormat.UNKNOWN_LENGTH,
                                                        smfParser);

    // must be MIDI Type 0 or Type 1
    if ((format.getType() != 0) && (format.getType() != 1)) {
        throw new InvalidMidiDataException("Invalid or unsupported file type: "  + format.getType());
    }

    // construct the sequence object
    Sequence sequence = new Sequence(format.getDivisionType(), format.getResolution());

    // for each track, go to the beginning and read the track events
    for (int i = 0; i < smfParser.tracks; i++) {
        if (smfParser.nextTrack()) {
            smfParser.readTrack(sequence.createTrack());
        } else {
            break;
        }
    }
    return sequence;
}
 
Example 3
Source File: StandardMidiFileReader.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public Sequence getSequence(InputStream stream) throws InvalidMidiDataException, IOException {
    SMFParser smfParser = new SMFParser();
    MidiFileFormat format = getMidiFileFormatFromStream(stream,
                                                        MidiFileFormat.UNKNOWN_LENGTH,
                                                        smfParser);

    // must be MIDI Type 0 or Type 1
    if ((format.getType() != 0) && (format.getType() != 1)) {
        throw new InvalidMidiDataException("Invalid or unsupported file type: "  + format.getType());
    }

    // construct the sequence object
    Sequence sequence = new Sequence(format.getDivisionType(), format.getResolution());

    // for each track, go to the beginning and read the track events
    for (int i = 0; i < smfParser.tracks; i++) {
        if (smfParser.nextTrack()) {
            smfParser.readTrack(sequence.createTrack());
        } else {
            break;
        }
    }
    return sequence;
}
 
Example 4
Source File: StandardMidiFileReader.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public Sequence getSequence(InputStream stream) throws InvalidMidiDataException, IOException {
    SMFParser smfParser = new SMFParser();
    MidiFileFormat format = getMidiFileFormatFromStream(stream,
                                                        MidiFileFormat.UNKNOWN_LENGTH,
                                                        smfParser);

    // must be MIDI Type 0 or Type 1
    if ((format.getType() != 0) && (format.getType() != 1)) {
        throw new InvalidMidiDataException("Invalid or unsupported file type: "  + format.getType());
    }

    // construct the sequence object
    Sequence sequence = new Sequence(format.getDivisionType(), format.getResolution());

    // for each track, go to the beginning and read the track events
    for (int i = 0; i < smfParser.tracks; i++) {
        if (smfParser.nextTrack()) {
            smfParser.readTrack(sequence.createTrack());
        } else {
            break;
        }
    }
    return sequence;
}
 
Example 5
Source File: StandardMidiFileReader.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public Sequence getSequence(InputStream stream) throws InvalidMidiDataException, IOException {
    SMFParser smfParser = new SMFParser();
    MidiFileFormat format = getMidiFileFormatFromStream(stream,
                                                        MidiFileFormat.UNKNOWN_LENGTH,
                                                        smfParser);

    // must be MIDI Type 0 or Type 1
    if ((format.getType() != 0) && (format.getType() != 1)) {
        throw new InvalidMidiDataException("Invalid or unsupported file type: "  + format.getType());
    }

    // construct the sequence object
    Sequence sequence = new Sequence(format.getDivisionType(), format.getResolution());

    // for each track, go to the beginning and read the track events
    for (int i = 0; i < smfParser.tracks; i++) {
        if (smfParser.nextTrack()) {
            smfParser.readTrack(sequence.createTrack());
        } else {
            break;
        }
    }
    return sequence;
}
 
Example 6
Source File: StandardMidiFileReader.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
@Override
public Sequence getSequence(InputStream stream) throws InvalidMidiDataException, IOException {
    SMFParser smfParser = new SMFParser();
    MidiFileFormat format = getMidiFileFormatFromStream(stream,
                                                        MidiFileFormat.UNKNOWN_LENGTH,
                                                        smfParser);

    // must be MIDI Type 0 or Type 1
    if ((format.getType() != 0) && (format.getType() != 1)) {
        throw new InvalidMidiDataException("Invalid or unsupported file type: "  + format.getType());
    }

    // construct the sequence object
    Sequence sequence = new Sequence(format.getDivisionType(), format.getResolution());

    // for each track, go to the beginning and read the track events
    for (int i = 0; i < smfParser.tracks; i++) {
        if (smfParser.nextTrack()) {
            smfParser.readTrack(sequence.createTrack());
        } else {
            break;
        }
    }
    return sequence;
}
 
Example 7
Source File: StandardMidiFileReader.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Sequence getSequence(InputStream stream) throws InvalidMidiDataException, IOException {
    SMFParser smfParser = new SMFParser();
    MidiFileFormat format = getMidiFileFormatFromStream(stream,
                                                        MidiFileFormat.UNKNOWN_LENGTH,
                                                        smfParser);

    // must be MIDI Type 0 or Type 1
    if ((format.getType() != 0) && (format.getType() != 1)) {
        throw new InvalidMidiDataException("Invalid or unsupported file type: "  + format.getType());
    }

    // construct the sequence object
    Sequence sequence = new Sequence(format.getDivisionType(), format.getResolution());

    // for each track, go to the beginning and read the track events
    for (int i = 0; i < smfParser.tracks; i++) {
        if (smfParser.nextTrack()) {
            smfParser.readTrack(sequence.createTrack());
        } else {
            break;
        }
    }
    return sequence;
}
 
Example 8
Source File: StandardMidiFileReader.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public Sequence getSequence(InputStream stream) throws InvalidMidiDataException, IOException {
    SMFParser smfParser = new SMFParser();
    MidiFileFormat format = getMidiFileFormatFromStream(stream,
                                                        MidiFileFormat.UNKNOWN_LENGTH,
                                                        smfParser);

    // must be MIDI Type 0 or Type 1
    if ((format.getType() != 0) && (format.getType() != 1)) {
        throw new InvalidMidiDataException("Invalid or unsupported file type: "  + format.getType());
    }

    // construct the sequence object
    Sequence sequence = new Sequence(format.getDivisionType(), format.getResolution());

    // for each track, go to the beginning and read the track events
    for (int i = 0; i < smfParser.tracks; i++) {
        if (smfParser.nextTrack()) {
            smfParser.readTrack(sequence.createTrack());
        } else {
            break;
        }
    }
    return sequence;
}
 
Example 9
Source File: StandardMidiFileReader.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public Sequence getSequence(InputStream stream) throws InvalidMidiDataException, IOException {
    SMFParser smfParser = new SMFParser();
    MidiFileFormat format = getMidiFileFormatFromStream(stream,
                                                        MidiFileFormat.UNKNOWN_LENGTH,
                                                        smfParser);

    // must be MIDI Type 0 or Type 1
    if ((format.getType() != 0) && (format.getType() != 1)) {
        throw new InvalidMidiDataException("Invalid or unsupported file type: "  + format.getType());
    }

    // construct the sequence object
    Sequence sequence = new Sequence(format.getDivisionType(), format.getResolution());

    // for each track, go to the beginning and read the track events
    for (int i = 0; i < smfParser.tracks; i++) {
        if (smfParser.nextTrack()) {
            smfParser.readTrack(sequence.createTrack());
        } else {
            break;
        }
    }
    return sequence;
}
 
Example 10
Source File: StandardMidiFileReader.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public Sequence getSequence(InputStream stream) throws InvalidMidiDataException, IOException {
    SMFParser smfParser = new SMFParser();
    MidiFileFormat format = getMidiFileFormatFromStream(stream,
                                                        MidiFileFormat.UNKNOWN_LENGTH,
                                                        smfParser);

    // must be MIDI Type 0 or Type 1
    if ((format.getType() != 0) && (format.getType() != 1)) {
        throw new InvalidMidiDataException("Invalid or unsupported file type: "  + format.getType());
    }

    // construct the sequence object
    Sequence sequence = new Sequence(format.getDivisionType(), format.getResolution());

    // for each track, go to the beginning and read the track events
    for (int i = 0; i < smfParser.tracks; i++) {
        if (smfParser.nextTrack()) {
            smfParser.readTrack(sequence.createTrack());
        } else {
            break;
        }
    }
    return sequence;
}
 
Example 11
Source File: StandardMidiFileReader.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public Sequence getSequence(InputStream stream) throws InvalidMidiDataException, IOException {
    SMFParser smfParser = new SMFParser();
    MidiFileFormat format = getMidiFileFormatFromStream(stream,
                                                        MidiFileFormat.UNKNOWN_LENGTH,
                                                        smfParser);

    // must be MIDI Type 0 or Type 1
    if ((format.getType() != 0) && (format.getType() != 1)) {
        throw new InvalidMidiDataException("Invalid or unsupported file type: "  + format.getType());
    }

    // construct the sequence object
    Sequence sequence = new Sequence(format.getDivisionType(), format.getResolution());

    // for each track, go to the beginning and read the track events
    for (int i = 0; i < smfParser.tracks; i++) {
        if (smfParser.nextTrack()) {
            smfParser.readTrack(sequence.createTrack());
        } else {
            break;
        }
    }
    return sequence;
}
 
Example 12
Source File: StandardMidiFileReader.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public Sequence getSequence(InputStream stream) throws InvalidMidiDataException, IOException {
    SMFParser smfParser = new SMFParser();
    MidiFileFormat format = getMidiFileFormatFromStream(stream,
                                                        MidiFileFormat.UNKNOWN_LENGTH,
                                                        smfParser);

    // must be MIDI Type 0 or Type 1
    if ((format.getType() != 0) && (format.getType() != 1)) {
        throw new InvalidMidiDataException("Invalid or unsupported file type: "  + format.getType());
    }

    // construct the sequence object
    Sequence sequence = new Sequence(format.getDivisionType(), format.getResolution());

    // for each track, go to the beginning and read the track events
    for (int i = 0; i < smfParser.tracks; i++) {
        if (smfParser.nextTrack()) {
            smfParser.readTrack(sequence.createTrack());
        } else {
            break;
        }
    }
    return sequence;
}
 
Example 13
Source File: StandardMidiFileReader.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public Sequence getSequence(InputStream stream) throws InvalidMidiDataException, IOException {
    SMFParser smfParser = new SMFParser();
    MidiFileFormat format = getMidiFileFormatFromStream(stream,
                                                        MidiFileFormat.UNKNOWN_LENGTH,
                                                        smfParser);

    // must be MIDI Type 0 or Type 1
    if ((format.getType() != 0) && (format.getType() != 1)) {
        throw new InvalidMidiDataException("Invalid or unsupported file type: "  + format.getType());
    }

    // construct the sequence object
    Sequence sequence = new Sequence(format.getDivisionType(), format.getResolution());

    // for each track, go to the beginning and read the track events
    for (int i = 0; i < smfParser.tracks; i++) {
        if (smfParser.nextTrack()) {
            smfParser.readTrack(sequence.createTrack());
        } else {
            break;
        }
    }
    return sequence;
}
 
Example 14
Source File: StandardMidiFileReader.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public Sequence getSequence(InputStream stream) throws InvalidMidiDataException, IOException {
    SMFParser smfParser = new SMFParser();
    MidiFileFormat format = getMidiFileFormatFromStream(stream,
                                                        MidiFileFormat.UNKNOWN_LENGTH,
                                                        smfParser);

    // must be MIDI Type 0 or Type 1
    if ((format.getType() != 0) && (format.getType() != 1)) {
        throw new InvalidMidiDataException("Invalid or unsupported file type: "  + format.getType());
    }

    // construct the sequence object
    Sequence sequence = new Sequence(format.getDivisionType(), format.getResolution());

    // for each track, go to the beginning and read the track events
    for (int i = 0; i < smfParser.tracks; i++) {
        if (smfParser.nextTrack()) {
            smfParser.readTrack(sequence.createTrack());
        } else {
            break;
        }
    }
    return sequence;
}