blob: b0201abdf5c360215a19561a5da3a07508bf7cfa [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 1999-2002 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26package javax.sound.midi;
27
28/**
29 * MIDI events contain a MIDI message and a corresponding time-stamp
30 * expressed in ticks, and can represent the MIDI event information
31 * stored in a MIDI file or a <code>{@link Sequence}</code> object. The
32 * duration of a tick is specified by the timing information contained
33 * in the MIDI file or <code>Sequence</code> object.
34 * <p>
35 * In Java Sound, <code>MidiEvent</code> objects are typically contained in a
36 * <code>{@link Track}</code>, and <code>Tracks</code> are likewise
37 * contained in a <code>Sequence</code>.
38 *
39 *
40 * @author David Rivas
41 * @author Kara Kytle
42 */
43public class MidiEvent {
44
45
46 // Instance variables
47
48 /**
49 * The MIDI message for this event.
50 */
51 private final MidiMessage message;
52
53
54 /**
55 * The tick value for this event.
56 */
57 private long tick;
58
59
60 /**
61 * Constructs a new <code>MidiEvent</code>.
62 * @param message the MIDI message contained in the event
63 * @param tick the time-stamp for the event, in MIDI ticks
64 */
65 public MidiEvent(MidiMessage message, long tick) {
66
67 this.message = message;
68 this.tick = tick;
69 }
70
71 /**
72 * Obtains the MIDI message contained in the event.
73 * @return the MIDI message
74 */
75 public MidiMessage getMessage() {
76 return message;
77 }
78
79
80 /**
81 * Sets the time-stamp for the event, in MIDI ticks
82 * @param tick the new time-stamp, in MIDI ticks
83 */
84 public void setTick(long tick) {
85 this.tick = tick;
86 }
87
88
89 /**
90 * Obtains the time-stamp for the event, in MIDI ticks
91 * @return the time-stamp for the event, in MIDI ticks
92 */
93 public long getTick() {
94 return tick;
95 }
96}