< prev index next >

src/java.desktop/share/classes/javax/sound/midi/Sequence.java

Print this page


   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


 249      * @return the newly created track
 250      */
 251     public Track createTrack() {
 252 
 253         Track track = new Track();
 254         tracks.addElement(track);
 255 
 256         return track;
 257     }
 258 
 259     /**
 260      * Removes the specified track from the sequence.
 261      *
 262      * @param  track the track to remove
 263      * @return {@code true} if the track existed in the track and was removed,
 264      *         otherwise {@code false}
 265      * @see #createTrack
 266      * @see #getTracks
 267      */
 268     public boolean deleteTrack(Track track) {
 269 
 270         synchronized(tracks) {
 271 
 272             return tracks.removeElement(track);
 273         }
 274     }
 275 
 276     /**
 277      * Obtains an array containing all the tracks in this sequence. If the
 278      * sequence contains no tracks, an array of length 0 is returned.
 279      *
 280      * @return the array of tracks
 281      * @see #createTrack
 282      * @see #deleteTrack
 283      */
 284     public Track[] getTracks() {
 285 
 286         return tracks.toArray(new Track[tracks.size()]);
 287     }
 288 
 289     /**
 290      * Obtains the duration of this sequence, expressed in microseconds.
 291      *
 292      * @return this sequence's duration in microseconds
 293      */
 294     public long getMicrosecondLength() {
 295 
 296         return com.sun.media.sound.MidiUtils.tick2microsecond(this, getTickLength(), null);
 297     }
 298 
 299     /**
 300      * Obtains the duration of this sequence, expressed in MIDI ticks.
 301      *
 302      * @return this sequence's length in ticks
 303      * @see #getMicrosecondLength
 304      */
 305     public long getTickLength() {
 306 


   1 /*
   2  * Copyright (c) 1999, 2016, 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


 249      * @return the newly created track
 250      */
 251     public Track createTrack() {
 252 
 253         Track track = new Track();
 254         tracks.addElement(track);
 255 
 256         return track;
 257     }
 258 
 259     /**
 260      * Removes the specified track from the sequence.
 261      *
 262      * @param  track the track to remove
 263      * @return {@code true} if the track existed in the track and was removed,
 264      *         otherwise {@code false}
 265      * @see #createTrack
 266      * @see #getTracks
 267      */
 268     public boolean deleteTrack(Track track) {



 269         return tracks.removeElement(track);
 270     }

 271 
 272     /**
 273      * Obtains an array containing all the tracks in this sequence. If the
 274      * sequence contains no tracks, an array of length 0 is returned.
 275      *
 276      * @return the array of tracks
 277      * @see #createTrack
 278      * @see #deleteTrack
 279      */
 280     public Track[] getTracks() {
 281         return tracks.toArray(new Track[0]);

 282     }
 283 
 284     /**
 285      * Obtains the duration of this sequence, expressed in microseconds.
 286      *
 287      * @return this sequence's duration in microseconds
 288      */
 289     public long getMicrosecondLength() {
 290 
 291         return com.sun.media.sound.MidiUtils.tick2microsecond(this, getTickLength(), null);
 292     }
 293 
 294     /**
 295      * Obtains the duration of this sequence, expressed in MIDI ticks.
 296      *
 297      * @return this sequence's length in ticks
 298      * @see #getMicrosecondLength
 299      */
 300     public long getTickLength() {
 301 


< prev index next >