Overview Package Class Use Source Tree Index Deprecated About
GNU Classpath (0.95)
Frames | No Frames

Source for javax.sound.midi.spi.MidiFileWriter

 1:  /* MidiFileWriter.java -- MIDI file writing services
 2:  Copyright (C) 2005 Free Software Foundation, Inc.
 3: 
 4: This file is part of GNU Classpath.
 5: 
 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.
 10: 
 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.
 15: 
 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.
 20: 
 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.
 25: 
 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. */
 37: 
 38: 
 39:  package javax.sound.midi.spi;
 40: 
 41:  import java.io.File;
 42:  import java.io.IOException;
 43:  import java.io.OutputStream;
 44: 
 45:  import javax.sound.midi.Sequence;
 46: 
 47:  /**
 48:  * MidiFileWriter provides MIDI file writing services. 
 49:  * 
 50:  * There are three types of Standard MIDI File (SMF) formats, 
 51:  * represented by integers 0, 1, and 2.
 52:  * 
 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.
 58:  * 
 59:  * See http://en.wikipedia.org/wiki/MIDI#MIDI_file_formats for more
 60:  * information.
 61:  * 
 62:  * @author Anthony Green (green@redhat.com)
 63:  * @since 1.3
 64:  *
 65:  */
 66:  public abstract class MidiFileWriter
 67: {
 68:  /**
 69:  * Return the MIDI file types supported by this writer.
 70:  * 
 71:  * @return the MIDI file types, or an empty array
 72:  */
 73:  public abstract int[] getMidiFileTypes();
 74:  
 75:  /**
 76:  * Return the MIDI file types supported by this writer for the
 77:  * given sequence.
 78:  * 
 79:  * @param sequence the sequence we'd like to write
 80:  * @return the MIDI file types, or an empty array
 81:  */
 82:  public abstract int[] getMidiFileTypes(Sequence sequence);
 83:  
 84:  /**
 85:  * Returns true if this writer supports the given file type.
 86:  * 
 87:  * @param fileType the file type we're asking about
 88:  * @return true if this writer supports fileType, false otherwise
 89:  */
 90:  public boolean isFileTypeSupported(int fileType)
 91:  {
 92:  int types[] = getMidiFileTypes();
 93:  for (int i = types.length; i > 0;)
 94:  {
 95:  if (types[--i] == fileType)
 96:  return true;
 97:  }
 98:  return false;
 99:  }
 100: 
 101:  /**
 102:  * Returns true if this writer supports the given file type for the
 103:  * given sequence.
 104:  * 
 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
 108:  */
 109:  public boolean isFileTypeSupported(int fileType, Sequence sequence)
 110:  {
 111:  int types[] = getMidiFileTypes(sequence);
 112:  for (int i = types.length; i > 0;)
 113:  {
 114:  if (types[--i] == fileType)
 115:  return true;
 116:  }
 117:  return false;
 118:  }
 119: 
 120:  /**
 121:  * Write a sequence to a stream using the specified MIDI file type.
 122:  * 
 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
 128:  */
 129:  public abstract int write(Sequence in, int fileType, OutputStream out)
 130:  throws IOException;
 131: 
 132:  /**
 133:  * Write a sequence to a file using the specified MIDI file type.
 134:  * 
 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
 140:  */
 141:  public abstract int write(Sequence in, int fileType, File out)
 142:  throws IOException;
 143: }
Overview Package Class Use Source Tree Index Deprecated About
GNU Classpath (0.95)

AltStyle によって変換されたページ (->オリジナル) /