be.hogent.tarsos.midi
Class MidiCommon

java.lang.Object
  extended by be.hogent.tarsos.midi.MidiCommon

public final class MidiCommon
extends java.lang.Object

Utility methods for MIDI examples.


Nested Class Summary
static class MidiCommon.MoreMidiInfo
           
 
Method Summary
static javax.sound.midi.MidiDevice chooseMidiDevice(boolean inputDevice, boolean outputDevice)
          Choose a MIDI device using a CLI.
static javax.sound.sampled.Mixer chooseMixerDevice()
          Choose a Mixer device using CLI.
static javax.sound.midi.MidiDevice.Info getMidiDeviceInfo(int index)
          Retrieve a MidiDevice.Info by index number.
static javax.sound.midi.MidiDevice.Info getMidiDeviceInfo(java.lang.String strDeviceName, boolean bForOutput)
          Retrieve a MidiDevice.Info for a given name.
static java.util.Vector<MidiCommon.MoreMidiInfo> listDevices(boolean input, boolean output)
           
static double[] tuningFromPeaks(double[] peaks)
          Create a MIDI tuning from a tone scale (defined by peaks).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

listDevices

public static java.util.Vector<MidiCommon.MoreMidiInfo> listDevices(boolean input,
                                                                    boolean output)

getMidiDeviceInfo

public static javax.sound.midi.MidiDevice.Info getMidiDeviceInfo(java.lang.String strDeviceName,
                                                                 boolean bForOutput)
Retrieve a MidiDevice.Info for a given name. This method tries to return a MidiDevice.Info whose name matches the passed name. If no matching MidiDevice.Info is found, null is returned. If bForOutput is true, then only output devices are searched, otherwise only input devices.

Parameters:
strDeviceName - the name of the device for which an info object should be retrieved.
bForOutput - If true, only output devices are considered. If false, only input devices are considered.
Returns:
A MidiDevice.Info object matching the passed device name or null if none could be found.

getMidiDeviceInfo

public static javax.sound.midi.MidiDevice.Info getMidiDeviceInfo(int index)
Retrieve a MidiDevice.Info by index number. This method returns a MidiDevice.Info whose index is specified as parameter. This index matches the number printed in the listDevicesAndExit method. If index is too small or too big, null is returned.

Parameters:
index - the index of the device to be retrieved
Returns:
A MidiDevice.Info object of the specified index or null if none could be found.

chooseMidiDevice

public static javax.sound.midi.MidiDevice chooseMidiDevice(boolean inputDevice,
                                                           boolean outputDevice)
Choose a MIDI device using a CLI. If an invalid device number is given the user is requested to choose another one.

Parameters:
inputDevice - is the MIDI device needed for input of events? E.G. a keyboard
outputDevice - is the MIDI device needed to send events to? E.g. a (software) synthesizer.
Returns:
the chosen MIDI device

chooseMixerDevice

public static javax.sound.sampled.Mixer chooseMixerDevice()
Choose a Mixer device using CLI.

Returns:
A chosen mixer object.

tuningFromPeaks

public static double[] tuningFromPeaks(double[] peaks)
Create a MIDI tuning from a tone scale (defined by peaks).

Parameters:
peaks - The peaks (from e.g. a Scala file or histogram).
Returns:
An array with 128 double values that can be used in a MIDI tuning dump.