src/share/classes/javax/sound/midi/MidiEvent.java

Print this page


   1 /*
   2  * Copyright (c) 1999, 2002, Oracle and/or its affiliates. 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.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package 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  */
  43 public 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 }
   1 /*
   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.
   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.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.sound.midi;
  27 
  28 /**
  29  * MIDI events contain a MIDI message and a corresponding time-stamp expressed
  30  * in ticks, and can represent the MIDI event information stored in a MIDI file
  31  * or a {@link Sequence} object. The duration of a tick is specified by the
  32  * timing information contained in the MIDI file or {@code Sequence} object.

  33  * <p>
  34  * In Java Sound, {@code MidiEvent} objects are typically contained in a
  35  * {@link Track}, and {@code Tracks} are likewise contained in a
  36  * {@code Sequence}.

  37  *
  38  * @author David Rivas
  39  * @author Kara Kytle
  40  */
  41 public class MidiEvent {
  42 



  43     /**
  44      * The MIDI message for this event.
  45      */
  46     private final MidiMessage message;
  47 

  48     /**
  49      * The tick value for this event.
  50      */
  51     private long tick;
  52 

  53     /**
  54      * Constructs a new {@code MidiEvent}.
  55      *
  56      * @param  message the MIDI message contained in the event
  57      * @param  tick the time-stamp for the event, in MIDI ticks
  58      */
  59     public MidiEvent(MidiMessage message, long tick) {
  60 
  61         this.message = message;
  62         this.tick = tick;
  63     }
  64 
  65     /**
  66      * Obtains the MIDI message contained in the event.
  67      *
  68      * @return the MIDI message
  69      */
  70     public MidiMessage getMessage() {
  71         return message;
  72     }
  73 

  74     /**
  75      * Sets the time-stamp for the event, in MIDI ticks.
  76      *
  77      * @param  tick the new time-stamp, in MIDI ticks
  78      */
  79     public void setTick(long tick) {
  80         this.tick = tick;
  81     }
  82 

  83     /**
  84      * Obtains the time-stamp for the event, in MIDI ticks.
  85      *
  86      * @return the time-stamp for the event, in MIDI ticks
  87      */
  88     public long getTick() {
  89         return tick;
  90     }
  91 }