source: trunk/src/org/apollo/meldex/MelodyEvent.java

Last change on this file was 315, checked in by bjn8, 16 years ago

Apollo spin-off added

File size: 1.6 KB
Line 
1package org.apollo.meldex;
2
3import java.io.Serializable;
4
5
6/**
7 * This class represents a single event in a monophonic melody: a pitch-duration pair. This
8 * class is serializable since it must be able to be written to the matching query collection
9 * files.
10 */
11public class MelodyEvent implements Serializable
12{
13
14 private static final long serialVersionUID = -2160853951522226811L;
15
16 /** Melody event type: this event is a rest (has no pitch). */
17 public static final int REST_EVENT = -128;
18 /** Melody event type: this event is a wild (matches any other melody event). */
19 public static final int WILD_EVENT = 128;
20
21 /** The pitch of this melody event, or the event type if it is not a note. */
22 private int pitch;
23 /** The duration of this melody event. */
24 private float duration;
25
26
27 /**
28 * Creates a new melody event.
29 *
30 * @param eventPitch The pitch of the melody event, or the event type if it is not a note.
31 * @param eventDuration The duration of the melody event.
32 */
33 public MelodyEvent(int eventPitch, float eventDuration)
34 {
35 pitch = eventPitch;
36 duration = eventDuration;
37 }
38
39
40 /**
41 * Returns the pitch of the melody event, or the event type if it is not a note.
42 *
43 * @return the pitch of the melody event, or the event type if it is not a note.
44 */
45 public int getPitch()
46 {
47 return pitch;
48 }
49
50
51 /**
52 * Returns the duration of the melody event.
53 *
54 * @return the duration of the melody event.
55 */
56 public float getDuration()
57 {
58 return duration;
59 }
60}
Note: See TracBrowser for help on using the repository browser.