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 Summary
Constructors Constructor Description MIDIPlayer()
Construct a MIDIPlayer object -
Method Summary
Modifier and Type Method Description void
finalize()
Can be called by the destructor to close the MIDI interface.static void
main(java.lang.String[] args)
Placeholder main function for library testing.void
playChord(int[] notes, int duration, int intensity)
Play a chord on the default channelvoid
playChords(int[] channelIndices, int[][] notes, int[] durations, int[][] intensities)
Method to play an array of chords with the given durations and intensitiesvoid
playNote(int note, int duration, int intensity)
Play a note on the default channelvoid
playNotes(int[] channelIndices, int[] notes, int[] durations, int[] intensities)
Method to play an array of notes with the given durations and intensitiesstatic void
rest(int duration)
Method to rest for a specified number of millisecondsvoid
setChannel(int i)
Set a particular MIDI channel as the default for playing notes through this interface that do not request a channel parametervoid
setInstrument(int num)
Method to set the instrument to play on the default channelvoid
setInstrument(int num, int index)
Method to set the instrument to play on a particular channel
-
Field Details
-
Constructor Details
-
MIDIPlayer
public MIDIPlayer()Construct a MIDIPlayer object
-
-
Method Details
-
setChannel
public 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
-
finalize
public void finalize()Can be called by the destructor to close the MIDI interface.- Overrides:
finalize
in classjava.lang.Object
-
playNote
public 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
-
playChord
public void playChord(int[] notes, int duration, int intensity)Play a chord on the default channel- Parameters:
notes
- an array of notes for the chordintensity
- the intensity of the soundduration
- the duration of the chord
-
playNotes
public 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 usenotes
- the array of notes to play (0-127)durations
- the array of durations to use for playing the notes in millisecondsintensities
- the array of intensities (loudness)
-
playChords
public 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 usenotes
- the 2D array of chords to play (0-127)durations
- the array of durations to use for playing the notes in millisecondsintensities
- the 2D array of intensities (loudness)
-
rest
public static void rest(int duration)Method to rest for a specified number of milliseconds- Parameters:
duration
- the amount to rest in milliseconds
-
setInstrument
public 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 instrumentindex
- the channel number
-
setInstrument
public 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
-
main
public 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
-