Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## ddf.minim
Class AudioSnippet

    java.lang.Object
      ddf.minim.Controller
          ddf.minim.AudioSnippet

All Implemented Interfaces:
  Playable

    public class AudioSnippet

extends Controller
implements Playable

`AudioSnippet` is a simple wrapper around a JavaSound `Clip` (It isn't called AudioClip because that's an interface defined in the package java.applet). 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 `AudioSnippet` by using `Minim.loadSnippet(String)`. One of the limitations of `AudioSnippet` 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 `AudioSnippet` 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, MUTE, PAN, SAMPLE_RATE, VOLUME`

Constructor Summary
`AudioSnippet(AudioRecording rec)`

Method Summary
`void` | `close()` Closes the snippet so that any resources it is using can be released.
`void` | `cue(int millis)` Sets the position to `millis` milliseconds from the beginning.
`AudioMetaData` | `getMetaData()` Returns the meta data for this.
`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 n)` Sets this to loop `num` times.
`int` | `loopCount()` Returns the number of loops left to do.
`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` | `rewind()` Rewinds to the beginning.
`void` | `setLoopPoints(int start, int stop)` Sets the loop points used when looping.
`void` | `skip(int millis)` Skips `millis` from the current position.

Methods inherited from class ddf.minim.Controller
`balance, gain, getBalance, getControl, getControls, getGain, getPan, getVolume, hasControl, isMuted, mute, pan, printControls, setBalance, setGain, setPan, setVolume, shiftBalance, shiftGain, shiftPan, shiftVolume, unmute, volume`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### AudioSnippet

    public AudioSnippet(AudioRecording rec)

Method Detail

### play

    public void play()

  Description copied from interface: `Playable`
  Starts playback from the current position. If this was previous set to loop, looping will be disabled.

  Specified by:
    `play` in interface `Playable`

### play

    public void play(int millis)

  Description copied from interface: `Playable`
  Starts playback `millis` from the beginning. If this was previous set to loop, looping will be disabled.

  Specified by:
    `play` in interface `Playable`

### pause

    public void pause()

  Description copied from interface: `Playable`
  Pauses playback.

  Specified by:
    `pause` in interface `Playable`

### rewind

    public void rewind()

  Description copied from interface: `Playable`
  Rewinds to the beginning. This does not stop playback.

  Specified by:
    `rewind` in interface `Playable`

### 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 n)

  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:
    `n` - the number of times to loop

### loopCount

    public int loopCount()

  Description copied from interface: `Playable`
  Returns the number of loops left to do.

  Specified by:
    `loopCount` in interface `Playable`
  Returns:
    the number of loops left

### length

    public int length()

  Description copied from interface: `Playable`
  Returns the length of the sound in milliseconds. If for any reason the length could not be determined, this will return -1. However, an unknown length should not impact playback.

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

### 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"

### 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, the position will not change. If you try to cue to a negative position or try to a position that is greater than `length()`, the amount will be clamped to zero or `length()`.

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

### skip

    public void skip(int millis)

  Description copied from interface: `Playable`
  Skips `millis` from the current position. `millis` can be negative, which will make this skip backwards. If the skip amount would result in a negative position or a position that is greater than `length()`, the new position will be clamped to zero or `length()`.

  Specified by:
    `skip` in interface `Playable`
  Parameters:
    `millis` - how many milliseconds to skip, sign indicates direction

### 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

### close

    public void close()

  Closes the snippet so that any resources it is using can be released. This should be called when you are finished using this snippet.

### getMetaData

    public AudioMetaData getMetaData()

  Description copied from interface: `Playable`
  Returns the meta data for this.

  Specified by:
    `getMetaData` in interface `Playable`

### setLoopPoints

    public void setLoopPoints(int start,
                              int stop)

  Description copied from interface: `Playable`
  Sets the loop points used when looping.

  Specified by:
    `setLoopPoints` in interface `Playable`
  Parameters:
    `start` - the start of the loop in milliseconds
    `stop` - the end of the loop in milliseconds

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD