ddf.minim
Class AudioFile

java.lang.Object
  extended byddf.minim.Controller
      extended byddf.minim.AudioFile
All Implemented Interfaces:
Effectable, Playable, Recordable

public class AudioFile
extends Controller
implements Effectable, Playable, Recordable

AudioFile is used for playing audio files, whether they are on the local file system or streaming from the web. The interface is identical to an AudioSnippet, the only difference being that samples are available. This means that you can do things like draw the waveform, attach AudioEffects, and use different audio analysis classes with it. You get an AudioFile by asking Minim for one.

Author:
Damien Di Fede

Field Summary
 AudioBuffer left
          The buffer containing the left channel samples.
 AudioBuffer mix
          The buffer containing the mix of the left and right channels.
 AudioBuffer right
          The buffer containing the right channel samples.
 
Fields inherited from class ddf.minim.Controller
BALANCE, GAIN, MUTE, PAN, SAMPLE_RATE, VOLUME
 
Method Summary
 void addEffect(AudioEffect e)
          Adds an effect to the effects chain.
 void addListener(AudioListener listener)
          Adds a listener who will be notified each time this receives or creates a new buffer of samples.
 int bufferSize()
          Returns the buffer size being used by this Recordable.
 void clearEffects()
          Removes all effects from the effect chain.
 void cue(int millis)
          Sets the position to millis milliseconds from the beginning.
 void disableEffect(int i)
          disables the ith effect in the effect chain.
 int effectCount()
          Returns the number of effects in the chain.
 void effects()
          Enables all effects currently attached to this.
 void enableEffect(int i)
          Enables the ith effect in the effect chain.
 AudioEffect getEffect(int i)
          Returns the ith effect in the effect chain.
 boolean isEffected()
          Returns true if at least one effect in the chain is enabled.
 boolean isLooping()
          Returns true if this is currently playing and has more than one loop left to play.
 boolean isPlaying()
          Returns true if this currently playing.
 int length()
          Returns the length of the sound in milliseconds.
 void loop()
          Sets looping to continuous.
 void loop(int num)
          Sets this to loop num times.
 void noEffects()
          Disables all effects currently attached to this.
 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" (ie how much of the sound has already been played)
 void removeEffect(AudioEffect e)
          Removes e from the effects chain.
 AudioEffect removeEffect(int i)
          Removes and returns the ith effect in the effect chain.
 void removeListener(AudioListener listener)
          Removes the listener from the list of listeners.
 void rewind()
          Rewinds to the beginning.
 
Methods inherited from class ddf.minim.Controller
balance, gain, getBalance, getControls, getFormat, getGain, getPan, getVolume, hasControl, isMuted, mute, pan, printControls, sampleRate, setBalance, setGain, setPan, setVolume, shiftBalance, shiftGain, shiftPan, shiftVolume, type, unmute, volume
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ddf.minim.Recordable
getFormat
 

Field Detail

left

public final AudioBuffer left
The buffer containing the left channel samples. If this is a mono AudioFile, it contains the single channel of audio.


right

public final AudioBuffer right
The buffer containing the right channel samples. If this is a mono AudioFile, right contains the same samples as left.


mix

public final AudioBuffer mix
The buffer containing the mix of the left and right channels. If this is a mono AudioFile, mix simply contains the same samples as left.

Method Detail

addEffect

public void addEffect(AudioEffect e)
Description copied from interface: Effectable
Adds an effect to the effects chain.

Specified by:
addEffect in interface Effectable
Parameters:
e - the AudioEffect to add

effectCount

public int effectCount()
Description copied from interface: Effectable
Returns the number of effects in the chain.

Specified by:
effectCount in interface Effectable
Returns:
the number of effects in the chain

clearEffects

public void clearEffects()
Description copied from interface: Effectable
Removes all effects from the effect chain.

Specified by:
clearEffects in interface Effectable

effects

public void effects()
Description copied from interface: Effectable
Enables all effects currently attached to this. If you want to enable only a single effect, use Effectable.enableEffect(int).

Specified by:
effects in interface Effectable

getEffect

public AudioEffect getEffect(int i)
Description copied from interface: Effectable
Returns the ith effect in the effect chain. This method is not required to do bounds checking and may throw an ArrayOutOfBoundsException if i is larger than Effectable.effectCount().

Specified by:
getEffect in interface Effectable
Parameters:
i - which effect to return
Returns:
the requested effect

enableEffect

public void enableEffect(int i)
Description copied from interface: Effectable
Enables the ith effect in the effect chain.

Specified by:
enableEffect in interface Effectable
Parameters:
i - the index of the effect to enable

disableEffect

public void disableEffect(int i)
Description copied from interface: Effectable
disables the ith effect in the effect chain.

Specified by:
disableEffect in interface Effectable
Parameters:
i - the index of the effect to disable

isEffected

public boolean isEffected()
Description copied from interface: Effectable
Returns true if at least one effect in the chain is enabled.

Specified by:
isEffected in interface Effectable
Returns:
true if at least one effect in the effects chain is enabled

noEffects

public void noEffects()
Description copied from interface: Effectable
Disables all effects currently attached to this. If you want to disable only a single effect, use Effectable.disableEffect(int).

Specified by:
noEffects in interface Effectable

removeEffect

public void removeEffect(AudioEffect e)
Description copied from interface: Effectable
Removes e from the effects chain.

Specified by:
removeEffect in interface Effectable
Parameters:
e - the AudioEffect to remove

removeEffect

public AudioEffect removeEffect(int i)
Description copied from interface: Effectable
Removes and returns the ith effect in the effect chain.

Specified by:
removeEffect in interface Effectable
Parameters:
i - which effect to remove
Returns:
the removed AudioEffect

cue

public void cue(int millis)
Description copied from interface: Playable
Sets the position to millis milliseconds from the beginning. This will not change the playstate. If an error occurs while trying to cue, it will be reported and this will be rewound.

Specified by:
cue in interface Playable
Parameters:
millis - the position to place the "playhead"

isLooping

public boolean isLooping()
Description copied from interface: Playable
Returns true if this is currently playing and has more than one loop left to play.

Specified by:
isLooping in interface Playable
Returns:
true if this is looping

isPlaying

public boolean isPlaying()
Description copied from interface: Playable
Returns true if this currently playing.

Specified by:
isPlaying in interface Playable
Returns:
true if this is currently playing

length

public int length()
Description copied from interface: Playable
Returns the length of the sound in milliseconds.

Specified by:
length in interface Playable
Returns:
the length of the sound in milliseconds

loop

public void loop()
Description copied from interface: Playable
Sets looping to continuous. If this is already playing, the position will not be reset to the beginning. If this is not playing, it will start playing.

Specified by:
loop in interface Playable

loop

public void loop(int num)
Description copied from interface: Playable
Sets this to loop num times. If this is already playing, the position will not be reset to the beginning. If this is not playing, it will start playing.

Specified by:
loop in interface Playable
Parameters:
num - the number of times to loop

pause

public void pause()
Description copied from interface: Playable
Pauses playback.

Specified by:
pause in interface Playable

play

public void play()
Description copied from interface: Playable
Starts playback from the current position.

Specified by:
play in interface Playable

play

public void play(int millis)
Description copied from interface: Playable
Starts playback millis from the beginning.

Specified by:
play in interface Playable
Parameters:
millis -

position

public int position()
Description copied from interface: Playable
Returns the current position of the "playhead" (ie how much of the sound has already been played)

Specified by:
position in interface Playable
Returns:
the current position of the "playhead"

rewind

public void rewind()
Description copied from interface: Playable
Rewinds to the beginning. This does not stop playback.

Specified by:
rewind in interface Playable

addListener

public void addListener(AudioListener listener)
Description copied from interface: Recordable
Adds a listener who will be notified each time this receives or creates a new buffer of samples.

Specified by:
addListener in interface Recordable
Parameters:
listener - the listener to add

bufferSize

public int bufferSize()
Description copied from interface: Recordable
Returns the buffer size being used by this Recordable.

Specified by:
bufferSize in interface Recordable
Returns:
the buffer size

removeListener

public void removeListener(AudioListener listener)
Description copied from interface: Recordable
Removes the listener from the list of listeners.

Specified by:
removeListener in interface Recordable
Parameters:
listener - the listener to remove