c11files.calgorythmic.midi
Class MidiPlayer

java.lang.Object
  extended by c11files.calgorythmic.midi.MidiPlayer

public class MidiPlayer
extends java.lang.Object

A simple wrapper for the Java MIDI API that provides note start and stop for various instruments and channels.

Version:
CS 108, August, 2008
Author:
Keith Vander Linden

Constructor Summary
MidiPlayer()
          This routine initializes the MIDI synthesizer, bank of synthesized sounds and the MIDI channels.
 
Method Summary
 void close()
          This routine shuts down the synthesizer.
 void setInstrument(int instrument)
          This routines sets current synthesized instrument with which to play notes.
 void startNote(int note, int velocity)
          This routine starts a note with the given velocity on the default MIDI channel.
 void startNote(int note, int velocity, int channelIndex)
          This routine starts a note with the given velocity on the given MIDI channel.
 void stopNote(int note, int velocity)
          This routine stops a note with the given velocity on the default MIDI channel.
 void stopNote(int note, int velocity, int channelIndex)
          This routine stops a note with the given velocity on the given MIDI channel.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MidiPlayer

public MidiPlayer()
This routine initializes the MIDI synthesizer, bank of synthesized sounds and the MIDI channels.

Method Detail

close

public void close()
This routine shuts down the synthesizer.


startNote

public void startNote(int note,
                      int velocity)
This routine starts a note with the given velocity on the default MIDI channel.

Parameters:
note - the desired pitch (Midi.C1-Midi.C8)
velocity - the force of the attack

stopNote

public void stopNote(int note,
                     int velocity)
This routine stops a note with the given velocity on the default MIDI channel. It will stop the pitch regardless of how many times it has been started before.

Parameters:
note - the desired pitch (Midi.C1-Midi.C8)
velocity - the force of the attach

startNote

public void startNote(int note,
                      int velocity,
                      int channelIndex)
This routine starts a note with the given velocity on the given MIDI channel.

Parameters:
note - the desired pitch (Midi.C1-Midi.C8)
velocity - the force of the attach
channelIndex - the MIDI channel to use

stopNote

public void stopNote(int note,
                     int velocity,
                     int channelIndex)
This routine stops a note with the given velocity on the given MIDI channel. It will stop the pitch regardless of how many times it has been started before.

Parameters:
note - the desired pitch (Midi.C1-Midi.C8)
velocity - the force of the attach
channelIndex - the MIDI channel to use

setInstrument

public void setInstrument(int instrument)
This routines sets current synthesized instrument with which to play notes.

Parameters:
instrument - the chosen instrument (Midi.PIANO, ...)