Java Code Examples for javax.sound.midi.spi.MidiFileWriter#isFileTypeSupported()

The following examples show how to use javax.sound.midi.spi.MidiFileWriter#isFileTypeSupported() . 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: MidiSystem.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Writes a stream of bytes representing a file of the MIDI file type
 * indicated to the external file provided.
 * @param in sequence containing MIDI data to be written to the file
 * @param type the file type of the file to be written to the output stream
 * @param out external file to which the file data should be written
 * @return the number of bytes written to the file
 * @throws IOException if an I/O exception occurs
 * @throws IllegalArgumentException if the file type is not supported by
 * the system
 * @see #isFileTypeSupported(int, Sequence)
 * @see     #getMidiFileTypes(Sequence)
 */
public static int write(Sequence in, int type, File out) throws IOException {

    List providers = getMidiFileWriters();
    //$$fb 2002-04-17: Fix for 4635287: Standard MidiFileWriter cannot write empty Sequences
    int bytesWritten = -2;

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        if( writer.isFileTypeSupported( type, in ) ) {

            bytesWritten = writer.write(in, type, out);
            break;
        }
    }
    if (bytesWritten == -2) {
        throw new IllegalArgumentException("MIDI file type is not supported");
    }
    return bytesWritten;
}
 
Example 2
Source File: MidiSystem.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Writes a stream of bytes representing a file of the MIDI file type
 * indicated to the output stream provided.
 * @param in sequence containing MIDI data to be written to the file
 * @param fileType the file type of the file to be written to the output stream
 * @param out stream to which the file data should be written
 * @return the number of bytes written to the output stream
 * @throws IOException if an I/O exception occurs
 * @throws IllegalArgumentException if the file format is not supported by
 * the system
 * @see #isFileTypeSupported(int, Sequence)
 * @see     #getMidiFileTypes(Sequence)
 */
public static int write(Sequence in, int fileType, OutputStream out) throws IOException {

    List providers = getMidiFileWriters();
    //$$fb 2002-04-17: Fix for 4635287: Standard MidiFileWriter cannot write empty Sequences
    int bytesWritten = -2;

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        if( writer.isFileTypeSupported( fileType, in ) ) {

            bytesWritten = writer.write(in, fileType, out);
            break;
        }
    }
    if (bytesWritten == -2) {
        throw new IllegalArgumentException("MIDI file type is not supported");
    }
    return bytesWritten;
}
 
Example 3
Source File: MidiSystem.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Writes a stream of bytes representing a file of the MIDI file type
 * indicated to the external file provided.
 * @param in sequence containing MIDI data to be written to the file
 * @param type the file type of the file to be written to the output stream
 * @param out external file to which the file data should be written
 * @return the number of bytes written to the file
 * @throws IOException if an I/O exception occurs
 * @throws IllegalArgumentException if the file type is not supported by
 * the system
 * @see #isFileTypeSupported(int, Sequence)
 * @see     #getMidiFileTypes(Sequence)
 */
public static int write(Sequence in, int type, File out) throws IOException {

    List providers = getMidiFileWriters();
    //$$fb 2002-04-17: Fix for 4635287: Standard MidiFileWriter cannot write empty Sequences
    int bytesWritten = -2;

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        if( writer.isFileTypeSupported( type, in ) ) {

            bytesWritten = writer.write(in, type, out);
            break;
        }
    }
    if (bytesWritten == -2) {
        throw new IllegalArgumentException("MIDI file type is not supported");
    }
    return bytesWritten;
}
 
Example 4
Source File: MidiSystem.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Writes a stream of bytes representing a file of the MIDI file type
 * indicated to the external file provided.
 * @param in sequence containing MIDI data to be written to the file
 * @param type the file type of the file to be written to the output stream
 * @param out external file to which the file data should be written
 * @return the number of bytes written to the file
 * @throws IOException if an I/O exception occurs
 * @throws IllegalArgumentException if the file type is not supported by
 * the system
 * @see #isFileTypeSupported(int, Sequence)
 * @see     #getMidiFileTypes(Sequence)
 */
public static int write(Sequence in, int type, File out) throws IOException {

    List providers = getMidiFileWriters();
    //$$fb 2002-04-17: Fix for 4635287: Standard MidiFileWriter cannot write empty Sequences
    int bytesWritten = -2;

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        if( writer.isFileTypeSupported( type, in ) ) {

            bytesWritten = writer.write(in, type, out);
            break;
        }
    }
    if (bytesWritten == -2) {
        throw new IllegalArgumentException("MIDI file type is not supported");
    }
    return bytesWritten;
}
 
Example 5
Source File: MidiSystem.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Writes a stream of bytes representing a file of the MIDI file type
 * indicated to the external file provided.
 * @param in sequence containing MIDI data to be written to the file
 * @param type the file type of the file to be written to the output stream
 * @param out external file to which the file data should be written
 * @return the number of bytes written to the file
 * @throws IOException if an I/O exception occurs
 * @throws IllegalArgumentException if the file type is not supported by
 * the system
 * @see #isFileTypeSupported(int, Sequence)
 * @see     #getMidiFileTypes(Sequence)
 */
public static int write(Sequence in, int type, File out) throws IOException {

    List providers = getMidiFileWriters();
    //$$fb 2002-04-17: Fix for 4635287: Standard MidiFileWriter cannot write empty Sequences
    int bytesWritten = -2;

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        if( writer.isFileTypeSupported( type, in ) ) {

            bytesWritten = writer.write(in, type, out);
            break;
        }
    }
    if (bytesWritten == -2) {
        throw new IllegalArgumentException("MIDI file type is not supported");
    }
    return bytesWritten;
}
 
Example 6
Source File: MidiSystem.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Writes a stream of bytes representing a file of the MIDI file type
 * indicated to the output stream provided.
 * @param in sequence containing MIDI data to be written to the file
 * @param fileType the file type of the file to be written to the output stream
 * @param out stream to which the file data should be written
 * @return the number of bytes written to the output stream
 * @throws IOException if an I/O exception occurs
 * @throws IllegalArgumentException if the file format is not supported by
 * the system
 * @see #isFileTypeSupported(int, Sequence)
 * @see     #getMidiFileTypes(Sequence)
 */
public static int write(Sequence in, int fileType, OutputStream out) throws IOException {

    List providers = getMidiFileWriters();
    //$$fb 2002-04-17: Fix for 4635287: Standard MidiFileWriter cannot write empty Sequences
    int bytesWritten = -2;

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        if( writer.isFileTypeSupported( fileType, in ) ) {

            bytesWritten = writer.write(in, fileType, out);
            break;
        }
    }
    if (bytesWritten == -2) {
        throw new IllegalArgumentException("MIDI file type is not supported");
    }
    return bytesWritten;
}
 
Example 7
Source File: MidiSystem.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Writes a stream of bytes representing a file of the MIDI file type
 * indicated to the external file provided.
 * @param in sequence containing MIDI data to be written to the file
 * @param type the file type of the file to be written to the output stream
 * @param out external file to which the file data should be written
 * @return the number of bytes written to the file
 * @throws IOException if an I/O exception occurs
 * @throws IllegalArgumentException if the file type is not supported by
 * the system
 * @see #isFileTypeSupported(int, Sequence)
 * @see     #getMidiFileTypes(Sequence)
 */
public static int write(Sequence in, int type, File out) throws IOException {

    List providers = getMidiFileWriters();
    //$$fb 2002-04-17: Fix for 4635287: Standard MidiFileWriter cannot write empty Sequences
    int bytesWritten = -2;

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        if( writer.isFileTypeSupported( type, in ) ) {

            bytesWritten = writer.write(in, type, out);
            break;
        }
    }
    if (bytesWritten == -2) {
        throw new IllegalArgumentException("MIDI file type is not supported");
    }
    return bytesWritten;
}
 
Example 8
Source File: MidiSystem.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Writes a stream of bytes representing a file of the MIDI file type
 * indicated to the output stream provided.
 * @param in sequence containing MIDI data to be written to the file
 * @param fileType the file type of the file to be written to the output stream
 * @param out stream to which the file data should be written
 * @return the number of bytes written to the output stream
 * @throws IOException if an I/O exception occurs
 * @throws IllegalArgumentException if the file format is not supported by
 * the system
 * @see #isFileTypeSupported(int, Sequence)
 * @see     #getMidiFileTypes(Sequence)
 */
public static int write(Sequence in, int fileType, OutputStream out) throws IOException {

    List providers = getMidiFileWriters();
    //$$fb 2002-04-17: Fix for 4635287: Standard MidiFileWriter cannot write empty Sequences
    int bytesWritten = -2;

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        if( writer.isFileTypeSupported( fileType, in ) ) {

            bytesWritten = writer.write(in, fileType, out);
            break;
        }
    }
    if (bytesWritten == -2) {
        throw new IllegalArgumentException("MIDI file type is not supported");
    }
    return bytesWritten;
}
 
Example 9
Source File: MidiSystem.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Writes a stream of bytes representing a file of the MIDI file type
 * indicated to the external file provided.
 * @param in sequence containing MIDI data to be written to the file
 * @param type the file type of the file to be written to the output stream
 * @param out external file to which the file data should be written
 * @return the number of bytes written to the file
 * @throws IOException if an I/O exception occurs
 * @throws IllegalArgumentException if the file type is not supported by
 * the system
 * @see #isFileTypeSupported(int, Sequence)
 * @see     #getMidiFileTypes(Sequence)
 */
public static int write(Sequence in, int type, File out) throws IOException {

    List providers = getMidiFileWriters();
    //$$fb 2002-04-17: Fix for 4635287: Standard MidiFileWriter cannot write empty Sequences
    int bytesWritten = -2;

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        if( writer.isFileTypeSupported( type, in ) ) {

            bytesWritten = writer.write(in, type, out);
            break;
        }
    }
    if (bytesWritten == -2) {
        throw new IllegalArgumentException("MIDI file type is not supported");
    }
    return bytesWritten;
}
 
Example 10
Source File: MidiSystem.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Writes a stream of bytes representing a file of the MIDI file type
 * indicated to the output stream provided.
 * @param in sequence containing MIDI data to be written to the file
 * @param fileType the file type of the file to be written to the output stream
 * @param out stream to which the file data should be written
 * @return the number of bytes written to the output stream
 * @throws IOException if an I/O exception occurs
 * @throws IllegalArgumentException if the file format is not supported by
 * the system
 * @see #isFileTypeSupported(int, Sequence)
 * @see     #getMidiFileTypes(Sequence)
 */
public static int write(Sequence in, int fileType, OutputStream out) throws IOException {

    List providers = getMidiFileWriters();
    //$$fb 2002-04-17: Fix for 4635287: Standard MidiFileWriter cannot write empty Sequences
    int bytesWritten = -2;

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        if( writer.isFileTypeSupported( fileType, in ) ) {

            bytesWritten = writer.write(in, fileType, out);
            break;
        }
    }
    if (bytesWritten == -2) {
        throw new IllegalArgumentException("MIDI file type is not supported");
    }
    return bytesWritten;
}
 
Example 11
Source File: MidiSystem.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Writes a stream of bytes representing a file of the MIDI file type
 * indicated to the output stream provided.
 * @param in sequence containing MIDI data to be written to the file
 * @param fileType the file type of the file to be written to the output stream
 * @param out stream to which the file data should be written
 * @return the number of bytes written to the output stream
 * @throws IOException if an I/O exception occurs
 * @throws IllegalArgumentException if the file format is not supported by
 * the system
 * @see #isFileTypeSupported(int, Sequence)
 * @see     #getMidiFileTypes(Sequence)
 */
public static int write(Sequence in, int fileType, OutputStream out) throws IOException {

    List providers = getMidiFileWriters();
    //$$fb 2002-04-17: Fix for 4635287: Standard MidiFileWriter cannot write empty Sequences
    int bytesWritten = -2;

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        if( writer.isFileTypeSupported( fileType, in ) ) {

            bytesWritten = writer.write(in, fileType, out);
            break;
        }
    }
    if (bytesWritten == -2) {
        throw new IllegalArgumentException("MIDI file type is not supported");
    }
    return bytesWritten;
}
 
Example 12
Source File: MidiSystem.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Indicates whether file writing support for the specified MIDI file type
 * is provided by the system.
 *
 * @param  fileType the file type for which write capabilities are queried
 * @return {@code true} if the file type is supported, otherwise
 *         {@code false}
 */
public static boolean isFileTypeSupported(int fileType) {

    List<MidiFileWriter> providers = getMidiFileWriters();

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = providers.get(i);
        if( writer.isFileTypeSupported(fileType)) {
            return true;
        }
    }
    return false;
}
 
Example 13
Source File: MidiSystem.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Indicates whether file writing support for the specified MIDI file type
 * is provided by the system.
 * @param fileType the file type for which write capabilities are queried
 * @return <code>true</code> if the file type is supported,
 * otherwise <code>false</code>
 */
public static boolean isFileTypeSupported(int fileType) {

    List providers = getMidiFileWriters();

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        if( writer.isFileTypeSupported(fileType)) {
            return true;
        }
    }
    return false;
}
 
Example 14
Source File: MidiSystem.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Indicates whether file writing support for the specified MIDI file type
 * is provided by the system.
 * @param fileType the file type for which write capabilities are queried
 * @return <code>true</code> if the file type is supported,
 * otherwise <code>false</code>
 */
public static boolean isFileTypeSupported(int fileType) {

    List providers = getMidiFileWriters();

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        if( writer.isFileTypeSupported(fileType)) {
            return true;
        }
    }
    return false;
}
 
Example 15
Source File: MidiSystem.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Indicates whether a MIDI file of the file type specified can be written
 * from the sequence indicated.
 * @param fileType the file type for which write capabilities
 * are queried
 * @param sequence the sequence for which file writing support is queried
 * @return <code>true</code> if the file type is supported for this
 * sequence, otherwise <code>false</code>
 */
public static boolean isFileTypeSupported(int fileType, Sequence sequence) {

    List providers = getMidiFileWriters();

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        if( writer.isFileTypeSupported(fileType,sequence)) {
            return true;
        }
    }
    return false;
}
 
Example 16
Source File: MidiSystem.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Indicates whether file writing support for the specified MIDI file type
 * is provided by the system.
 * @param fileType the file type for which write capabilities are queried
 * @return <code>true</code> if the file type is supported,
 * otherwise <code>false</code>
 */
public static boolean isFileTypeSupported(int fileType) {

    List providers = getMidiFileWriters();

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        if( writer.isFileTypeSupported(fileType)) {
            return true;
        }
    }
    return false;
}
 
Example 17
Source File: MidiSystem.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Indicates whether a MIDI file of the file type specified can be written
 * from the sequence indicated.
 * @param fileType the file type for which write capabilities
 * are queried
 * @param sequence the sequence for which file writing support is queried
 * @return <code>true</code> if the file type is supported for this
 * sequence, otherwise <code>false</code>
 */
public static boolean isFileTypeSupported(int fileType, Sequence sequence) {

    List providers = getMidiFileWriters();

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        if( writer.isFileTypeSupported(fileType,sequence)) {
            return true;
        }
    }
    return false;
}
 
Example 18
Source File: MidiSystem.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Indicates whether a MIDI file of the file type specified can be written
 * from the sequence indicated.
 * @param fileType the file type for which write capabilities
 * are queried
 * @param sequence the sequence for which file writing support is queried
 * @return <code>true</code> if the file type is supported for this
 * sequence, otherwise <code>false</code>
 */
public static boolean isFileTypeSupported(int fileType, Sequence sequence) {

    List providers = getMidiFileWriters();

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        if( writer.isFileTypeSupported(fileType,sequence)) {
            return true;
        }
    }
    return false;
}
 
Example 19
Source File: MidiSystem.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Indicates whether file writing support for the specified MIDI file type
 * is provided by the system.
 * @param fileType the file type for which write capabilities are queried
 * @return <code>true</code> if the file type is supported,
 * otherwise <code>false</code>
 */
public static boolean isFileTypeSupported(int fileType) {

    List providers = getMidiFileWriters();

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        if( writer.isFileTypeSupported(fileType)) {
            return true;
        }
    }
    return false;
}
 
Example 20
Source File: MidiSystem.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Indicates whether a MIDI file of the file type specified can be written
 * from the sequence indicated.
 * @param fileType the file type for which write capabilities
 * are queried
 * @param sequence the sequence for which file writing support is queried
 * @return <code>true</code> if the file type is supported for this
 * sequence, otherwise <code>false</code>
 */
public static boolean isFileTypeSupported(int fileType, Sequence sequence) {

    List providers = getMidiFileWriters();

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        if( writer.isFileTypeSupported(fileType,sequence)) {
            return true;
        }
    }
    return false;
}