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 AudioSource

    java.lang.Object
      ddf.minim.Controller
          ddf.minim.AudioSource

All Implemented Interfaces:
  Effectable, Recordable

Direct Known Subclasses:
  AudioInput, AudioOutput, AudioPlayer, AudioSample

    public class AudioSource

extends Controller
implements Effectable, Recordable

An `AudioSource` is a kind of wrapper around an `AudioStream`. An `AudioSource` will add its `AudioBuffer`s as listeners on the stream so that you can access the stream's samples without having to implement `AudioListener` yourself. It also provides the `Effectable` and `Recordable` interface. Because an `AudioStream` must be closed when you are finished with it, you must remember to call `close()` on any `AudioSource`s you obtain from Minim, such as `AudioInput`s, `AudioOutput`s, and `AudioPlayer`s.

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`

Constructor Summary
`AudioSource(AudioStream istream)` Constructs an `AudioSource` that will subscribe to the samples in `stream`.

Method Summary
`void` | `addEffect(AudioEffect effect)` 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.
`void` | `clearEffects()` Removes all effects from the effect chain.
`void` | `close()` Closes the `AudioStream` this was constructed with.
`void` | `disableEffect(AudioEffect effect)` Disables `effect` if it is in the chain.
`void` | `disableEffect(int i)` disables the `i`th 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(AudioEffect effect)` Enables `effect` if it is in the chain.
`void` | `enableEffect(int i)` Enables the `i`th effect in the effect chain.
`AudioEffect` | `getEffect(int i)` Returns the `ith` effect in the effect chain.
`javax.sound.sampled.AudioFormat` | `getFormat()` Returns the format of this recordable audio.
`boolean` | `hasEffect(AudioEffect e)` Returns true if `effect` is in the chain.
`boolean` | `isEffected()` Returns true if at least one effect in the chain is enabled.
`boolean` | `isEnabled(AudioEffect effect)` Returns true if `effect` is in the chain and is also enabled.
`void` | `noEffects()` Disables all effects currently attached to this.
`void` | `removeEffect(AudioEffect effect)` Removes `effect` 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.
`float` | `sampleRate()` Returns the sample rate of this recordable audio.
`int` | `type()` Returns either Minim.MONO or Minim.STEREO

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`

Field Detail

### left

    public final AudioBuffer left

  The buffer containing the left channel samples. If this is a mono `AudioSource`, it contains the single channel of audio.

### right

    public final AudioBuffer right

  The buffer containing the right channel samples. If this is a mono `AudioSource`, `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 `AudioSource`, `mix` contains the same samples as `left`.

Constructor Detail

### AudioSource

    public AudioSource(AudioStream istream)

  Constructs an `AudioSource` that will subscribe to the samples in `stream`. It is expected that the stream is using a `DataLine` for playback. If it is not, calls to `Controller`'s methods will result in a `NullPointerException`.

  Parameters:
    `istream` - the `AudioStream` to subscribe to and wrap

Method Detail

### close

    public void close()

  Closes the `AudioStream` this was constructed with.

### addEffect

    public void addEffect(AudioEffect effect)

  Description copied from interface: `Effectable`
  Adds an effect to the effects chain.

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

### clearEffects

    public void clearEffects()

  Description copied from interface: `Effectable`
  Removes all effects from the effect chain.

  Specified by:
    `clearEffects` in interface `Effectable`

### disableEffect

    public void disableEffect(int i)

  Description copied from interface: `Effectable`
  disables the `i`th effect in the effect chain.

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

### disableEffect

    public void disableEffect(AudioEffect effect)

  Description copied from interface: `Effectable`
  Disables `effect` if it is in the chain.

  Specified by:
    `disableEffect` in interface `Effectable`
  Parameters:
    `effect` - the `AudioEffect` to disable

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

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

### hasEffect

    public boolean hasEffect(AudioEffect e)

  Description copied from interface: `Effectable`
  Returns true if `effect` is in the chain.

  Specified by:
    `hasEffect` in interface `Effectable`
  Parameters:
    `e` - the effec to check for
  Returns:
    true if `effect` is attached to this

### enableEffect

    public void enableEffect(int i)

  Description copied from interface: `Effectable`
  Enables the `i`th effect in the effect chain.

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

### enableEffect

    public void enableEffect(AudioEffect effect)

  Description copied from interface: `Effectable`
  Enables `effect` if it is in the chain.

  Specified by:
    `enableEffect` in interface `Effectable`
  Parameters:
    `effect` - the `AudioEffect` to enable

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

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

### isEnabled

    public boolean isEnabled(AudioEffect effect)

  Description copied from interface: `Effectable`
  Returns true if `effect` is in the chain and is also enabled.

  Specified by:
    `isEnabled` in interface `Effectable`
  Parameters:
    `effect` - the `AudioEffect` to check the status of
  Returns:
    true if `effect` is in the chain and 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 effect)

  Description copied from interface: `Effectable`
  Removes `effect` from the effects chain.

  Specified by:
    `removeEffect` in interface `Effectable`
  Parameters:
    `effect` - 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`

### 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. If the listener has already been added, it will not be added again.

  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.

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

### getFormat

    public javax.sound.sampled.AudioFormat getFormat()

  Description copied from interface: `Recordable`
  Returns the format of this recordable audio.

  Specified by:
    `getFormat` in interface `Recordable`
  Returns:
    the format of the audio

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

### type

    public int type()

  Description copied from interface: `Recordable`
  Returns either Minim.MONO or Minim.STEREO

  Specified by:
    `type` in interface `Recordable`
  Returns:
    Minim.MONO if this is mono, Minim.STEREO if this is stereo

### sampleRate

    public float sampleRate()

  Description copied from interface: `Recordable`
  Returns the sample rate of this recordable audio.

  Specified by:
    `sampleRate` in interface `Recordable`
  Returns:
    the sample rate of this recordable audio

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