uk.org.toot.midi.core.channel
Class DefaultMidiChannelReader

java.lang.Object
  extended by uk.org.toot.midi.core.channel.DefaultMidiChannelReader
All Implemented Interfaces:
MidiChannelReader

public class DefaultMidiChannelReader
extends java.lang.Object
implements MidiChannelReader

This class decodes state and provides a channel=based read API. It has state.


Constructor Summary
DefaultMidiChannelReader(int index)
           
 
Method Summary
 void decode(int command, int data1, int data2)
           
 int getChannelPressure()
          Obtains the channel's keyboard pressure.
 int getControl(int control)
          Get the value of the controller with the specified index.
 int getController(int controller)
          Obtains the current value of the specified controller.
 int getIndex()
          Get the channel index number.
 boolean getMono()
          Obtains the current mono/poly mode.
 boolean getMute()
          Obtains the current mute state for this channel.
 boolean getOmni()
          Obtains the current omni mode status.
 int getPan()
           
 int getPitchBend()
          Obtains the upward or downward pitch offset for this channel.
 int getPolyPressure(int noteNumber)
          Obtains the pressure with which the specified key is being depressed.
 int getProgram()
          Obtains the current program number for this channel.
 boolean getSolo()
          Obtains the current solo state for this channel.
 int getVolume()
           
 void setIndex(int index)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultMidiChannelReader

public DefaultMidiChannelReader(int index)
Method Detail

decode

public void decode(int command,
                   int data1,
                   int data2)
Specified by:
decode in interface MidiChannelReader

getControl

public int getControl(int control)
Description copied from interface: MidiChannelReader
Get the value of the controller with the specified index. This method determines whether the specified controller is 7 bit or 14 bit and results in one or two getController() calls as appropriate.

Specified by:
getControl in interface MidiChannelReader

getPolyPressure

public int getPolyPressure(int noteNumber)
Obtains the pressure with which the specified key is being depressed.

Specified by:
getPolyPressure in interface MidiChannelReader
Parameters:
noteNumber - the MIDI note number, from 0 to 127 (60 = Middle C)
Returns:
the amount of pressure for that note, from 0 to 127 (127 = maximum pressure)
See Also:
#setPolyPressure(int, int)

getChannelPressure

public int getChannelPressure()
Obtains the channel's keyboard pressure.

Specified by:
getChannelPressure in interface MidiChannelReader
Returns:
the pressure with which the keyboard is being depressed, from 0 to 127 (127 = maximum pressure)
See Also:
#setChannelPressure(int)

getController

public int getController(int controller)
Obtains the current value of the specified controller. The return value is represented with 7 bits. For 14-bit controllers, the MSB and LSB controller value needs to be obtained separately. For example, the 14-bit value of the volume controller can be calculated by multiplying the value of controller 7 (0x07, channel volume MSB) with 128 and adding the value of controller 39 (0x27, channel volume LSB).

Specified by:
getController in interface MidiChannelReader
Parameters:
controller - the number of the controller whose value is desired. The allowed range is 0-127; see the MIDI 1.0 Specification for the interpretation.
Returns:
the current value of the specified controller (0 to 127)
See Also:
#controlChange(int, int)

getProgram

public int getProgram()
Obtains the current program number for this channel.

Specified by:
getProgram in interface MidiChannelReader
Returns:
the program number of the currently selected patch
See Also:
Patch.getProgram(), Synthesizer.loadInstrument(javax.sound.midi.Instrument), #programChange(int)

getPitchBend

public int getPitchBend()
Obtains the upward or downward pitch offset for this channel.

Specified by:
getPitchBend in interface MidiChannelReader
Returns:
bend amount, as a nonnegative 14-bit value (8192 = no bend)
See Also:
#setPitchBend(int)

getVolume

public int getVolume()
Specified by:
getVolume in interface MidiChannelReader

getPan

public int getPan()
Specified by:
getPan in interface MidiChannelReader

getMono

public boolean getMono()
Obtains the current mono/poly mode.

Specified by:
getMono in interface MidiChannelReader
Returns:
true if mono mode is on, otherwise false (meaning poly mode is on).
See Also:
#setMono(boolean)

getOmni

public boolean getOmni()
Obtains the current omni mode status.

Specified by:
getOmni in interface MidiChannelReader
Returns:
true if omni mode is on, otherwise false.
See Also:
#setOmni(boolean)

getMute

public boolean getMute()
Obtains the current mute state for this channel.

Specified by:
getMute in interface MidiChannelReader
Returns:
true the channel is muted, false if not
See Also:
#setMute(boolean)

getSolo

public boolean getSolo()
Obtains the current solo state for this channel.

Specified by:
getSolo in interface MidiChannelReader
Returns:
true if soloed, false if not
See Also:
#setSolo(boolean)

getIndex

public int getIndex()
Description copied from interface: MidiChannelReader
Get the channel index number.

Specified by:
getIndex in interface MidiChannelReader
Returns:
int - the zero-based index of the channel (0..15)

setIndex

public void setIndex(int index)


Copyright © 2004, 2005, 2006, 2007 Steve Taylor. All Rights Reserved.