1 /* |
1 /* |
2 * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
24 */ |
24 */ |
25 |
25 |
26 package javax.sound.midi; |
26 package javax.sound.midi; |
27 |
27 |
28 /** |
28 /** |
29 * MIDI events contain a MIDI message and a corresponding time-stamp |
29 * MIDI events contain a MIDI message and a corresponding time-stamp expressed |
30 * expressed in ticks, and can represent the MIDI event information |
30 * in ticks, and can represent the MIDI event information stored in a MIDI file |
31 * stored in a MIDI file or a <code>{@link Sequence}</code> object. The |
31 * or a {@link Sequence} object. The duration of a tick is specified by the |
32 * duration of a tick is specified by the timing information contained |
32 * timing information contained in the MIDI file or {@code Sequence} object. |
33 * in the MIDI file or <code>Sequence</code> object. |
|
34 * <p> |
33 * <p> |
35 * In Java Sound, <code>MidiEvent</code> objects are typically contained in a |
34 * In Java Sound, {@code MidiEvent} objects are typically contained in a |
36 * <code>{@link Track}</code>, and <code>Tracks</code> are likewise |
35 * {@link Track}, and {@code Tracks} are likewise contained in a |
37 * contained in a <code>Sequence</code>. |
36 * {@code Sequence}. |
38 * |
|
39 * |
37 * |
40 * @author David Rivas |
38 * @author David Rivas |
41 * @author Kara Kytle |
39 * @author Kara Kytle |
42 */ |
40 */ |
43 public class MidiEvent { |
41 public class MidiEvent { |
44 |
42 |
45 |
|
46 // Instance variables |
|
47 |
|
48 /** |
43 /** |
49 * The MIDI message for this event. |
44 * The MIDI message for this event. |
50 */ |
45 */ |
51 private final MidiMessage message; |
46 private final MidiMessage message; |
52 |
|
53 |
47 |
54 /** |
48 /** |
55 * The tick value for this event. |
49 * The tick value for this event. |
56 */ |
50 */ |
57 private long tick; |
51 private long tick; |
58 |
52 |
59 |
|
60 /** |
53 /** |
61 * Constructs a new <code>MidiEvent</code>. |
54 * Constructs a new {@code MidiEvent}. |
62 * @param message the MIDI message contained in the event |
55 * |
63 * @param tick the time-stamp for the event, in MIDI ticks |
56 * @param message the MIDI message contained in the event |
|
57 * @param tick the time-stamp for the event, in MIDI ticks |
64 */ |
58 */ |
65 public MidiEvent(MidiMessage message, long tick) { |
59 public MidiEvent(MidiMessage message, long tick) { |
66 |
60 |
67 this.message = message; |
61 this.message = message; |
68 this.tick = tick; |
62 this.tick = tick; |
69 } |
63 } |
70 |
64 |
71 /** |
65 /** |
72 * Obtains the MIDI message contained in the event. |
66 * Obtains the MIDI message contained in the event. |
|
67 * |
73 * @return the MIDI message |
68 * @return the MIDI message |
74 */ |
69 */ |
75 public MidiMessage getMessage() { |
70 public MidiMessage getMessage() { |
76 return message; |
71 return message; |
77 } |
72 } |
78 |
73 |
79 |
|
80 /** |
74 /** |
81 * Sets the time-stamp for the event, in MIDI ticks |
75 * Sets the time-stamp for the event, in MIDI ticks. |
82 * @param tick the new time-stamp, in MIDI ticks |
76 * |
|
77 * @param tick the new time-stamp, in MIDI ticks |
83 */ |
78 */ |
84 public void setTick(long tick) { |
79 public void setTick(long tick) { |
85 this.tick = tick; |
80 this.tick = tick; |
86 } |
81 } |
87 |
82 |
88 |
|
89 /** |
83 /** |
90 * Obtains the time-stamp for the event, in MIDI ticks |
84 * Obtains the time-stamp for the event, in MIDI ticks. |
|
85 * |
91 * @return the time-stamp for the event, in MIDI ticks |
86 * @return the time-stamp for the event, in MIDI ticks |
92 */ |
87 */ |
93 public long getTick() { |
88 public long getTick() { |
94 return tick; |
89 return tick; |
95 } |
90 } |