1. /*
  2. * @(#)Sequencer.java 1.36 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.sound.midi;
  8. import java.io.InputStream;
  9. import java.io.IOException;
  10. /**
  11. * A hardware or software device that plays back a MIDI
  12. * <code>{@link Sequence sequence}</code> is known as a <em>sequencer</em>.
  13. * A MIDI sequence contains lists of time-stamped MIDI data, such as
  14. * might be read from a standard MIDI file. Most
  15. * sequencers also provide functions for creating and editing sequences.
  16. * <p>
  17. * The <code>Sequencer</code> interface includes methods for the following
  18. * basic MIDI sequencer operations:
  19. * <ul>
  20. * <li>obtaining a sequence from MIDI file data</li>
  21. * <li>starting and stopping playback</li>
  22. * <li>moving to an arbitrary position in the sequence</li>
  23. * <li>changing the tempo (speed) of playback</li>
  24. * <li>synchronizing playback to an internal clock or to received MIDI
  25. * messages</li>
  26. * <li>controlling the timing of another device</li>
  27. * </ul>
  28. * In addition, the following operations are supported, either directly, or
  29. * indirectly through objects that the <code>Sequencer</code> has access to:
  30. * <ul>
  31. * <li>editing the data by adding or deleting individual MIDI events or entire
  32. * tracks</li>
  33. * <li>muting or soloing individual tracks in the sequence</li>
  34. * <li>notifying listener objects about any meta-events or
  35. * control-change events encountered while playing back the sequence.</li>
  36. * </ul>
  37. *
  38. * @see Sequencer.SyncMode
  39. * @see #addMetaEventListener
  40. * @see ControllerEventListener
  41. * @see Receiver
  42. * @see Transmitter
  43. * @see MidiDevice
  44. *
  45. * @version 1.36, 03/12/19
  46. * @author Kara Kytle
  47. * @author Florian Bomers
  48. */
  49. public interface Sequencer extends MidiDevice {
  50. /**
  51. * A value indicating that looping should continue
  52. * indefinitely rather than complete after a specific
  53. * number of loops.
  54. *
  55. * @see #setLoopCount
  56. * @since 1.5
  57. */
  58. public static final int LOOP_CONTINUOUSLY = -1;
  59. /**
  60. * Sets the current sequence on which the sequencer operates.
  61. *
  62. * <p>This method can be called even if the
  63. * <code>Sequencer</code> is closed.
  64. *
  65. * @param sequence the sequence to be loaded.
  66. * @throws InvalidMidiDataException if the sequence contains invalid
  67. * MIDI data, or is not supported.
  68. */
  69. public void setSequence(Sequence sequence) throws InvalidMidiDataException;
  70. /**
  71. * Sets the current sequence on which the sequencer operates.
  72. * The stream must point to MIDI file data.
  73. *
  74. * <p>This method can be called even if the
  75. * <code>Sequencer</code> is closed.
  76. *
  77. * @param stream stream containing MIDI file data.
  78. * @throws IOException if an I/O exception occurs during reading of the stream.
  79. * @throws InvalidMidiDataException if invalid data is encountered
  80. * in the stream, or the stream is not supported.
  81. */
  82. public void setSequence(InputStream stream) throws IOException, InvalidMidiDataException;
  83. /**
  84. * Obtains the sequence on which the Sequencer is currently operating.
  85. *
  86. * <p>This method can be called even if the
  87. * <code>Sequencer</code> is closed.
  88. *
  89. * @return the current sequence, or <code>null</code> if no sequence is currently set.
  90. */
  91. public Sequence getSequence();
  92. /**
  93. * Starts playback of the MIDI data in the currently
  94. * loaded sequence.
  95. * Playback will begin from the current position.
  96. * If the playback position reaches the loop end point,
  97. * and the loop count is greater than 0, playback will
  98. * resume at the loop start point for the number of
  99. * repetitions set with <code>setLoopCount</code>.
  100. * After that, or if the loop count is 0, playback will
  101. * continue to play to the end of the sequence.
  102. *
  103. * <p>The implementation ensures that the synthesizer
  104. * is brought to a consistent state when jumping
  105. * to the loop start point by sending appropriate
  106. * controllers, pitch bend, and program change events.
  107. *
  108. * @throws IllegalStateException if the <code>Sequencer</code> is
  109. * closed.
  110. *
  111. * @see #setLoopStartPoint
  112. * @see #setLoopEndPoint
  113. * @see #setLoopCount
  114. * @see #stop
  115. */
  116. public void start();
  117. /**
  118. * Stops recording, if active, and playback of the currently loaded sequence,
  119. * if any.
  120. *
  121. * @throws IllegalStateException if the <code>Sequencer</code> is
  122. * closed.
  123. *
  124. * @see #start
  125. * @see #isRunning
  126. */
  127. public void stop();
  128. /**
  129. * Indicates whether the Sequencer is currently running. The default is <code>false</code>.
  130. * The Sequencer starts running when either <code>{@link #start}</code> or <code>{@link #startRecording}</code>
  131. * is called. <code>isRunning</code> then returns <code>true</code> until playback of the
  132. * sequence completes or <code>{@link #stop}</code> is called.
  133. * @return <code>true</code> if the Sequencer is running, otherwise <code>false</code>
  134. */
  135. public boolean isRunning();
  136. /**
  137. * Starts recording and playback of MIDI data. Data is recorded to all enabled tracks,
  138. * on the channel(s) for which they were enabled. Recording begins at the current position
  139. * of the sequencer. Any events already in the track are overwritten for the duration
  140. * of the recording session. Events from the currently loaded sequence,
  141. * if any, are delivered to the sequencer's transmitter(s) along with messages
  142. * received during recording.
  143. * <p>
  144. * Note that tracks are not by default enabled for recording. In order to record MIDI data,
  145. * at least one track must be specifically enabled for recording.
  146. *
  147. * @throws IllegalStateException if the <code>Sequencer</code> is
  148. * closed.
  149. *
  150. * @see #startRecording
  151. * @see #recordEnable
  152. * @see #recordDisable
  153. */
  154. public void startRecording();
  155. /**
  156. * Stops recording, if active. Playback of the current sequence continues.
  157. *
  158. * @throws IllegalStateException if the <code>Sequencer</code> is
  159. * closed.
  160. *
  161. * @see #startRecording
  162. * @see #isRecording
  163. */
  164. public void stopRecording();
  165. /**
  166. * Indicates whether the Sequencer is currently recording. The default is <code>false</code>.
  167. * The Sequencer begins recording when <code>{@link #startRecording}</code> is called,
  168. * and then returns <code>true</code> until <code>{@link #stop}</code> or <code>{@link #stopRecording}</code>
  169. * is called.
  170. * @return <code>true</code> if the Sequencer is recording, otherwise <code>false</code>
  171. */
  172. public boolean isRecording();
  173. /**
  174. * Prepares the specified track for recording events received on a particular channel.
  175. * Once enabled, a track will receive events when recording is active.
  176. * @param track the track to which events will be recorded
  177. * @param channel the channel on which events will be received. If -1 is specified
  178. * for the channel value, the track will receive data from all channels.
  179. * @throws IllegalArgumentException thrown if the track is not part of the current
  180. * sequence.
  181. */
  182. public void recordEnable(Track track, int channel);
  183. /**
  184. * Disables recording to the specified track. Events will no longer be recorded
  185. * into this track.
  186. * @param track the track to disable for recording, or <code>null</code> to disable
  187. * recording for all tracks.
  188. */
  189. public void recordDisable(Track track);
  190. /**
  191. * Obtains the current tempo, expressed in beats per minute. The
  192. * actual tempo of playback is the product of the returned value
  193. * and the tempo factor.
  194. *
  195. * @return the current tempo in beats per minute
  196. *
  197. * @see #getTempoFactor
  198. * @see #setTempoInBPM(float)
  199. * @see #getTempoInMPQ
  200. */
  201. public float getTempoInBPM();
  202. /**
  203. * Sets the tempo in beats per minute. The actual tempo of playback
  204. * is the product of the specified value and the tempo factor.
  205. *
  206. * @param bpm desired new tempo in beats per minute
  207. * @see #getTempoFactor
  208. * @see #setTempoInMPQ(float)
  209. * @see #getTempoInBPM
  210. */
  211. public void setTempoInBPM(float bpm);
  212. /**
  213. * Obtains the current tempo, expressed in microseconds per quarter
  214. * note. The actual tempo of playback is the product of the returned
  215. * value and the tempo factor.
  216. *
  217. * @return the current tempo in microseconds per quarter note
  218. * @see #getTempoFactor
  219. * @see #setTempoInMPQ(float)
  220. * @see #getTempoInBPM
  221. */
  222. public float getTempoInMPQ();
  223. /**
  224. * Sets the tempo in microseconds per quarter note. The actual tempo
  225. * of playback is the product of the specified value and the tempo
  226. * factor.
  227. *
  228. * @param mpq desired new tempo in microseconds per quarter note.
  229. * @see #getTempoFactor
  230. * @see #setTempoInBPM(float)
  231. * @see #getTempoInMPQ
  232. */
  233. public void setTempoInMPQ(float mpq);
  234. /**
  235. * Scales the sequencer's actual playback tempo by the factor provided.
  236. * The default is 1.0. A value of 1.0 represents the natural rate (the
  237. * tempo specified in the sequence), 2.0 means twice as fast, etc.
  238. * The tempo factor does not affect the values returned by
  239. * <code>{@link #getTempoInMPQ}</code> and <code>{@link #getTempoInBPM}</code>.
  240. * Those values indicate the tempo prior to scaling.
  241. * <p>
  242. * Note that the tempo factor cannot be adjusted when external
  243. * synchronization is used. In that situation,
  244. * <code>setTempoFactor</code> always sets the tempo factor to 1.0.
  245. *
  246. * @param factor the requested tempo scalar
  247. * @see #getTempoFactor
  248. */
  249. public void setTempoFactor(float factor);
  250. /**
  251. * Returns the current tempo factor for the sequencer. The default is
  252. * 1.0.
  253. *
  254. * @return tempo factor.
  255. * @see #setTempoFactor(float)
  256. */
  257. public float getTempoFactor();
  258. /**
  259. * Obtains the length of the current sequence, expressed in MIDI ticks,
  260. * or 0 if no sequence is set.
  261. * @return length of the sequence in ticks
  262. */
  263. public long getTickLength();
  264. /**
  265. * Obtains the current position in the sequence, expressed in MIDI
  266. * ticks. (The duration of a tick in seconds is determined both by
  267. * the tempo and by the timing resolution stored in the
  268. * <code>{@link Sequence}</code>.)
  269. *
  270. * @return current tick
  271. * @see #setTickPosition
  272. */
  273. public long getTickPosition();
  274. /**
  275. * Sets the current sequencer position in MIDI ticks
  276. * @param tick the desired tick position
  277. * @see #getTickPosition
  278. */
  279. public void setTickPosition(long tick);
  280. /**
  281. * Obtains the length of the current sequence, expressed in microseconds,
  282. * or 0 if no sequence is set.
  283. * @return length of the sequence in microseconds.
  284. */
  285. public long getMicrosecondLength();
  286. /**
  287. * Obtains the current position in the sequence, expressed in
  288. * microseconds.
  289. * @return the current position in microseconds
  290. * @see #setMicrosecondPosition
  291. */
  292. public long getMicrosecondPosition();
  293. /**
  294. * Sets the current position in the sequence, expressed in microseconds
  295. * @param microseconds desired position in microseconds
  296. * @see #getMicrosecondPosition
  297. */
  298. public void setMicrosecondPosition(long microseconds);
  299. /**
  300. * Sets the source of timing information used by this sequencer.
  301. * The sequencer synchronizes to the master, which is the internal clock,
  302. * MIDI clock, or MIDI time code, depending on the value of
  303. * <code>sync</code>. The <code>sync</code> argument must be one
  304. * of the supported modes, as returned by
  305. * <code>{@link #getMasterSyncModes}</code>.
  306. *
  307. * @param sync the desired master synchronization mode
  308. *
  309. * @see SyncMode#INTERNAL_CLOCK
  310. * @see SyncMode#MIDI_SYNC
  311. * @see SyncMode#MIDI_TIME_CODE
  312. * @see #getMasterSyncMode
  313. */
  314. public void setMasterSyncMode(SyncMode sync);
  315. /**
  316. * Obtains the current master synchronization mode for this sequencer.
  317. *
  318. * @return the current master synchronization mode
  319. *
  320. * @see #setMasterSyncMode(Sequencer.SyncMode)
  321. * @see #getMasterSyncModes
  322. */
  323. public SyncMode getMasterSyncMode();
  324. /**
  325. * Obtains the set of master synchronization modes supported by this
  326. * sequencer.
  327. *
  328. * @return the available master synchronization modes
  329. *
  330. * @see SyncMode#INTERNAL_CLOCK
  331. * @see SyncMode#MIDI_SYNC
  332. * @see SyncMode#MIDI_TIME_CODE
  333. * @see #getMasterSyncMode
  334. * @see #setMasterSyncMode(Sequencer.SyncMode)
  335. */
  336. public SyncMode[] getMasterSyncModes();
  337. /**
  338. * Sets the slave synchronization mode for the sequencer.
  339. * This indicates the type of timing information sent by the sequencer
  340. * to its receiver. The <code>sync</code> argument must be one
  341. * of the supported modes, as returned by
  342. * <code>{@link #getSlaveSyncModes}</code>.
  343. *
  344. * @param sync the desired slave synchronization mode
  345. *
  346. * @see SyncMode#MIDI_SYNC
  347. * @see SyncMode#MIDI_TIME_CODE
  348. * @see SyncMode#NO_SYNC
  349. * @see #getSlaveSyncModes
  350. */
  351. public void setSlaveSyncMode(SyncMode sync);
  352. /**
  353. * Obtains the current slave synchronization mode for this sequencer.
  354. *
  355. * @return the current slave synchronization mode
  356. *
  357. * @see #setSlaveSyncMode(Sequencer.SyncMode)
  358. * @see #getSlaveSyncModes
  359. */
  360. public SyncMode getSlaveSyncMode();
  361. /**
  362. * Obtains the set of slave synchronization modes supported by the sequencer.
  363. *
  364. * @return the available slave synchronization modes
  365. *
  366. * @see SyncMode#MIDI_SYNC
  367. * @see SyncMode#MIDI_TIME_CODE
  368. * @see SyncMode#NO_SYNC
  369. */
  370. public SyncMode[] getSlaveSyncModes();
  371. /**
  372. * Sets the mute state for a track. This method may fail for a number
  373. * of reasons. For example, the track number specified may not be valid
  374. * for the current sequence, or the sequencer may not support this functionality.
  375. * An application which needs to verify whether this operation succeeded should
  376. * follow this call with a call to <code>{@link #getTrackMute}</code>.
  377. *
  378. * @param track the track number. Tracks in the current sequence are numbered
  379. * from 0 to the number of tracks in the sequence minus 1.
  380. * @param mute the new mute state for the track. <code>true</code> implies the
  381. * track should be muted, <code>false</code> implies the track should be unmuted.
  382. * @see #getSequence
  383. */
  384. public void setTrackMute(int track, boolean mute);
  385. /**
  386. * Obtains the current mute state for a track. The default mute
  387. * state for all tracks which have not been muted is false. In any
  388. * case where the specified track has not been muted, this method should
  389. * return false. This applies if the sequencer does not support muting
  390. * of tracks, and if the specified track index is not valid.
  391. *
  392. * @param track the track number. Tracks in the current sequence are numbered
  393. * from 0 to the number of tracks in the sequence minus 1.
  394. * @return <code>true</code> if muted, <code>false</code> if not.
  395. */
  396. public boolean getTrackMute(int track);
  397. /**
  398. * Sets the solo state for a track. If <code>solo</code> is <code>true</code>
  399. * only this track and other solo'd tracks will sound. If <code>solo</code>
  400. * is <code>false</code> then only other solo'd tracks will sound, unless no
  401. * tracks are solo'd in which case all un-muted tracks will sound.
  402. * <p>
  403. * This method may fail for a number
  404. * of reasons. For example, the track number specified may not be valid
  405. * for the current sequence, or the sequencer may not support this functionality.
  406. * An application which needs to verify whether this operation succeeded should
  407. * follow this call with a call to <code>{@link #getTrackSolo}</code>.
  408. *
  409. * @param track the track number. Tracks in the current sequence are numbered
  410. * from 0 to the number of tracks in the sequence minus 1.
  411. * @param solo the new solo state for the track. <code>true</code> implies the
  412. * track should be solo'd, <code>false</code> implies the track should not be solo'd.
  413. * @see #getSequence
  414. */
  415. public void setTrackSolo(int track, boolean solo);
  416. /**
  417. * Obtains the current solo state for a track. The default mute
  418. * state for all tracks which have not been solo'd is false. In any
  419. * case where the specified track has not been solo'd, this method should
  420. * return false. This applies if the sequencer does not support soloing
  421. * of tracks, and if the specified track index is not valid.
  422. *
  423. * @param track the track number. Tracks in the current sequence are numbered
  424. * from 0 to the number of tracks in the sequence minus 1.
  425. * @return <code>true</code> if solo'd, <code>false</code> if not.
  426. */
  427. public boolean getTrackSolo(int track);
  428. /**
  429. * Registers a meta-event listener to receive
  430. * notification whenever a meta-event is encountered in the sequence
  431. * and processed by the sequencer. This method can fail if, for
  432. * instance,this class of sequencer does not support meta-event
  433. * notification.
  434. *
  435. * @param listener listener to add
  436. * @return <code>true</code> if the listener was successfully added,
  437. * otherwise <code>false</code>
  438. *
  439. * @see #removeMetaEventListener
  440. * @see MetaEventListener
  441. * @see MetaMessage
  442. */
  443. public boolean addMetaEventListener(MetaEventListener listener);
  444. /**
  445. * Removes the specified meta-event listener from this sequencer's
  446. * list of registered listeners, if in fact the listener is registered.
  447. *
  448. * @param listener the meta-event listener to remove
  449. * @see #addMetaEventListener
  450. */
  451. public void removeMetaEventListener(MetaEventListener listener);
  452. /**
  453. * Registers a controller event listener to receive notification
  454. * whenever the sequencer processes a control-change event of the
  455. * requested type or types. The types are specified by the
  456. * <code>controllers</code> argument, which should contain an array of
  457. * MIDI controller numbers. (Each number should be between 0 and 127,
  458. * inclusive. See the MIDI 1.0 Specification for the numbers that
  459. * correspond to various types of controllers.)
  460. * <p>
  461. * The returned array contains the MIDI controller
  462. * numbers for which the listener will now receive events.
  463. * Some sequencers might not support controller event notification, in
  464. * which case the array has a length of 0. Other sequencers might
  465. * support notification for some controllers but not all.
  466. * This method may be invoked repeatedly.
  467. * Each time, the returned array indicates all the controllers
  468. * that the listener will be notified about, not only the controllers
  469. * requested in that particular invocation.
  470. *
  471. * @param listener the controller event listener to add to the list of
  472. * registered listeners
  473. * @param controllers the MIDI controller numbers for which change
  474. * notification is requested
  475. * @return the numbers of all the MIDI controllers whose changes will
  476. * now be reported to the specified listener
  477. *
  478. * @see #removeControllerEventListener
  479. * @see ControllerEventListener
  480. */
  481. public int[] addControllerEventListener(ControllerEventListener listener, int[] controllers);
  482. /**
  483. * Removes a controller event listener's interest in one or more
  484. * types of controller event. The <code>controllers</code> argument
  485. * is an array of MIDI numbers corresponding to the controllers for
  486. * which the listener should no longer receive change notifications.
  487. * To completely remove this listener from the list of registered
  488. * listeners, pass in <code>null</code> for <code>controllers</code>.
  489. * The returned array contains the MIDI controller
  490. * numbers for which the listener will now receive events. The
  491. * array has a length of 0 if the listener will not receive
  492. * change notifications for any controllers.
  493. *
  494. * @param listener old listener
  495. * @param controllers the MIDI controller numbers for which change
  496. * notification should be cancelled, or <code>null</code> to cancel
  497. * for all controllers
  498. * @return the numbers of all the MIDI controllers whose changes will
  499. * now be reported to the specified listener
  500. *
  501. * @see #addControllerEventListener
  502. */
  503. public int[] removeControllerEventListener(ControllerEventListener listener, int[] controllers);
  504. /**
  505. * Sets the first MIDI tick that will be
  506. * played in the loop. If the loop count is
  507. * greater than 0, playback will jump to this
  508. * point when reaching the loop end point.
  509. *
  510. * <p>A value of 0 for the starting point means the
  511. * beginning of the loaded sequence. The starting
  512. * point must be lower than or equal to the ending
  513. * point, and it must fall within the size of the
  514. * loaded sequence.
  515. *
  516. * <p>A sequencer's loop start point defaults to
  517. * start of the sequence.
  518. *
  519. * @param tick the loop's starting position,
  520. * in MIDI ticks (zero-based)
  521. * @throws IllegalArgumentException if the requested
  522. * loop start point cannot be set, usually because
  523. * it falls outside the sequence's
  524. * duration or because the start point is
  525. * after the end point
  526. *
  527. * @see #setLoopEndPoint
  528. * @see #setLoopCount
  529. * @see #getLoopStartPoint
  530. * @see #start
  531. * @since 1.5
  532. */
  533. public void setLoopStartPoint(long tick);
  534. /**
  535. * Obtains the start position of the loop,
  536. * in MIDI ticks.
  537. *
  538. * @return the start position of the loop,
  539. in MIDI ticks (zero-based)
  540. * @see #setLoopStartPoint
  541. * @since 1.5
  542. */
  543. public long getLoopStartPoint();
  544. /**
  545. * Sets the last MIDI tick that will be played in
  546. * the loop. If the loop count is 0, the loop end
  547. * point has no effect and playback continues to
  548. * play when reaching the loop end point.
  549. *
  550. * <p>A value of -1 for the ending point
  551. * indicates the last tick of the sequence.
  552. * Otherwise, the ending point must be greater
  553. * than or equal to the starting point, and it must
  554. * fall within the size of the loaded sequence.
  555. *
  556. * <p>A sequencer's loop end point defaults to -1,
  557. * meaning the end of the sequence.
  558. *
  559. * @param tick the loop's ending position,
  560. * in MIDI ticks (zero-based), or
  561. * -1 to indicate the final tick
  562. * @throws IllegalArgumentException if the requested
  563. * loop point cannot be set, usually because
  564. * it falls outside the sequence's
  565. * duration or because the ending point is
  566. * before the starting point
  567. *
  568. * @see #setLoopStartPoint
  569. * @see #setLoopCount
  570. * @see #getLoopEndPoint
  571. * @see #start
  572. * @since 1.5
  573. */
  574. public void setLoopEndPoint(long tick);
  575. /**
  576. * Obtains the end position of the loop,
  577. * in MIDI ticks.
  578. *
  579. * @return the end position of the loop, in MIDI
  580. * ticks (zero-based), or -1 to indicate
  581. * the end of the sequence
  582. * @see #setLoopEndPoint
  583. * @since 1.5
  584. */
  585. public long getLoopEndPoint();
  586. /**
  587. * Sets the number of repetitions of the loop for
  588. * playback.
  589. * When the playback position reaches the loop end point,
  590. * it will loop back to the loop start point
  591. * <code>count</code> times, after which playback will
  592. * continue to play to the end of the sequence.
  593. * <p>
  594. * If the current position when this method is invoked
  595. * is greater than the loop end point, playback
  596. * continues to the end of the sequence without looping,
  597. * unless the loop end point is changed subsequently.
  598. * <p>
  599. * A <code>count</code> value of 0 disables looping:
  600. * playback will continue at the loop end point, and it
  601. * will not loop back to the loop start point.
  602. * This is a sequencer's default.
  603. *
  604. * <p>If playback is stopped during looping, the
  605. * current loop status is cleared; subsequent start
  606. * requests are not affected by an interrupted loop
  607. * operation.
  608. *
  609. * @param count the number of times playback should
  610. * loop back from the loop's end position
  611. * to the loop's start position, or
  612. * <code>{@link #LOOP_CONTINUOUSLY}</code>
  613. * to indicate that looping should
  614. * continue until interrupted
  615. *
  616. * @throws IllegalArgumentException if <code>count</code> is
  617. * negative and not equal to {@link #LOOP_CONTINUOUSLY}
  618. *
  619. * @see #setLoopStartPoint
  620. * @see #setLoopEndPoint
  621. * @see #getLoopCount
  622. * @see #start
  623. * @since 1.5
  624. */
  625. public void setLoopCount(int count);
  626. /**
  627. * Obtains the number of repetitions for
  628. * playback.
  629. *
  630. * @return the number of loops after which
  631. * playback plays to the end of the
  632. * sequence
  633. * @see #setLoopCount
  634. * @see #start
  635. * @since 1.5
  636. */
  637. public int getLoopCount();
  638. /**
  639. * A <code>SyncMode</code> object represents one of the ways in which
  640. * a MIDI sequencer's notion of time can be synchronized with a master
  641. * or slave device.
  642. * If the sequencer is being synchronized to a master, the
  643. * sequencer revises its current time in response to messages from
  644. * the master. If the sequencer has a slave, the sequencer
  645. * similarly sends messages to control the slave's timing.
  646. * <p>
  647. * There are three predefined modes that specify possible masters
  648. * for a sequencer: <code>INTERNAL_CLOCK</code>,
  649. * <code>MIDI_SYNC</code>, and <code>MIDI_TIME_CODE</code>. The
  650. * latter two work if the sequencer receives MIDI messages from
  651. * another device. In these two modes, the sequencer's time gets reset
  652. * based on system real-time timing clock messages or MIDI time code
  653. * (MTC) messages, respectively. These two modes can also be used
  654. * as slave modes, in which case the sequencer sends the corresponding
  655. * types of MIDI messages to its receiver (whether or not the sequencer
  656. * is also receiving them from a master). A fourth mode,
  657. * <code>NO_SYNC</code>, is used to indicate that the sequencer should
  658. * not control its receiver's timing.
  659. *
  660. * @see Sequencer#setMasterSyncMode(Sequencer.SyncMode)
  661. * @see Sequencer#setSlaveSyncMode(Sequencer.SyncMode)
  662. */
  663. public static class SyncMode {
  664. /**
  665. * Synchronization mode name.
  666. */
  667. private String name;
  668. /**
  669. * Constructs a synchronization mode.
  670. * @param name name of the synchronization mode
  671. */
  672. protected SyncMode(String name) {
  673. this.name = name;
  674. }
  675. /**
  676. * Determines whether two objects are equal.
  677. * Returns <code>true</code> if the objects are identical
  678. * @param obj the reference object with which to compare
  679. * @return <code>true</code> if this object is the same as the
  680. * <code>obj</code> argument, <code>false</code> otherwise
  681. */
  682. public final boolean equals(Object obj) {
  683. return super.equals(obj);
  684. }
  685. /**
  686. * Finalizes the hashcode method.
  687. */
  688. public final int hashCode() {
  689. return super.hashCode();
  690. }
  691. /**
  692. * Provides this synchronization mode's name as the string
  693. * representation of the mode.
  694. * @return the name of this synchronization mode
  695. */
  696. public final String toString() {
  697. return name;
  698. }
  699. /**
  700. * A master synchronization mode that makes the sequencer get
  701. * its timing information from its internal clock. This is not
  702. * a legal slave sync mode.
  703. */
  704. public static final SyncMode INTERNAL_CLOCK = new SyncMode("Internal Clock");
  705. /**
  706. * A master or slave synchronization mode that specifies the
  707. * use of MIDI clock
  708. * messages. If this mode is used as the master sync mode,
  709. * the sequencer gets its timing information from system real-time
  710. * MIDI clock messages. This mode only applies as the master sync
  711. * mode for sequencers that are also MIDI receivers. If this is the
  712. * slave sync mode, the sequencer sends system real-time MIDI clock
  713. * messages to its receiver. MIDI clock messages are sent at a rate
  714. * of 24 per quarter note.
  715. */
  716. public static final SyncMode MIDI_SYNC = new SyncMode("MIDI Sync");
  717. /**
  718. * A master or slave synchronization mode that specifies the
  719. * use of MIDI Time Code.
  720. * If this mode is used as the master sync mode,
  721. * the sequencer gets its timing information from MIDI Time Code
  722. * messages. This mode only applies as the master sync
  723. * mode to sequencers that are also MIDI receivers. If this
  724. * mode is used as the
  725. * slave sync mode, the sequencer sends MIDI Time Code
  726. * messages to its receiver. (See the MIDI 1.0 Detailed
  727. * Specification for a description of MIDI Time Code.)
  728. */
  729. public static final SyncMode MIDI_TIME_CODE = new SyncMode("MIDI Time Code");
  730. /**
  731. * A slave synchronization mode indicating that no timing information
  732. * should be sent to the receiver. This is not a legal master sync
  733. * mode.
  734. */
  735. public static final SyncMode NO_SYNC = new SyncMode("No Timing");
  736. } // class SyncMode
  737. }