Class MidiPlayer

java.lang.Object
  extended byMidiPlayer

public class MidiPlayer
extends java.lang.Object

Class that knows how to play notes using the midi standard Copyright 2004 Georgia Institute of Technology

Author:
unknown Georgia Tech Students, Barbara Ericson

Field Summary
static int ALTO_SAX
           
static int APPLAUSE
           
static int BASS
           
static int BIRD
           
static int CELLO
           
static int CLARINET
           
static int FLUTE
           
static int FRENCH_HORN
           
static int GUITAR
           
static int HARMONICA
           
static int HARP
           
static int HELICOPTER
           
static int ICE_CUBE
           
static int JAZZ_GUITAR
           
static int MUSIC_BOX
           
static int OBOE
           
static int PIANO
           
static int PICCOLO
           
static int STEEL_GUITAR
           
static int TELEPHONE
           
static int TENOR_SAX
           
static int TIMPANI
           
static int TROMBONE
           
static int TRUMPET
           
static int TUBA
           
static int VIOLIN
           
static int WHISTLE
           
static int XYLOPHONE
           
 
Constructor Summary
MidiPlayer()
          Constructor that takes no arguments
 
Method Summary
 void cleanUp()
          Method to clean up the midi player
 void close()
          Method to close the midi player
 void getInstrumentNames()
          Method to get the map of index number to instrument names
 javax.sound.midi.Synthesizer getSynthesizer()
          Method to return the synthesizer
 void playJingleBells()
          Method to play Jingle Bells
 void playJingleBells4()
          Method to play the first 4 measures of jingle bells with each measure taking 1000 milliseconds (1 second)
 void playJingleBellsV1V2()
          Method to play the first verse of jingle bells with each measure taking 1000 milliseconds (1 second) It is in 2/4 time
 void playNote(int note, int duration)
          Method to play a note
 void playNote(int note, int duration, int intensity)
          Method to play a note
 void playNotesOnChannel(int index, int[] notes, int[] durations, int[] intensities)
          Method to play an array of notes with the given durations and intensities
 void rest(int duration)
          Method to rest for a specified number of milliseconds
 void setChannel(int index)
          Method to change the current channel
 void setInstrument(int num)
          Method to set the instrument to play
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PIANO

public static final int PIANO
See Also:
Constant Field Values

HARMONICA

public static final int HARMONICA
See Also:
Constant Field Values

MUSIC_BOX

public static final int MUSIC_BOX
See Also:
Constant Field Values

XYLOPHONE

public static final int XYLOPHONE
See Also:
Constant Field Values

GUITAR

public static final int GUITAR
See Also:
Constant Field Values

STEEL_GUITAR

public static final int STEEL_GUITAR
See Also:
Constant Field Values

JAZZ_GUITAR

public static final int JAZZ_GUITAR
See Also:
Constant Field Values

BASS

public static final int BASS
See Also:
Constant Field Values

VIOLIN

public static final int VIOLIN
See Also:
Constant Field Values

CELLO

public static final int CELLO
See Also:
Constant Field Values

HARP

public static final int HARP
See Also:
Constant Field Values

TIMPANI

public static final int TIMPANI
See Also:
Constant Field Values

TRUMPET

public static final int TRUMPET
See Also:
Constant Field Values

TROMBONE

public static final int TROMBONE
See Also:
Constant Field Values

TUBA

public static final int TUBA
See Also:
Constant Field Values

FRENCH_HORN

public static final int FRENCH_HORN
See Also:
Constant Field Values

ALTO_SAX

public static final int ALTO_SAX
See Also:
Constant Field Values

TENOR_SAX

public static final int TENOR_SAX
See Also:
Constant Field Values

OBOE

public static final int OBOE
See Also:
Constant Field Values

CLARINET

public static final int CLARINET
See Also:
Constant Field Values

PICCOLO

public static final int PICCOLO
See Also:
Constant Field Values

FLUTE

public static final int FLUTE
See Also:
Constant Field Values

WHISTLE

public static final int WHISTLE
See Also:
Constant Field Values

BIRD

public static final int BIRD
See Also:
Constant Field Values

TELEPHONE

public static final int TELEPHONE
See Also:
Constant Field Values

HELICOPTER

public static final int HELICOPTER
See Also:
Constant Field Values

APPLAUSE

public static final int APPLAUSE
See Also:
Constant Field Values

ICE_CUBE

public static final int ICE_CUBE
See Also:
Constant Field Values
Constructor Detail

MidiPlayer

public MidiPlayer()
Constructor that takes no arguments

Method Detail

getSynthesizer

public javax.sound.midi.Synthesizer getSynthesizer()
Method to return the synthesizer

Returns:
the synthesizer

close

public void close()
Method to close the midi player


cleanUp

public void cleanUp()
Method to clean up the midi player


playNote

public void playNote(int note,
                     int duration,
                     int intensity)
Method to play a note

Parameters:
note - the note to play (0 to 127, 60 is middle C)
duration - how long to play the note in milliseconds
intensity - how loud to play the note (how hard the key was struck on a piano)

rest

public void rest(int duration)
Method to rest for a specified number of milliseconds

Parameters:
duration - the amount to rest in milliseconds

setChannel

public void setChannel(int index)
Method to change the current channel

Parameters:
index - the index of the channel to use

setInstrument

public void setInstrument(int num)
Method to set the instrument to play

Parameters:
num - a number from 0 to 127 that represents the instruments

getInstrumentNames

public void getInstrumentNames()
Method to get the map of index number to instrument names


playNote

public void playNote(int note,
                     int duration)
Method to play a note

Parameters:
note - the note to play
duration - how long to play the note

playNotesOnChannel

public void playNotesOnChannel(int index,
                               int[] notes,
                               int[] durations,
                               int[] intensities)
Method to play an array of notes with the given durations and intensities

Parameters:
index - the index of the channel 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)

playJingleBellsV1V2

public void playJingleBellsV1V2()
Method to play the first verse of jingle bells with each measure taking 1000 milliseconds (1 second) It is in 2/4 time


playJingleBells

public void playJingleBells()
Method to play Jingle Bells


playJingleBells4

public void playJingleBells4()
Method to play the first 4 measures of jingle bells with each measure taking 1000 milliseconds (1 second)