-
- All Superinterfaces:
- AutoCloseable
- All Known Subinterfaces:
- Sequencer, Synthesizer
public interface MidiDevice extends AutoCloseable
MidiDevice
is the base interface for all MIDI devices. Common devices include synthesizers, sequencers, MIDI input ports, and MIDI output ports.A
MidiDevice
can be a transmitter or a receiver of MIDI events, or both. Therefore, it can provideTransmitter
orReceiver
instances (or both). Typically, MIDI IN ports provide transmitters, MIDI OUT ports and synthesizers provide receivers. A Sequencer typically provides transmitters for playback and receivers for recording.A
MidiDevice
can be opened and closed explicitly as well as implicitly. Explicit opening is accomplished by callingopen()
, explicit closing is done by callingclose()
on theMidiDevice
instance. If an application opens aMidiDevice
explicitly, it has to close it explicitly to free system resources and enable the application to exit cleanly. Implicit opening is done by callingMidiSystem.getReceiver
andMidiSystem.getTransmitter
. TheMidiDevice
used byMidiSystem.getReceiver
andMidiSystem.getTransmitter
is implementation-dependant unless the propertiesjavax.sound.midi.Receiver
andjavax.sound.midi.Transmitter
are used (see the description of properties to select default providers inMidiSystem
). AMidiDevice
that was opened implicitly, is closed implicitly by closing theReceiver
orTransmitter
that resulted in opening it. If more than one implicitly openingReceiver
orTransmitter
were obtained by the application, the decive is closed after the lastReceiver
orTransmitter
has been closed. On the other hand, callinggetReceiver
orgetTransmitter
on the device instance directly does not open the device implicitly. Closing theseTransmitter
s andReceiver
s does not close the device implicitly. To use a device withReceiver
s orTransmitter
s obtained this way, the device has to be opened and closed explicitly.If implicit and explicit opening and closing are mixed on the same
MidiDevice
instance, the following rules apply:- After an explicit open (either before or after implicit opens), the device will not be closed by implicit closing. The only way to close an explicitly opened device is an explicit close.
- An explicit close always closes the device, even if it also has been opened implicitly. A subsequent implicit close has no further effect.
MidiDevice device = ...; if ( ! (device instanceof Sequencer) && ! (device instanceof Synthesizer)) { // we're now sure that device represents a MIDI port // ... }
A
MidiDevice
includes a
object to provide manufacturer information and so on.MidiDevice.Info
- See Also:
Synthesizer
,Sequencer
,Receiver
,Transmitter
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface and Description static class
MidiDevice.Info
AMidiDevice.Info
object contains assorted data about a
, including its name, the company who created it, and descriptive text.MidiDevice
-
Method Summary
Methods Modifier and Type Method and Description void
close()
Closes the device, indicating that the device should now release any system resources it is using.MidiDevice.Info
getDeviceInfo()
Obtains information about the device, including its Java class andStrings
containing its name, vendor, and description.int
getMaxReceivers()
Obtains the maximum number of MIDI IN connections available on this MIDI device for receiving MIDI data.int
getMaxTransmitters()
Obtains the maximum number of MIDI OUT connections available on this MIDI device for transmitting MIDI data.long
getMicrosecondPosition()
Obtains the current time-stamp of the device, in microseconds.Receiver
getReceiver()
Obtains a MIDI IN receiver through which the MIDI device may receive MIDI data.List<Receiver>
getReceivers()
Returns all currently active, non-closed receivers connected with this MidiDevice.Transmitter
getTransmitter()
Obtains a MIDI OUT connection from which the MIDI device will transmit MIDI data The returned transmitter must be closed when the application has finished using it.List<Transmitter>
getTransmitters()
Returns all currently active, non-closed transmitters connected with this MidiDevice.boolean
isOpen()
Reports whether the device is open.void
open()
Opens the device, indicating that it should now acquire any system resources it requires and become operational.
-
-
-
Method Detail
-
getDeviceInfo
MidiDevice.Info getDeviceInfo()
Obtains information about the device, including its Java class andStrings
containing its name, vendor, and description.- Returns:
- device info
-
open
void open() throws MidiUnavailableException
Opens the device, indicating that it should now acquire any system resources it requires and become operational.An application opening a device explicitly with this call has to close the device by calling
close()
. This is necessary to release system resources and allow applications to exit cleanly.Note that some devices, once closed, cannot be reopened. Attempts to reopen such a device will always result in a MidiUnavailableException.
- Throws:
MidiUnavailableException
- thrown if the device cannot be opened due to resource restrictions.SecurityException
- thrown if the device cannot be opened due to security restrictions.- See Also:
close()
,isOpen()
-
close
void close()
Closes the device, indicating that the device should now release any system resources it is using.All
Receiver
andTransmitter
instances open from this device are closed. This includes instances retrieved viaMidiSystem
.- Specified by:
close
in interfaceAutoCloseable
- See Also:
open()
,isOpen()
-
isOpen
boolean isOpen()
Reports whether the device is open.
-
getMicrosecondPosition
long getMicrosecondPosition()
Obtains the current time-stamp of the device, in microseconds. If a device supports time-stamps, it should start counting at 0 when the device is opened and continue incrementing its time-stamp in microseconds until the device is closed. If it does not support time-stamps, it should always return -1.- Returns:
- the current time-stamp of the device in microseconds, or -1 if time-stamping is not supported by the device.
-
getMaxReceivers
int getMaxReceivers()
Obtains the maximum number of MIDI IN connections available on this MIDI device for receiving MIDI data.- Returns:
- maximum number of MIDI IN connections, or -1 if an unlimited number of connections is available.
-
getMaxTransmitters
int getMaxTransmitters()
Obtains the maximum number of MIDI OUT connections available on this MIDI device for transmitting MIDI data.- Returns:
- maximum number of MIDI OUT connections, or -1 if an unlimited number of connections is available.
-
getReceiver
Receiver getReceiver() throws MidiUnavailableException
Obtains a MIDI IN receiver through which the MIDI device may receive MIDI data. The returned receiver must be closed when the application has finished using it.Usually the returned receiver implements the
MidiDeviceReceiver
interface.Obtaining a
Receiver
with this method does not open the device. To be able to use the device, it has to be opened explicitly by callingopen()
. Also, closing theReceiver
does not close the device. It has to be closed explicitly by callingclose()
.- Returns:
- a receiver for the device.
- Throws:
MidiUnavailableException
- thrown if a receiver is not available due to resource restrictions- See Also:
Receiver.close()
-
getReceivers
List<Receiver> getReceivers()
Returns all currently active, non-closed receivers connected with this MidiDevice. A receiver can be removed from the device by closing it.Usually the returned receivers implement the
MidiDeviceReceiver
interface.- Returns:
- an unmodifiable list of the open receivers
- Since:
- 1.5
-
getTransmitter
Transmitter getTransmitter() throws MidiUnavailableException
Obtains a MIDI OUT connection from which the MIDI device will transmit MIDI data The returned transmitter must be closed when the application has finished using it.Usually the returned transmitter implements the
MidiDeviceTransmitter
interface.Obtaining a
Transmitter
with this method does not open the device. To be able to use the device, it has to be opened explicitly by callingopen()
. Also, closing theTransmitter
does not close the device. It has to be closed explicitly by callingclose()
.- Returns:
- a MIDI OUT transmitter for the device.
- Throws:
MidiUnavailableException
- thrown if a transmitter is not available due to resource restrictions- See Also:
Transmitter.close()
-
getTransmitters
List<Transmitter> getTransmitters()
Returns all currently active, non-closed transmitters connected with this MidiDevice. A transmitter can be removed from the device by closing it.Usually the returned transmitters implement the
MidiDeviceTransmitter
interface.- Returns:
- an unmodifiable list of the open transmitters
- Since:
- 1.5
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-javax/sound/midi/MidiDevice.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.