001 /* MidiDevice.java -- Interface for MIDI devices 002 Copyright (C) 2005 Free Software Foundation, Inc. 003 004 This file is part of GNU Classpath. 005 006 GNU Classpath is free software; you can redistribute it and/or modify 007 it under the terms of the GNU General Public License as published by 008 the Free Software Foundation; either version 2, or (at your option) 009 any later version. 010 011 GNU Classpath is distributed in the hope that it will be useful, but 012 WITHOUT ANY WARRANTY; without even the implied warranty of 013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 General Public License for more details. 015 016 You should have received a copy of the GNU General Public License 017 along with GNU Classpath; see the file COPYING. If not, write to the 018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 019 02110-1301 USA. 020 021 Linking this library statically or dynamically with other modules is 022 making a combined work based on this library. Thus, the terms and 023 conditions of the GNU General Public License cover the whole 024 combination. 025 026 As a special exception, the copyright holders of this library give you 027 permission to link this library with independent modules to produce an 028 executable, regardless of the license terms of these independent 029 modules, and to copy and distribute the resulting executable under 030 terms of your choice, provided that you also meet, for each linked 031 independent module, the terms and conditions of the license of that 032 module. An independent module is a module which is not derived from 033 or based on this library. If you modify this library, you may extend 034 this exception to your version of the library, but you are not 035 obligated to do so. If you do not wish to do so, delete this 036 exception statement from your version. */ 037 038 039 package javax.sound.midi; 040 041 /** 042 * Interface for all MIDI devices. 043 * 044 * @author Anthony Green (green@redhat.com) 045 * @since 1.3 046 * 047 */ 048 public interface MidiDevice 049 { 050 /** 051 * Get the Info object describing this device. 052 * @return the Info object describing this device 053 */ 054 public Info getDeviceInfo(); 055 056 /** 057 * Open this MIDI device and allocate any system resource we need. 058 * 059 * @throws MidiUnavailableException if we're not able to open for some reason 060 */ 061 public void open() throws MidiUnavailableException; 062 063 /** 064 * Close this MIDI device, and release any system resources we're using. 065 */ 066 public void close(); 067 068 /** 069 * Returns true if this MIDI device is open and false otherwise. 070 * 071 * @return true if this is open, false otherwise 072 */ 073 public boolean isOpen(); 074 075 /** 076 * If this device supports time-stamps, then it will return the number 077 * of microseconds since this device has been open, and -1 otherwise. 078 * 079 * @return -1 or the number of microseconds since this was opened 080 */ 081 public long getMicrosecondPosition(); 082 083 /** 084 * The maximum number of MIDI IN connections we can get as Receivers, 085 * or -1 if there is no maximum. 086 * 087 * @return -1 or the maximum number of Receivers we can get 088 */ 089 public int getMaxReceivers(); 090 091 /** 092 * The maximum number of MIDI OUT connections we can get as Transmitters, 093 * or -1 if there is no maximum. 094 * 095 * @return -1 or the maximum number of Transmitters we can get 096 */ 097 public int getMaxTransmitters(); 098 099 /** 100 * Get a MIDI IN Receiver for this device. 101 * 102 * @return a MIDI IN Receiver for this device 103 * @throws MidiUnavailableException if we can't get a Receiver 104 */ 105 public Receiver getReceiver() throws MidiUnavailableException; 106 107 /** 108 * Get a MIDI OUT Transmitter for this device. 109 * 110 * @return a MIDI OUT Transmitter for this device 111 * @throws MidiUnavailableException if we can't get a Transmitter 112 */ 113 public Transmitter getTransmitter() throws MidiUnavailableException; 114 115 /** 116 * A MIDI device descriptor object. 117 * 118 * @author green@redhat.com 119 * 120 */ 121 public static class Info 122 { 123 // Private data describing this device 124 private String name; 125 private String vendor; 126 private String description; 127 private String version; 128 129 /** 130 * Create an Info object for a MIDI device 131 * 132 * @param name the device name 133 * @param vendor the vendor name 134 * @param description the device description 135 * @param version the device version string 136 */ 137 protected Info(String name, String vendor, String description, String version) 138 { 139 this.name = name; 140 this.vendor = vendor; 141 this.description = description; 142 this.version = version; 143 } 144 145 /** 146 * This equals method only returns true if this object 147 * is the same as obj. 148 * 149 * @param obj the object we're comparing to 150 * @return true if this is the same object 151 * @see java.lang.Object#equals(java.lang.Object) 152 */ 153 public final boolean equals(Object obj) 154 { 155 return super.equals(obj); 156 } 157 158 /** 159 * A hash code for this object. 160 * 161 * @return the hash code for this object 162 * @see java.lang.Object#hashCode() 163 */ 164 public final int hashCode() 165 { 166 return super.hashCode(); 167 } 168 169 /** 170 * Get the device name. 171 * 172 * @return the device name 173 */ 174 public final String getName() 175 { 176 return name; 177 } 178 179 /** 180 * Get the device vendor. 181 * 182 * @return the device vendor 183 */ 184 public final String getVendor() 185 { 186 return vendor; 187 } 188 189 /** 190 * Get the device description 191 * 192 * @return the device description 193 */ 194 public final String getDescription() 195 { 196 return description; 197 } 198 199 /** 200 * get the device version 201 * 202 * @return the device version 203 */ 204 public final String getVersion() 205 { 206 return version; 207 } 208 209 /** 210 * Simple return the name of the device. 211 * 212 * @return the device name 213 * @see java.lang.Object#toString() 214 */ 215 public final String toString() 216 { 217 return name; 218 } 219 } 220 }