Dead
[official-gcc.git] / gomp-20050608-branch / libjava / classpath / javax / sound / midi / spi / MidiFileWriter.java
blobe2a1f55c6e0680490240ff350292378ac83ff947
1 /* MidiFileWriter.java -- MIDI file writing services
2 Copyright (C) 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax.sound.midi.spi;
41 import java.io.File;
42 import java.io.IOException;
43 import java.io.OutputStream;
45 import javax.sound.midi.Sequence;
47 /**
48 * MidiFileWriter provides MIDI file writing services.
50 * There are three types of Standard MIDI File (SMF) formats,
51 * represented by integers 0, 1, and 2.
53 * Type 0 files contain a single track and represents a single song
54 * performance.
55 * Type 1 may contain multiple tracks for a single song performance.
56 * Type 2 may contain multiple tracks, each representing a
57 * separate song performance.
59 * See http://en.wikipedia.org/wiki/MIDI#MIDI_file_formats for more
60 * information.
62 * @author Anthony Green (green@redhat.com)
63 * @since 1.3
66 public abstract class MidiFileWriter
68 /**
69 * Return the MIDI file types supported by this writer.
71 * @return the MIDI file types, or an empty array
73 public abstract int[] getMidiFileTypes();
75 /**
76 * Return the MIDI file types supported by this writer for the
77 * given sequence.
79 * @param sequence the sequence we'd like to write
80 * @return the MIDI file types, or an empty array
82 public abstract int[] getMidiFileTypes(Sequence sequence);
84 /**
85 * Returns true if this writer supports the given file type.
87 * @param fileType the file type we're asking about
88 * @return true if this writer supports fileType, false otherwise
90 public boolean isFileTypeSupported(int fileType)
92 int types[] = getMidiFileTypes();
93 for (int i = types.length; i > 0;)
95 if (types[--i] == fileType)
96 return true;
98 return false;
102 * Returns true if this writer supports the given file type for the
103 * given sequence.
105 * @param fileType the file type we're asking about
106 * @param sequence the sequence we'd like to write
107 * @return true if this writer supports fileType, false otherwise
109 public boolean isFileTypeSupported(int fileType, Sequence sequence)
111 int types[] = getMidiFileTypes(sequence);
112 for (int i = types.length; i > 0;)
114 if (types[--i] == fileType)
115 return true;
117 return false;
121 * Write a sequence to a stream using the specified MIDI file type.
123 * @param in the sequence to write
124 * @param fileType the MIDI file type to use
125 * @param out the output stream to write to
126 * @return the number of byte written
127 * @throws IOException if an I/O exception happens
129 public abstract int write(Sequence in, int fileType, OutputStream out)
130 throws IOException;
133 * Write a sequence to a file using the specified MIDI file type.
135 * @param in the sequence to write
136 * @param fileType the MIDI file type to use
137 * @param out the file to write to
138 * @return the number of byte written
139 * @throws IOException if an I/O exception happens
141 public abstract int write(Sequence in, int fileType, File out)
142 throws IOException;