com.siemens.mp.game
Class MelodyComposer

java.lang.Object
  extended bycom.siemens.mp.game.MelodyComposer

public class MelodyComposer
extends Object

This class implements a melody composing facility.

The user can compose a melody using predefined tones and tonelengths, set beats per minute and then get the resulting Melody object for playing.

Example


Field Summary
static int BPM
          Default beats per minute
static int NO_TONE
          special constant: No tone
static int TONE_A0
          A note, octave 0
static int TONE_A1
          A note, octave 1
static int TONE_A2
          A note, octave 2
static int TONE_A3
          A note, octave 3
static int TONE_A4
          A note, octave 4
static int TONE_AIS0
          A# note, octave 0
static int TONE_AIS1
          A# note, octave 1
static int TONE_AIS2
          A# note, octave 2
static int TONE_AIS3
          A# note, octave 3
static int TONE_C0
          C note, octave 0
static int TONE_C1
          C note, octave 1
static int TONE_C2
          C note, octave 2
static int TONE_C3
          C note, octave 3
static int TONE_C4
          C note, octave 4
static int TONE_CIS0
          C# note, octave 0
static int TONE_CIS1
          C# note, octave 1
static int TONE_CIS2
          C# note, octave 2
static int TONE_CIS3
          C# note, octave 3
static int TONE_CIS4
          C# note, octave 4
static int TONE_D0
          D note, octave 0
static int TONE_D1
          D note, octave 1
static int TONE_D2
          D note, octave 2
static int TONE_D3
          D note, octave 3
static int TONE_D4
          D note, octave 4
static int TONE_DIS0
          D# note, octave 0
static int TONE_DIS1
          D# note, octave 1
static int TONE_DIS2
          D# note, octave 2
static int TONE_DIS3
          D# note, octave 3
static int TONE_DIS4
          D# note, octave 4
static int TONE_E0
          E note, octave 0
static int TONE_E1
          E note, octave 1
static int TONE_E2
          E note, octave 2
static int TONE_E3
          E note, octave 3
static int TONE_E4
          E note, octave 4
static int TONE_F0
          F note, octave 0
static int TONE_F1
          F note, octave 1
static int TONE_F2
          F note, octave 2
static int TONE_F3
          F note, octave 3
static int TONE_F4
          F note, octave 4
static int TONE_FIS0
          F# note, octave 0
static int TONE_FIS1
          F# note, octave 1
static int TONE_FIS2
          F# note, octave 2
static int TONE_FIS3
          F# note, octave 3
static int TONE_FIS4
          F# note, octave 4
static int TONE_G0
          G note, octave 0
static int TONE_G1
          G note, octave 1
static int TONE_G2
          G note, octave 2
static int TONE_G3
          G note, octave 3
static int TONE_G4
          G note, octave 4
static int TONE_GIS0
          G# note, octave 0
static int TONE_GIS1
          G# note, octave 1
static int TONE_GIS2
          G# note, octave 2
static int TONE_GIS3
          G# note, octave 3
static int TONE_GIS4
          G# note, octave 4
static int TONE_H0
          H note, octave 0
static int TONE_H1
          H note, octave 1
static int TONE_H2
          H note, octave 2
static int TONE_H3
          H note, octave 3
static int TONE_MARK
          special constant: Sets a marker as starting point of the following repeat variants
static int TONE_PAUSE
          special constant: pause
static int TONE_REPEAT
          special constant: REPEAT n times from the very beginning
please use an integer value for "n" in the length parameter!
static int TONE_REPEAT_MARK
          special constant: REPEAT n times from the preceding TONE_MARK
please use an integer value for "n" in the length parameter!
static int TONE_REPEV
          special constant: REPEAT forever from the very beginning
static int TONE_REPEV_MARK
          special constant: REPEAT forever from the preceding TONE_MARK
static int TONE_REPON
          special constant: REPEAT n times from the very beginning, then go ON
please use an integer value for "n" in the length parameter!
static int TONE_REPON_MARK
          special constant: REPEAT n times from the preceding TONE_MARK, then go ON
please use an integer value for "n" in the length parameter!
static int TONE_STOP
          special constant: STOP the tone sequence
static int TONELENGTH_1_1
          whole note tone length
static int TONELENGTH_1_16
          1/16 note tone length
static int TONELENGTH_1_2
          1/2 note tone length
static int TONELENGTH_1_32
          1/32 note tone length
static int TONELENGTH_1_4
          1/4 note tone length
static int TONELENGTH_1_64
          1/64 note tone length
static int TONELENGTH_1_8
          1/8 note tone length
static int TONELENGTH_DOTTED_1_1
          whole note dotted tone length
static int TONELENGTH_DOTTED_1_16
          1/16 note dotted tone length
static int TONELENGTH_DOTTED_1_2
          1/2 note dotted tone length
static int TONELENGTH_DOTTED_1_32
          1/32 note dotted tone length
static int TONELENGTH_DOTTED_1_4
          1/4 note dotted tone length
static int TONELENGTH_DOTTED_1_64
          1/64 note dotted tone length
static int TONELENGTH_DOTTED_1_8
          1/8 note dotted tone length
 
Constructor Summary
MelodyComposer()
          Creates a MelodyComposer object.
MelodyComposer(int[] notes, int bpm)
          Creates a MelodyComposer object and initializes it with the provided melody and beats-per-minute value.
 
Method Summary
 void appendNote(int note, int length)
          Appends to the melody one note with specified tone and length, or one special constant.
 Melody getMelody()
          Returns the composed Melody object.
 int length()
          Counts the tones in the composed melody.
static int maxLength()
          Returns the maximum possible size of a melody in tones
 void resetMelody()
          Resets the composed melody and makes it empty.
 void setBPM(int bpm)
          Sets beats per minute (default: 60).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TONE_C0

public static final int TONE_C0
C note, octave 0

See Also:
Constant Field Values

TONE_CIS0

public static final int TONE_CIS0
C# note, octave 0

See Also:
Constant Field Values

TONE_D0

public static final int TONE_D0
D note, octave 0

See Also:
Constant Field Values

TONE_DIS0

public static final int TONE_DIS0
D# note, octave 0

See Also:
Constant Field Values

TONE_E0

public static final int TONE_E0
E note, octave 0

See Also:
Constant Field Values

TONE_F0

public static final int TONE_F0
F note, octave 0

See Also:
Constant Field Values

TONE_FIS0

public static final int TONE_FIS0
F# note, octave 0

See Also:
Constant Field Values

TONE_G0

public static final int TONE_G0
G note, octave 0

See Also:
Constant Field Values

TONE_GIS0

public static final int TONE_GIS0
G# note, octave 0

See Also:
Constant Field Values

TONE_A0

public static final int TONE_A0
A note, octave 0

See Also:
Constant Field Values

TONE_AIS0

public static final int TONE_AIS0
A# note, octave 0

See Also:
Constant Field Values

TONE_H0

public static final int TONE_H0
H note, octave 0

See Also:
Constant Field Values

TONE_C1

public static final int TONE_C1
C note, octave 1

See Also:
Constant Field Values

TONE_CIS1

public static final int TONE_CIS1
C# note, octave 1

See Also:
Constant Field Values

TONE_D1

public static final int TONE_D1
D note, octave 1

See Also:
Constant Field Values

TONE_DIS1

public static final int TONE_DIS1
D# note, octave 1

See Also:
Constant Field Values

TONE_E1

public static final int TONE_E1
E note, octave 1

See Also:
Constant Field Values

TONE_F1

public static final int TONE_F1
F note, octave 1

See Also:
Constant Field Values

TONE_FIS1

public static final int TONE_FIS1
F# note, octave 1

See Also:
Constant Field Values

TONE_G1

public static final int TONE_G1
G note, octave 1

See Also:
Constant Field Values

TONE_GIS1

public static final int TONE_GIS1
G# note, octave 1

See Also:
Constant Field Values

TONE_A1

public static final int TONE_A1
A note, octave 1

See Also:
Constant Field Values

TONE_AIS1

public static final int TONE_AIS1
A# note, octave 1

See Also:
Constant Field Values

TONE_H1

public static final int TONE_H1
H note, octave 1

See Also:
Constant Field Values

TONE_C2

public static final int TONE_C2
C note, octave 2

See Also:
Constant Field Values

TONE_CIS2

public static final int TONE_CIS2
C# note, octave 2

See Also:
Constant Field Values

TONE_D2

public static final int TONE_D2
D note, octave 2

See Also:
Constant Field Values

TONE_DIS2

public static final int TONE_DIS2
D# note, octave 2

See Also:
Constant Field Values

TONE_E2

public static final int TONE_E2
E note, octave 2

See Also:
Constant Field Values

TONE_F2

public static final int TONE_F2
F note, octave 2

See Also:
Constant Field Values

TONE_FIS2

public static final int TONE_FIS2
F# note, octave 2

See Also:
Constant Field Values

TONE_G2

public static final int TONE_G2
G note, octave 2

See Also:
Constant Field Values

TONE_GIS2

public static final int TONE_GIS2
G# note, octave 2

See Also:
Constant Field Values

TONE_A2

public static final int TONE_A2
A note, octave 2

See Also:
Constant Field Values

TONE_AIS2

public static final int TONE_AIS2
A# note, octave 2

See Also:
Constant Field Values

TONE_H2

public static final int TONE_H2
H note, octave 2

See Also:
Constant Field Values

TONE_C3

public static final int TONE_C3
C note, octave 3

See Also:
Constant Field Values

TONE_CIS3

public static final int TONE_CIS3
C# note, octave 3

See Also:
Constant Field Values

TONE_D3

public static final int TONE_D3
D note, octave 3

See Also:
Constant Field Values

TONE_DIS3

public static final int TONE_DIS3
D# note, octave 3

See Also:
Constant Field Values

TONE_E3

public static final int TONE_E3
E note, octave 3

See Also:
Constant Field Values

TONE_F3

public static final int TONE_F3
F note, octave 3

See Also:
Constant Field Values

TONE_FIS3

public static final int TONE_FIS3
F# note, octave 3

See Also:
Constant Field Values

TONE_G3

public static final int TONE_G3
G note, octave 3

See Also:
Constant Field Values

TONE_GIS3

public static final int TONE_GIS3
G# note, octave 3

See Also:
Constant Field Values

TONE_A3

public static final int TONE_A3
A note, octave 3

See Also:
Constant Field Values

TONE_AIS3

public static final int TONE_AIS3
A# note, octave 3

See Also:
Constant Field Values

TONE_H3

public static final int TONE_H3
H note, octave 3

See Also:
Constant Field Values

TONE_C4

public static final int TONE_C4
C note, octave 4

See Also:
Constant Field Values

TONE_CIS4

public static final int TONE_CIS4
C# note, octave 4

See Also:
Constant Field Values

TONE_D4

public static final int TONE_D4
D note, octave 4

See Also:
Constant Field Values

TONE_DIS4

public static final int TONE_DIS4
D# note, octave 4

See Also:
Constant Field Values

TONE_E4

public static final int TONE_E4
E note, octave 4

See Also:
Constant Field Values

TONE_F4

public static final int TONE_F4
F note, octave 4

See Also:
Constant Field Values

TONE_FIS4

public static final int TONE_FIS4
F# note, octave 4

See Also:
Constant Field Values

TONE_G4

public static final int TONE_G4
G note, octave 4

See Also:
Constant Field Values

TONE_GIS4

public static final int TONE_GIS4
G# note, octave 4

See Also:
Constant Field Values

TONE_A4

public static final int TONE_A4
A note, octave 4

See Also:
Constant Field Values

TONE_PAUSE

public static final int TONE_PAUSE
special constant: pause

See Also:
Constant Field Values

NO_TONE

public static final int NO_TONE
special constant: No tone

See Also:
Constant Field Values

TONE_STOP

public static final int TONE_STOP
special constant: STOP the tone sequence

See Also:
Constant Field Values

TONE_REPEAT

public static final int TONE_REPEAT
special constant: REPEAT n times from the very beginning
please use an integer value for "n" in the length parameter!

See Also:
Constant Field Values

TONE_REPEV

public static final int TONE_REPEV
special constant: REPEAT forever from the very beginning

See Also:
Constant Field Values

TONE_REPON

public static final int TONE_REPON
special constant: REPEAT n times from the very beginning, then go ON
please use an integer value for "n" in the length parameter!

See Also:
Constant Field Values

TONE_MARK

public static final int TONE_MARK
special constant: Sets a marker as starting point of the following repeat variants

See Also:
Constant Field Values

TONE_REPEAT_MARK

public static final int TONE_REPEAT_MARK
special constant: REPEAT n times from the preceding TONE_MARK
please use an integer value for "n" in the length parameter!

See Also:
Constant Field Values

TONE_REPEV_MARK

public static final int TONE_REPEV_MARK
special constant: REPEAT forever from the preceding TONE_MARK

See Also:
Constant Field Values

TONE_REPON_MARK

public static final int TONE_REPON_MARK
special constant: REPEAT n times from the preceding TONE_MARK, then go ON
please use an integer value for "n" in the length parameter!

See Also:
Constant Field Values

TONELENGTH_1_1

public static final int TONELENGTH_1_1
whole note tone length

See Also:
Constant Field Values

TONELENGTH_1_2

public static final int TONELENGTH_1_2
1/2 note tone length

See Also:
Constant Field Values

TONELENGTH_1_4

public static final int TONELENGTH_1_4
1/4 note tone length

See Also:
Constant Field Values

TONELENGTH_1_8

public static final int TONELENGTH_1_8
1/8 note tone length

See Also:
Constant Field Values

TONELENGTH_1_16

public static final int TONELENGTH_1_16
1/16 note tone length

See Also:
Constant Field Values

TONELENGTH_1_32

public static final int TONELENGTH_1_32
1/32 note tone length

See Also:
Constant Field Values

TONELENGTH_1_64

public static final int TONELENGTH_1_64
1/64 note tone length

See Also:
Constant Field Values

TONELENGTH_DOTTED_1_1

public static final int TONELENGTH_DOTTED_1_1
whole note dotted tone length

See Also:
Constant Field Values

TONELENGTH_DOTTED_1_2

public static final int TONELENGTH_DOTTED_1_2
1/2 note dotted tone length

See Also:
Constant Field Values

TONELENGTH_DOTTED_1_4

public static final int TONELENGTH_DOTTED_1_4
1/4 note dotted tone length

See Also:
Constant Field Values

TONELENGTH_DOTTED_1_8

public static final int TONELENGTH_DOTTED_1_8
1/8 note dotted tone length

See Also:
Constant Field Values

TONELENGTH_DOTTED_1_16

public static final int TONELENGTH_DOTTED_1_16
1/16 note dotted tone length

See Also:
Constant Field Values

TONELENGTH_DOTTED_1_32

public static final int TONELENGTH_DOTTED_1_32
1/32 note dotted tone length

See Also:
Constant Field Values

TONELENGTH_DOTTED_1_64

public static final int TONELENGTH_DOTTED_1_64
1/64 note dotted tone length

See Also:
Constant Field Values

BPM

public static final int BPM
Default beats per minute

See Also:
Constant Field Values
Constructor Detail

MelodyComposer

public MelodyComposer()
Creates a MelodyComposer object.

Example


MelodyComposer

public MelodyComposer(int[] notes,
                      int bpm)
Creates a MelodyComposer object and initializes it with the provided melody and beats-per-minute value.

Parameters:
notes - melody consisting of pairs of tones and corresponding tone lengths
bpm - beats-per-minute value

Example

Method Detail

setBPM

public void setBPM(int bpm)
Sets beats per minute (default: 60).

Parameters:
bpm - new beats per minute value

Example


appendNote

public void appendNote(int note,
                       int length)
                throws Exception
Appends to the melody one note with specified tone and length, or one special constant.

Parameters:
note - a tone or a special constant
length - the tone length or the special constant's parameter

Example

Throws:
Exception

getMelody

public Melody getMelody()
Returns the composed Melody object.

Returns:
the composed Melody object

Example


resetMelody

public void resetMelody()
Resets the composed melody and makes it empty.

Example


length

public int length()
Counts the tones in the composed melody.

Returns:
the size of the composed melody in tones

Example


maxLength

public static int maxLength()
Returns the maximum possible size of a melody in tones

Returns:
the maximum size of a melody in tones

Example



Generated on 2003-10-17For further information and updates, please visit Siemens mobile Developer Portal