ddf.minim
Class AudioClip

java.lang.Object
  extended byddf.minim.Controller
      extended byddf.minim.AudioClip

public class AudioClip
extends Controller

AudioClip is a simple wrapper around a JavaSound Clip. It provides almost the exact same functionality, the main difference being that length, position, and cue are expressed in milliseconds instead of microseconds. You can obtain an AudioClip by using MInim.loadClip(). One of the limitations of AudioClip is that you do not have access to the audio samples as they are played. However, you are spared all of the overhead associated with making samples available. An AudioClip is a good choice if all you need to do is play a short sound at some point. If your aim is to repeatedly trigger a sound, you should use an AudioSample instead.

Author:
Damien Di Fede

Field Summary
 
Fields inherited from class ddf.minim.Controller
BALANCE, GAIN, line, MUTE, PAN, VOLUME
 
Constructor Summary
AudioClip(javax.sound.sampled.Clip c)
          Constructs an AudioClip using the passed Clip.
 
Method Summary
 void cue(int millis)
          Sets the position of the clip to millis milliseconds from the beginning.
 int length()
          Returns the length of the AudioClip in milliseconds.
 void loop()
          Sets the clip to loop continuously.
 void loop(int n)
          Sets the clip to loop n times.
 void pause()
          Pauses playback.
 void play()
          Starts playback from the current position.
 void play(int millis)
          Starts playback millis from the beginning.
 int position()
          Returns the current position of the "playhead" in the clip (ie how much of the clip has already been played)
 void rewind()
          Rewinds the clip to the beginning.
 
Methods inherited from class ddf.minim.Controller
getBalance, getGain, getPan, getVolume, isMuted, mute, printControls, setBalance, setGain, setPan, setVolume, shiftBalance, shiftGain, shiftPan, shiftVolume, unmute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AudioClip

public AudioClip(javax.sound.sampled.Clip c)
Constructs an AudioClip using the passed Clip.

Parameters:
c - the Clip to wrap
Method Detail

play

public void play()
Starts playback from the current position.


play

public void play(int millis)
Starts playback millis from the beginning.

Parameters:
millis -

pause

public void pause()
Pauses playback.


rewind

public void rewind()
Rewinds the clip to the beginning. This does not stop playback.


loop

public void loop()
Sets the clip to loop continuously. If it is already playing, this will not reset the position to the beginning. If it is not playing, this will cause the clip to start playing.


loop

public void loop(int n)
Sets the clip to loop n times. If it is already playing, this will not reset the position to the beginning. If it is not playing, this will cause the clip to start playing.

Parameters:
n - the number of times to loop

length

public int length()
Returns the length of the AudioClip in milliseconds.

Returns:
the length of the clip in milliseconds

position

public int position()
Returns the current position of the "playhead" in the clip (ie how much of the clip has already been played)

Returns:
the current position of the clip in milliseconds

cue

public void cue(int millis)
Sets the position of the clip to millis milliseconds from the beginning. This will not change the playstate of the clip.

Parameters:
millis - how many milliseconds from the beginning to place the "playhead"