KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > sound > midi > MidiEvent


1 /*
2  * @(#)MidiEvent.java 1.10 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.sound.midi;
9
10 /**
11  * MIDI events contain a MIDI message and a corresponding time-stamp
12  * expressed in ticks, and can represent the MIDI event information
13  * stored in a MIDI file or a <code>{@link Sequence}</code> object. The
14  * duration of a tick is specified by the timing information contained
15  * in the MIDI file or <code>Sequence</code> object.
16  * <p>
17  * In Java Sound, <code>MidiEvent</code> objects are typically contained in a
18  * <code>{@link Track}</code>, and <code>Tracks</code> are likewise
19  * contained in a <code>Sequence</code>.
20  *
21  *
22  * @version 1.10 03/12/19
23  * @author David Rivas
24  * @author Kara Kytle
25  */

26 public class MidiEvent {
27
28
29     // Instance variables
30

31     /**
32      * The MIDI message for this event.
33      */

34     private final MidiMessage JavaDoc message;
35     
36
37     /**
38      * The tick value for this event.
39      */

40     private long tick;
41
42
43     /**
44      * Constructs a new <code>MidiEvent</code>.
45      * @param message the MIDI message contained in the event
46      * @param tick the time-stamp for the event, in MIDI ticks
47      */

48     public MidiEvent(MidiMessage JavaDoc message, long tick) {
49
50     this.message = message;
51     this.tick = tick;
52     }
53
54     /**
55      * Obtains the MIDI message contained in the event.
56      * @return the MIDI message
57      */

58     public MidiMessage JavaDoc getMessage() {
59     return message;
60     }
61
62
63     /**
64      * Sets the time-stamp for the event, in MIDI ticks
65      * @param tick the new time-stamp, in MIDI ticks
66      */

67     public void setTick(long tick) {
68     this.tick = tick;
69     }
70
71     
72     /**
73      * Obtains the time-stamp for the event, in MIDI ticks
74      * @return the time-stamp for the event, in MIDI ticks
75      */

76     public long getTick() {
77     return tick;
78     }
79 }
80
Popular Tags