< prev index next >

src/java.desktop/share/classes/com/sun/media/sound/MidiUtils.java

Print this page

        

@@ -75,11 +75,10 @@
         // now get message and check for end of track
         byte[] msg = midiMsg.getMessage();
         return ((msg[1] & 0xFF) == META_END_OF_TRACK_TYPE) && (msg[2] == 0);
     }
 
-
     /** return if the given message is a meta tempo message */
     public static boolean isMetaTempo(MidiMessage midiMsg) {
         // first check if it is a META message at all
         if (midiMsg.getLength() != 6
             || midiMsg.getStatus() != MetaMessage.META) {

@@ -89,11 +88,10 @@
         byte[] msg = midiMsg.getMessage();
         // meta type must be 0x51, and data length must be 3
         return ((msg[1] & 0xFF) == META_TEMPO_TYPE) && (msg[2] == 3);
     }
 
-
     /** parses this message for a META tempo message and returns
      * the tempo in MPQ, or -1 if this isn't a tempo message
      */
     public static int getTempoMPQ(MidiMessage midiMsg) {
         // first check if it is a META message at all

@@ -109,11 +107,10 @@
                     | ((msg[4] & 0xFF) << 8)
                     | ((msg[3] & 0xFF) << 16);
         return tempo;
     }
 
-
     /**
      * converts<br>
      * 1 - MPQ-Tempo to BPM tempo<br>
      * 2 - BPM tempo to MPQ tempo<br>
      */

@@ -122,11 +119,10 @@
             tempo = 1;
         }
         return ((double) 60000000l) / tempo;
     }
 
-
     /**
      * convert tick to microsecond with given tempo.
      * Does not take tempo changes into account.
      * Does not work for SMPTE timing!
      */

@@ -143,11 +139,10 @@
         // do not round to nearest tick
         //return (long) Math.round((((double)us) * resolution) / tempoMPQ);
         return (long) ((((double)us) * resolution) / tempoMPQ);
     }
 
-
     /**
      * Given a tick, convert to microsecond
      * @param cache tempo info and current tempo
      */
     public static long tick2microsecond(Sequence seq, long tick, TempoCache cache) {

@@ -244,11 +239,10 @@
         }
         cache.currTempo = tempos[i - 1];
         return tick;
     }
 
-
     /**
      * Binary search for the event indexes of the track
      *
      * @param tick  tick number of index to be found in array
      * @return index in track which is on or after "tick".

@@ -281,11 +275,10 @@
             }
         }
         return ret;
     }
 
-
     public static final class TempoCache {
         long[] ticks;
         int[] tempos; // in MPQ
         // index in ticks/tempos at the snapshot
         int snapshotIndex = 0;

@@ -308,11 +301,10 @@
         public TempoCache(Sequence seq) {
             this();
             refresh(seq);
         }
 
-
         public synchronized void refresh(Sequence seq) {
             ArrayList<MidiEvent> list = new ArrayList<>();
             Track[] tracks = seq.getTracks();
             if (tracks.length > 0) {
                 // tempo events only occur in track 0

@@ -371,8 +363,7 @@
                     return (float) tempos[i];
                 }
             }
             return tempos[tempos.length - 1];
         }
-
     }
 }
< prev index next >