1. /*
  2. * @(#)MidiEvent.java 1.9 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.sound.midi;
  8. /**
  9. * MIDI events contain a MIDI message and a corresponding time-stamp
  10. * expressed in ticks, and can represent the MIDI event information
  11. * stored in a MIDI file or a <code>{@link Sequence}</code> object. The
  12. * duration of a tick is specified by the timing information contained
  13. * in the MIDI file or <code>Sequence</code> object.
  14. * <p>
  15. * In Java Sound, <code>MidiEvent</code> objects are typically contained in a
  16. * <code>{@link Track}</code>, and <code>Tracks</code> are likewise
  17. * contained in a <code>Sequence</code>.
  18. *
  19. *
  20. * @version 1.9 03/01/23
  21. * @author David Rivas
  22. * @author Kara Kytle
  23. */
  24. public class MidiEvent {
  25. // Instance variables
  26. /**
  27. * The MIDI message for this event.
  28. */
  29. private final MidiMessage message;
  30. /**
  31. * The tick value for this event.
  32. */
  33. private long tick;
  34. /**
  35. * Constructs a new <code>MidiEvent</code>.
  36. * @param message the MIDI message contained in the event
  37. * @param tick the time-stamp for the event, in MIDI ticks
  38. */
  39. public MidiEvent(MidiMessage message, long tick) {
  40. this.message = message;
  41. this.tick = tick;
  42. }
  43. /**
  44. * Obtains the MIDI message contained in the event.
  45. * @return the MIDI message
  46. */
  47. public MidiMessage getMessage() {
  48. return message;
  49. }
  50. /**
  51. * Sets the time-stamp for the event, in MIDI ticks
  52. * @param tick the new time-stamp, in MIDI ticks
  53. */
  54. public void setTick(long tick) {
  55. this.tick = tick;
  56. }
  57. /**
  58. * Obtains the time-stamp for the event, in MIDI ticks
  59. * @return the time-stamp for the event, in MIDI ticks
  60. */
  61. public long getTick() {
  62. return tick;
  63. }
  64. }