Package com.MIDI
Class MIDIPlayer
java.lang.Object
com.MIDI.MIDIPlayer
public final class MIDIPlayer
extends java.lang.Object
Class that knows how to play notes using the midi standard
 Copyright 2004 Georgia Institute of Technology
- 
Field Summary
- 
Constructor SummaryConstructors Constructor Description MIDIPlayer()Construct a MIDIPlayer object
- 
Method SummaryModifier and Type Method Description voidfinalize()Can be called by the destructor to close the MIDI interface.static voidmain(java.lang.String[] args)Placeholder main function for library testing.voidplayChord(int[] notes, int duration, int intensity)Play a chord on the default channelvoidplayChords(int[] channelIndices, int[][] notes, int[] durations, int[][] intensities)Method to play an array of chords with the given durations and intensitiesvoidplayNote(int note, int duration, int intensity)Play a note on the default channelvoidplayNotes(int[] channelIndices, int[] notes, int[] durations, int[] intensities)Method to play an array of notes with the given durations and intensitiesstatic voidrest(int duration)Method to rest for a specified number of millisecondsvoidsetChannel(int i)Set a particular MIDI channel as the default for playing notes through this interface that do not request a channel parametervoidsetInstrument(int num)Method to set the instrument to play on the default channelvoidsetInstrument(int num, int index)Method to set the instrument to play on a particular channel
- 
Field Details
- 
Constructor Details- 
MIDIPlayerpublic MIDIPlayer()Construct a MIDIPlayer object
 
- 
- 
Method Details- 
setChannelpublic void setChannel(int i)Set a particular MIDI channel as the default for playing notes through this interface that do not request a channel parameter- Parameters:
- i- the index of the channel to set as the default
 
- 
finalizepublic void finalize()Can be called by the destructor to close the MIDI interface.- Overrides:
- finalizein class- java.lang.Object
 
- 
playNotepublic void playNote(int note, int duration, int intensity)Play a note on the default channel- Parameters:
- note- index of the note from the Notes class (60 is middle C)
- duration- duration of the note (i.e., Notes.NOTE_WHOLE or Notes.NOTE_QUARTER)
- intensity- intensity of the note
 
- 
playChordpublic void playChord(int[] notes, int duration, int intensity)Play a chord on the default channel- Parameters:
- notes- an array of notes for the chord
- intensity- the intensity of the sound
- duration- the duration of the chord
 
- 
playNotespublic void playNotes(int[] channelIndices, int[] notes, int[] durations, int[] intensities)Method to play an array of notes with the given durations and intensities- Parameters:
- channelIndices- the array channel indices to use
- notes- the array of notes to play (0-127)
- durations- the array of durations to use for playing the notes in milliseconds
- intensities- the array of intensities (loudness)
 
- 
playChordspublic void playChords(int[] channelIndices, int[][] notes, int[] durations, int[][] intensities)Method to play an array of chords with the given durations and intensities- Parameters:
- channelIndices- the array channel indices to use
- notes- the 2D array of chords to play (0-127)
- durations- the array of durations to use for playing the notes in milliseconds
- intensities- the 2D array of intensities (loudness)
 
- 
restpublic static void rest(int duration)Method to rest for a specified number of milliseconds- Parameters:
- duration- the amount to rest in milliseconds
 
- 
setInstrumentpublic void setInstrument(int num, int index)Method to set the instrument to play on a particular channel- Parameters:
- num- a number from 0 to 127 that represents the instrument
- index- the channel number
 
- 
setInstrumentpublic void setInstrument(int num)Method to set the instrument to play on the default channel- Parameters:
- num- a number from 0 to 127 that represents the instrument
 
- 
mainpublic static void main(java.lang.String[] args)Placeholder main function for library testing. Do not call this method.- Parameters:
- args- an array of command line argument strings
 
 
-