Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## jcontrol.toolkit
Class iMelody

    java.lang.Object
      jcontrol.toolkit.iMelody

All Implemented Interfaces:
  Runnable

    public class iMelody

extends Object
implements Runnable

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

See Also:
  `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

### NORMAL

    public static final byte NORMAL

  Normal mode

  See Also:
    `setStyle(int)`, Constant Field Values

### CONT

    public static final byte CONT

  Continuous mode

  See Also:
    `setStyle(int)`, Constant Field Values

### STACC

    public static final byte STACC

  Staccato mode

  See Also:
    `setStyle(int)`, Constant Field Values

Constructor Detail

### iMelody

    public iMelody(String melody)

  Creates a new iMelody object using a string and the default system buzzer.

  Parameters:
    `melody` - the complete melody string to play

### iMelody

    public iMelody(Resource res)

  Creates a new iMelody object using a resource and the default system buzzer.

  This should be the prefered way to play iMelody sounds as the note data will be read directly from the resource.

  Parameters:
    `res` - a Resource specifying an iMelody (`.imy`) file.

### iMelody

    public iMelody(SoundDevice sound,
                   Resource res)

  Creates a new iMelody object using a resource and a spcific sound device.

  This should be the prefered way to play iMelody sounds as the note data will be read directly from the resource.

  Parameters:
    `sound` - the `SoundDevice` tu use
    `res` - a Resource specifying an iMelody (`.imy`) file.

Method Detail

### setNotes

    public void setNotes(String melody)

  Set the melody string.

  Parameters:
    `melody` - the complete melody string to play

### setBeat

    public void setBeat(int beat)

  Set the beat.

  Parameters:
    `beat` - beats per minute

### setStyle

    public void setStyle(int style)

  Set the music style.

  Parameters:
    `style` - one of `NORMAL`, `STACC` or `CONT`

### stop

    public void stop()

  Stops the music playing.

### isPlaying

    public boolean isPlaying()

### run

    public void run()

  Play the specified melody.

  Specified by:
    `run` in interface `Runnable`
  See Also:
    `Thread.run()`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD