1 /*
2 * Copyright (c) 1999, 2004, 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
267 */
268 public boolean deleteTrack(Track track) {
269
270 synchronized(tracks) {
271
272 return tracks.removeElement(track);
273 }
274 }
275
276
277 /**
278 * Obtains an array containing all the tracks in this sequence.
279 * If the sequence contains no tracks, an array of length 0 is returned.
280 * @return the array of tracks
281 *
282 * @see #createTrack
283 * @see #deleteTrack
284 */
285 public Track[] getTracks() {
286
287 return (Track[]) tracks.toArray(new Track[tracks.size()]);
288 }
289
290
291 /**
292 * Obtains the duration of this sequence, expressed in microseconds.
293 * @return this sequence's duration in microseconds.
294 */
295 public long getMicrosecondLength() {
296
297 return com.sun.media.sound.MidiUtils.tick2microsecond(this, getTickLength(), null);
298 }
299
300
301 /**
302 * Obtains the duration of this sequence, expressed in MIDI ticks.
303 *
304 * @return this sequence's length in ticks
305 *
306 * @see #getMicrosecondLength
307 */
308 public long getTickLength() {
309
310 long length = 0;
311
312 synchronized(tracks) {
313
314 for(int i=0; i<tracks.size(); i++ ) {
315 long temp = ((Track)tracks.elementAt(i)).ticks();
316 if( temp>length ) {
317 length = temp;
318 }
319 }
320 return length;
321 }
322 }
323
324
325 /**
326 * Obtains a list of patches referenced in this sequence.
327 * This patch list may be used to load the required
328 * <code>{@link Instrument}</code> objects
329 * into a <code>{@link Synthesizer}</code>.
330 *
331 * @return an array of <code>{@link Patch}</code> objects used in this sequence
332 *
333 * @see Synthesizer#loadInstruments(Soundbank, Patch[])
334 */
335 public Patch[] getPatchList() {
|
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
267 */
268 public boolean deleteTrack(Track track) {
269
270 synchronized(tracks) {
271
272 return tracks.removeElement(track);
273 }
274 }
275
276
277 /**
278 * Obtains an array containing all the tracks in this sequence.
279 * If the sequence contains no tracks, an array of length 0 is returned.
280 * @return the array of tracks
281 *
282 * @see #createTrack
283 * @see #deleteTrack
284 */
285 public Track[] getTracks() {
286
287 return tracks.toArray(new Track[tracks.size()]);
288 }
289
290
291 /**
292 * Obtains the duration of this sequence, expressed in microseconds.
293 * @return this sequence's duration in microseconds.
294 */
295 public long getMicrosecondLength() {
296
297 return com.sun.media.sound.MidiUtils.tick2microsecond(this, getTickLength(), null);
298 }
299
300
301 /**
302 * Obtains the duration of this sequence, expressed in MIDI ticks.
303 *
304 * @return this sequence's length in ticks
305 *
306 * @see #getMicrosecondLength
307 */
308 public long getTickLength() {
309
310 long length = 0;
311
312 synchronized(tracks) {
313
314 for(int i=0; i<tracks.size(); i++ ) {
315 long temp = tracks.elementAt(i).ticks();
316 if( temp>length ) {
317 length = temp;
318 }
319 }
320 return length;
321 }
322 }
323
324
325 /**
326 * Obtains a list of patches referenced in this sequence.
327 * This patch list may be used to load the required
328 * <code>{@link Instrument}</code> objects
329 * into a <code>{@link Synthesizer}</code>.
330 *
331 * @return an array of <code>{@link Patch}</code> objects used in this sequence
332 *
333 * @see Synthesizer#loadInstruments(Soundbank, Patch[])
334 */
335 public Patch[] getPatchList() {
|