Java Code Examples for javax.sound.midi.spi.MidiFileWriter

The following examples show how to use javax.sound.midi.spi.MidiFileWriter. These examples are extracted from open source projects. 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 Project: jdk1.8-source-analysis   Source File: MidiSystem.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Obtains the set of MIDI file types for which file writing support is
 * provided by the system.
 * @return array of unique file types.  If no file types are supported,
 * an array of length 0 is returned.
 */
public static int[] getMidiFileTypes() {

    List providers = getMidiFileWriters();
    Set allTypes = new HashSet();

    // gather from all the providers

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        int[] types = writer.getMidiFileTypes();
        for (int j = 0; j < types.length; j++ ) {
            allTypes.add(new Integer(types[j]));
        }
    }
    int resultTypes[] = new int[allTypes.size()];
    int index = 0;
    Iterator iterator = allTypes.iterator();
    while (iterator.hasNext()) {
        Integer integer = (Integer) iterator.next();
        resultTypes[index++] = integer.intValue();
    }
    return resultTypes;
}
 
Example 2
Source Project: jdk1.8-source-analysis   Source File: MidiSystem.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Obtains the set of MIDI file types that the system can write from the
 * sequence specified.
 * @param sequence the sequence for which MIDI file type support
 * is queried
 * @return the set of unique supported file types.  If no file types are supported,
 * returns an array of length 0.
 */
public static int[] getMidiFileTypes(Sequence sequence) {

    List providers = getMidiFileWriters();
    Set allTypes = new HashSet();

    // gather from all the providers

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        int[] types = writer.getMidiFileTypes(sequence);
        for (int j = 0; j < types.length; j++ ) {
            allTypes.add(new Integer(types[j]));
        }
    }
    int resultTypes[] = new int[allTypes.size()];
    int index = 0;
    Iterator iterator = allTypes.iterator();
    while (iterator.hasNext()) {
        Integer integer = (Integer) iterator.next();
        resultTypes[index++] = integer.intValue();
    }
    return resultTypes;
}
 
Example 3
Source Project: jdk1.8-source-analysis   Source File: MidiSystem.java    License: 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
/**
 * Obtains a List containing installed instances of the providers for the
 * requested service. The returned List is immutable.
 *
 * @param serviceClass The type of providers requested. This should be one
 *                     of AudioFileReader.class, AudioFileWriter.class,
 *                     FormatConversionProvider.class, MixerProvider.class,
 *                     MidiDeviceProvider.class, MidiFileReader.class,
 *                     MidiFileWriter.class or SoundbankReader.class.
 *
 * @return A List of providers of the requested type. This List is
 *         immutable.
 */
public static List<?> getProviders(final Class<?> serviceClass) {
    final List<?> providers;
    if (!MixerProvider.class.equals(serviceClass)
            && !FormatConversionProvider.class.equals(serviceClass)
            && !AudioFileReader.class.equals(serviceClass)
            && !AudioFileWriter.class.equals(serviceClass)
            && !MidiDeviceProvider.class.equals(serviceClass)
            && !SoundbankReader.class.equals(serviceClass)
            && !MidiFileWriter.class.equals(serviceClass)
            && !MidiFileReader.class.equals(serviceClass)) {
        providers = new ArrayList<>(0);
    } else {
        providers = JSSecurityManager.getProviders(serviceClass);
    }
    return Collections.unmodifiableList(providers);
}
 
Example 5
Source Project: dragonwell8_jdk   Source File: MidiSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the set of MIDI file types for which file writing support is
 * provided by the system.
 * @return array of unique file types.  If no file types are supported,
 * an array of length 0 is returned.
 */
public static int[] getMidiFileTypes() {

    List providers = getMidiFileWriters();
    Set allTypes = new HashSet();

    // gather from all the providers

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        int[] types = writer.getMidiFileTypes();
        for (int j = 0; j < types.length; j++ ) {
            allTypes.add(new Integer(types[j]));
        }
    }
    int resultTypes[] = new int[allTypes.size()];
    int index = 0;
    Iterator iterator = allTypes.iterator();
    while (iterator.hasNext()) {
        Integer integer = (Integer) iterator.next();
        resultTypes[index++] = integer.intValue();
    }
    return resultTypes;
}
 
Example 6
Source Project: openjdk-8-source   Source File: MidiSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the set of MIDI file types for which file writing support is
 * provided by the system.
 * @return array of unique file types.  If no file types are supported,
 * an array of length 0 is returned.
 */
public static int[] getMidiFileTypes() {

    List providers = getMidiFileWriters();
    Set allTypes = new HashSet();

    // gather from all the providers

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        int[] types = writer.getMidiFileTypes();
        for (int j = 0; j < types.length; j++ ) {
            allTypes.add(new Integer(types[j]));
        }
    }
    int resultTypes[] = new int[allTypes.size()];
    int index = 0;
    Iterator iterator = allTypes.iterator();
    while (iterator.hasNext()) {
        Integer integer = (Integer) iterator.next();
        resultTypes[index++] = integer.intValue();
    }
    return resultTypes;
}
 
Example 7
Source Project: dragonwell8_jdk   Source File: MidiSystem.java    License: 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 8
Source Project: dragonwell8_jdk   Source File: MidiSystem.java    License: 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 9
Source Project: jdk8u_jdk   Source File: MidiSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the set of MIDI file types that the system can write from the
 * sequence specified.
 * @param sequence the sequence for which MIDI file type support
 * is queried
 * @return the set of unique supported file types.  If no file types are supported,
 * returns an array of length 0.
 */
public static int[] getMidiFileTypes(Sequence sequence) {

    List providers = getMidiFileWriters();
    Set allTypes = new HashSet();

    // gather from all the providers

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        int[] types = writer.getMidiFileTypes(sequence);
        for (int j = 0; j < types.length; j++ ) {
            allTypes.add(new Integer(types[j]));
        }
    }
    int resultTypes[] = new int[allTypes.size()];
    int index = 0;
    Iterator iterator = allTypes.iterator();
    while (iterator.hasNext()) {
        Integer integer = (Integer) iterator.next();
        resultTypes[index++] = integer.intValue();
    }
    return resultTypes;
}
 
Example 10
Source Project: hottub   Source File: MidiSystem.java    License: 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 Project: hottub   Source File: MidiSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the set of MIDI file types for which file writing support is
 * provided by the system.
 * @return array of unique file types.  If no file types are supported,
 * an array of length 0 is returned.
 */
public static int[] getMidiFileTypes() {

    List providers = getMidiFileWriters();
    Set allTypes = new HashSet();

    // gather from all the providers

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        int[] types = writer.getMidiFileTypes();
        for (int j = 0; j < types.length; j++ ) {
            allTypes.add(new Integer(types[j]));
        }
    }
    int resultTypes[] = new int[allTypes.size()];
    int index = 0;
    Iterator iterator = allTypes.iterator();
    while (iterator.hasNext()) {
        Integer integer = (Integer) iterator.next();
        resultTypes[index++] = integer.intValue();
    }
    return resultTypes;
}
 
Example 12
Source Project: Java8CN   Source File: MidiSystem.java    License: 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 13
Source Project: TencentKona-8   Source File: MidiSystem.java    License: 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 14
Source Project: TencentKona-8   Source File: MidiSystem.java    License: 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 15
Source Project: jdk8u60   Source File: MidiSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the set of MIDI file types for which file writing support is
 * provided by the system.
 * @return array of unique file types.  If no file types are supported,
 * an array of length 0 is returned.
 */
public static int[] getMidiFileTypes() {

    List providers = getMidiFileWriters();
    Set allTypes = new HashSet();

    // gather from all the providers

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        int[] types = writer.getMidiFileTypes();
        for (int j = 0; j < types.length; j++ ) {
            allTypes.add(new Integer(types[j]));
        }
    }
    int resultTypes[] = new int[allTypes.size()];
    int index = 0;
    Iterator iterator = allTypes.iterator();
    while (iterator.hasNext()) {
        Integer integer = (Integer) iterator.next();
        resultTypes[index++] = integer.intValue();
    }
    return resultTypes;
}
 
Example 16
Source Project: jdk8u60   Source File: MidiSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the set of MIDI file types that the system can write from the
 * sequence specified.
 * @param sequence the sequence for which MIDI file type support
 * is queried
 * @return the set of unique supported file types.  If no file types are supported,
 * returns an array of length 0.
 */
public static int[] getMidiFileTypes(Sequence sequence) {

    List providers = getMidiFileWriters();
    Set allTypes = new HashSet();

    // gather from all the providers

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        int[] types = writer.getMidiFileTypes(sequence);
        for (int j = 0; j < types.length; j++ ) {
            allTypes.add(new Integer(types[j]));
        }
    }
    int resultTypes[] = new int[allTypes.size()];
    int index = 0;
    Iterator iterator = allTypes.iterator();
    while (iterator.hasNext()) {
        Integer integer = (Integer) iterator.next();
        resultTypes[index++] = integer.intValue();
    }
    return resultTypes;
}
 
Example 17
Source Project: jdk8u60   Source File: MidiSystem.java    License: 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 18
Source Project: jdk8u60   Source File: MidiSystem.java    License: 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 19
Source Project: JDKSourceCode1.8   Source File: MidiSystem.java    License: MIT License 6 votes vote down vote up
/**
 * Obtains the set of MIDI file types for which file writing support is
 * provided by the system.
 * @return array of unique file types.  If no file types are supported,
 * an array of length 0 is returned.
 */
public static int[] getMidiFileTypes() {

    List providers = getMidiFileWriters();
    Set allTypes = new HashSet();

    // gather from all the providers

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        int[] types = writer.getMidiFileTypes();
        for (int j = 0; j < types.length; j++ ) {
            allTypes.add(new Integer(types[j]));
        }
    }
    int resultTypes[] = new int[allTypes.size()];
    int index = 0;
    Iterator iterator = allTypes.iterator();
    while (iterator.hasNext()) {
        Integer integer = (Integer) iterator.next();
        resultTypes[index++] = integer.intValue();
    }
    return resultTypes;
}
 
Example 20
Source Project: JDKSourceCode1.8   Source File: MidiSystem.java    License: MIT License 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 21
Source Project: openjdk-8   Source File: MidiSystem.java    License: 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 22
Source Project: jdk8u_jdk   Source File: JDK13Services.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains a List containing installed instances of the providers for the
 * requested service. The returned List is immutable.
 *
 * @param serviceClass The type of providers requested. This should be one
 *                     of AudioFileReader.class, AudioFileWriter.class,
 *                     FormatConversionProvider.class, MixerProvider.class,
 *                     MidiDeviceProvider.class, MidiFileReader.class,
 *                     MidiFileWriter.class or SoundbankReader.class.
 *
 * @return A List of providers of the requested type. This List is
 *         immutable.
 */
public static List<?> getProviders(final Class<?> serviceClass) {
    final List<?> providers;
    if (!MixerProvider.class.equals(serviceClass)
            && !FormatConversionProvider.class.equals(serviceClass)
            && !AudioFileReader.class.equals(serviceClass)
            && !AudioFileWriter.class.equals(serviceClass)
            && !MidiDeviceProvider.class.equals(serviceClass)
            && !SoundbankReader.class.equals(serviceClass)
            && !MidiFileWriter.class.equals(serviceClass)
            && !MidiFileReader.class.equals(serviceClass)) {
        providers = new ArrayList<>(0);
    } else {
        providers = JSSecurityManager.getProviders(serviceClass);
    }
    return Collections.unmodifiableList(providers);
}
 
Example 23
Source Project: openjdk-jdk8u   Source File: JDK13Services.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains a List containing installed instances of the providers for the
 * requested service. The returned List is immutable.
 *
 * @param serviceClass The type of providers requested. This should be one
 *                     of AudioFileReader.class, AudioFileWriter.class,
 *                     FormatConversionProvider.class, MixerProvider.class,
 *                     MidiDeviceProvider.class, MidiFileReader.class,
 *                     MidiFileWriter.class or SoundbankReader.class.
 *
 * @return A List of providers of the requested type. This List is
 *         immutable.
 */
public static List<?> getProviders(final Class<?> serviceClass) {
    final List<?> providers;
    if (!MixerProvider.class.equals(serviceClass)
            && !FormatConversionProvider.class.equals(serviceClass)
            && !AudioFileReader.class.equals(serviceClass)
            && !AudioFileWriter.class.equals(serviceClass)
            && !MidiDeviceProvider.class.equals(serviceClass)
            && !SoundbankReader.class.equals(serviceClass)
            && !MidiFileWriter.class.equals(serviceClass)
            && !MidiFileReader.class.equals(serviceClass)) {
        providers = new ArrayList<>(0);
    } else {
        providers = JSSecurityManager.getProviders(serviceClass);
    }
    return Collections.unmodifiableList(providers);
}
 
Example 24
Source Project: openjdk-jdk8u   Source File: MidiSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the set of MIDI file types for which file writing support is
 * provided by the system.
 * @return array of unique file types.  If no file types are supported,
 * an array of length 0 is returned.
 */
public static int[] getMidiFileTypes() {

    List providers = getMidiFileWriters();
    Set allTypes = new HashSet();

    // gather from all the providers

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        int[] types = writer.getMidiFileTypes();
        for (int j = 0; j < types.length; j++ ) {
            allTypes.add(new Integer(types[j]));
        }
    }
    int resultTypes[] = new int[allTypes.size()];
    int index = 0;
    Iterator iterator = allTypes.iterator();
    while (iterator.hasNext()) {
        Integer integer = (Integer) iterator.next();
        resultTypes[index++] = integer.intValue();
    }
    return resultTypes;
}
 
Example 25
Source Project: Java8CN   Source File: MidiSystem.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Obtains the set of MIDI file types that the system can write from the
 * sequence specified.
 * @param sequence the sequence for which MIDI file type support
 * is queried
 * @return the set of unique supported file types.  If no file types are supported,
 * returns an array of length 0.
 */
public static int[] getMidiFileTypes(Sequence sequence) {

    List providers = getMidiFileWriters();
    Set allTypes = new HashSet();

    // gather from all the providers

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        int[] types = writer.getMidiFileTypes(sequence);
        for (int j = 0; j < types.length; j++ ) {
            allTypes.add(new Integer(types[j]));
        }
    }
    int resultTypes[] = new int[allTypes.size()];
    int index = 0;
    Iterator iterator = allTypes.iterator();
    while (iterator.hasNext()) {
        Integer integer = (Integer) iterator.next();
        resultTypes[index++] = integer.intValue();
    }
    return resultTypes;
}
 
Example 26
Source Project: openjdk-jdk8u   Source File: MidiSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the set of MIDI file types that the system can write from the
 * sequence specified.
 * @param sequence the sequence for which MIDI file type support
 * is queried
 * @return the set of unique supported file types.  If no file types are supported,
 * returns an array of length 0.
 */
public static int[] getMidiFileTypes(Sequence sequence) {

    List providers = getMidiFileWriters();
    Set allTypes = new HashSet();

    // gather from all the providers

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        int[] types = writer.getMidiFileTypes(sequence);
        for (int j = 0; j < types.length; j++ ) {
            allTypes.add(new Integer(types[j]));
        }
    }
    int resultTypes[] = new int[allTypes.size()];
    int index = 0;
    Iterator iterator = allTypes.iterator();
    while (iterator.hasNext()) {
        Integer integer = (Integer) iterator.next();
        resultTypes[index++] = integer.intValue();
    }
    return resultTypes;
}
 
Example 27
Source Project: openjdk-8   Source File: MidiSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the set of MIDI file types that the system can write from the
 * sequence specified.
 * @param sequence the sequence for which MIDI file type support
 * is queried
 * @return the set of unique supported file types.  If no file types are supported,
 * returns an array of length 0.
 */
public static int[] getMidiFileTypes(Sequence sequence) {

    List providers = getMidiFileWriters();
    Set allTypes = new HashSet();

    // gather from all the providers

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        int[] types = writer.getMidiFileTypes(sequence);
        for (int j = 0; j < types.length; j++ ) {
            allTypes.add(new Integer(types[j]));
        }
    }
    int resultTypes[] = new int[allTypes.size()];
    int index = 0;
    Iterator iterator = allTypes.iterator();
    while (iterator.hasNext()) {
        Integer integer = (Integer) iterator.next();
        resultTypes[index++] = integer.intValue();
    }
    return resultTypes;
}
 
Example 28
Source Project: hottub   Source File: MidiSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the set of MIDI file types that the system can write from the
 * sequence specified.
 * @param sequence the sequence for which MIDI file type support
 * is queried
 * @return the set of unique supported file types.  If no file types are supported,
 * returns an array of length 0.
 */
public static int[] getMidiFileTypes(Sequence sequence) {

    List providers = getMidiFileWriters();
    Set allTypes = new HashSet();

    // gather from all the providers

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        int[] types = writer.getMidiFileTypes(sequence);
        for (int j = 0; j < types.length; j++ ) {
            allTypes.add(new Integer(types[j]));
        }
    }
    int resultTypes[] = new int[allTypes.size()];
    int index = 0;
    Iterator iterator = allTypes.iterator();
    while (iterator.hasNext()) {
        Integer integer = (Integer) iterator.next();
        resultTypes[index++] = integer.intValue();
    }
    return resultTypes;
}
 
Example 29
Source Project: openjdk-jdk8u   Source File: MidiSystem.java    License: 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 30
Source Project: Java8CN   Source File: MidiSystem.java    License: 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 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;
}