java.lang.Runnable
public class SynthNote extends java.lang.Object implements java.lang.Runnable
This program is based loosely on SynthNote which can be found at http://www.jsresources.org/examples/SynthNote.java.html. However, it has been heavily modified to reduce the need on third-party libraries and to make it more understandable.
Modifier and Type | Field | Description |
---|---|---|
(package private) java.util.List<javax.sound.midi.MidiDevice> |
devices |
|
(package private) javax.sound.midi.MidiDevice.Info[] |
infos |
|
(package private) int |
NOTE_OFF |
|
(package private) int |
NOTE_ON |
|
(package private) int |
PROGRAM_CHANGE |
|
(package private) javax.sound.midi.Receiver |
receiver |
|
(package private) javax.sound.midi.Synthesizer |
synthesizer |
Constructor | Description |
---|---|
SynthNote() |
Modifier and Type | Method | Description |
---|---|---|
static void |
main(java.lang.String[] args) |
Test driver.
|
void |
run() |
|
protected void |
sendChord(int note,
int length) |
Send a chord.
|
protected void |
sendNote(int note,
int length) |
Play a note
|
java.util.List<javax.sound.midi.MidiDevice> devices
javax.sound.midi.MidiDevice.Info[] infos
javax.sound.midi.Synthesizer synthesizer
javax.sound.midi.Receiver receiver
int PROGRAM_CHANGE
int NOTE_ON
int NOTE_OFF
public SynthNote()
public void run()
run
in interface java.lang.Runnable
protected void sendNote(int note, int length) throws javax.sound.midi.MidiUnavailableException, javax.sound.midi.InvalidMidiDataException
note
- note to be playedlength
- length of note in millisecondsjavax.sound.midi.MidiUnavailableException
javax.sound.midi.InvalidMidiDataException
protected void sendChord(int note, int length) throws javax.sound.midi.MidiUnavailableException, javax.sound.midi.InvalidMidiDataException
note
- base notelength
- length of chord in millisecondsjavax.sound.midi.MidiUnavailableException
javax.sound.midi.InvalidMidiDataException
public static void main(java.lang.String[] args)
args
- not usedCopyright © 2017. All rights reserved.