|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jcontrol.toolkit.iMelody
public class iMelody
This class iMelody.class
is used to play a set of tones using a buzzer.
The iMelody format is compatible with the iMelody format specified by Infrared Data Association (IrDA).
<melody> ::= {<silence>|<note>|<repeat>}+
<silence> ::= <rest><duration>[<duration-specifier>]
<rest> ::= "r"
<repeat> ::= "("{<silence>|<note>}+"@"<repeat-count>")"
<repeat-count> ::= "0"|"1"|"2"|... (0 is repeat forever)
<note> ::= [<octave-prefix>]<basic-ess-iss-note><duration>[<duration-specifier>]
<duration> ::= "0"|"1"|"2"|"3"|"4"|"5"
<duration-specifier> ::= "."|":"|";"
<octave-prefix> ::= "*0"|"*1"|"*2"...
<basic-ess-iss-note> ::= <basic-note>|<ess-note>|<iss-note>
<basic-note> ::= "c"|"d"|"e"|"f"|"g"|"a"|"b"
<ess-note> ::= "&d"|"&e"|"&g"|"&a"|"&b" (flat notes)
<iss-note> ::= "#c"|"#d"|"#f"|"#g"|"#a" (sharp notes)
Note: No <repeat> block within <repeat> block!
Duration:
0 - Full-note
1 - 1/2-note
2 - 1/4-note
3 - 1/8-note
4 - 1/16-note
5 - 1/32-note
Duration Specifier:
none - No special duration
. - Dotted note
: - Double dotted note
; - 2/3 length
jcontrol.io.PWM
Field Summary | |
---|---|
static byte |
CONT
Continuous mode |
static byte |
NORMAL
Normal mode |
static byte |
STACC
Staccato mode |
Constructor Summary | |
---|---|
iMelody(Resource res)
Creates a new iMelody object using a resource and the default system buzzer. |
|
iMelody(SoundDevice sound,
Resource res)
Creates a new iMelody object using a resource and a spcific sound device. |
|
iMelody(String melody)
Creates a new iMelody object using a string and the default system buzzer. |
Method Summary | |
---|---|
boolean |
isPlaying()
|
void |
run()
Play the specified melody. |
void |
setBeat(int beat)
Set the beat. |
void |
setNotes(String melody)
Set the melody string. |
void |
setStyle(int style)
Set the music style. |
void |
stop()
Stops the music playing. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, notifyAll, toString, wait |
Field Detail |
---|
public static final byte NORMAL
setStyle(int)
,
Constant Field Valuespublic static final byte CONT
setStyle(int)
,
Constant Field Valuespublic static final byte STACC
setStyle(int)
,
Constant Field ValuesConstructor Detail |
---|
public iMelody(String melody)
melody
- the complete melody string to playpublic iMelody(Resource res)
This should be the prefered way to play iMelody sounds as the note data will be read directly from the resource.
res
- a Resource specifying an iMelody (.imy
) file.public iMelody(SoundDevice sound, Resource res)
This should be the prefered way to play iMelody sounds as the note data will be read directly from the resource.
sound
- the SoundDevice
tu useres
- a Resource specifying an iMelody (.imy
) file.Method Detail |
---|
public void setNotes(String melody)
melody
- the complete melody string to playpublic void setBeat(int beat)
beat
- beats per minutepublic void setStyle(int style)
style
- one of NORMAL
, STACC
or CONT
public void stop()
public boolean isPlaying()
public void run()
run
in interface Runnable
Thread.run()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |