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

## toxi.audio
Class JOALUtil

    java.lang.Object
      toxi.audio.JOALUtil

    public class JOALUtil

extends java.lang.Object

JOAL convenience wrapper. Full documentation forthcoming. Please see the attached Processing demo & source distribution of this package for basic usage.

Field Summary
`static java.lang.String` | `HARDWARE`
`static java.util.logging.Logger` | `logger`
`static java.lang.String` | `SOFTWARE`

Method Summary
`void` | `deleteAll()` Deletes & releases all sources and buffers created via this class.
`boolean` | `deleteBuffer(AudioBuffer b)`
`boolean` | `deleteSource(AudioSource src)`
`boolean` | `deleteSource(AudioSource src, boolean killBuffer)`
`AudioBuffer[]` | `generateBuffers(int numBuffers)` Creates the specified number of audio sample buffers and returns an array of `AudioBuffer` wrappers.
`AudioSource` | `generateSource()` Convenience wrapper for `generateSources(int)` to create a single `AudioSource`.
`AudioSource` | `generateSourceFromFile(java.lang.String file)` Convenience wrapper bundling `loadBuffer(String)` & `generateSource()` in a single method call.
`AudioSource[]` | `generateSources(int numSources)` Creates the specified number of hardware audio sources required to actually play the sample data stored in `AudioBuffer`s.
`net.java.games.joal.AL` | `getAL()` Returns a direct reference to the OpenAL API.
`java.lang.String[]` | `getDeviceList()` Retrieves a list of available OpenAL compatible audio devices.
`static JOALUtil` | `getInstance()`
`SoundListener` | `getListener()` Returns the `SoundListener` instance for the associated OpenAL context.
`boolean` | `init()` Initializes the OpenAL context.
`boolean` | `init(java.lang.String deviceName, boolean attemptEAX)` Initializes the OpenAL context and if parameter is true, will attempt to also setup an EAX environment.
`boolean` | `isEAXSupported()` Checks if EAX are supported by the underlying hardware.
`AudioBuffer` | `loadBuffer(java.io.InputStream is)` Loads a WAV file from the given `InputStream`.
`AudioBuffer` | `loadBuffer(java.lang.String fileName)` Loads a WAV file (mono/stereo) from the specified file name
`void` | `shutdown()` Destroys all objects, sources, buffers, contexts created by this class.

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

Field Detail

### HARDWARE

    public static java.lang.String HARDWARE

### SOFTWARE

    public static java.lang.String SOFTWARE

### logger

    public static final java.util.logging.Logger logger

Method Detail

### getInstance

    public static JOALUtil getInstance()

### deleteAll

    public void deleteAll()

  Deletes & releases all sources and buffers created via this class.

### deleteBuffer

    public boolean deleteBuffer(AudioBuffer b)

### deleteSource

    public boolean deleteSource(AudioSource src)

### deleteSource

    public boolean deleteSource(AudioSource src,
                                boolean killBuffer)

### generateBuffers

    public AudioBuffer[] generateBuffers(int numBuffers)

  Creates the specified number of audio sample buffers and returns an array of `AudioBuffer` wrappers.

  Parameters:
    `numBuffers` - number of requested buffers
  Returns:
    array

### generateSource

    public AudioSource generateSource()

  Convenience wrapper for `generateSources(int)` to create a single `AudioSource`.

  Returns:
    audio source instance

### generateSourceFromFile

    public AudioSource generateSourceFromFile(java.lang.String file)

  Convenience wrapper bundling `loadBuffer(String)` & `generateSource()` in a single method call. Generates a new `AudioSource` and assigns the sample buffer created from the given WAV file.

  Parameters:
    `file` - absolute path to WAV file
  Returns:
    configured audio source instance

### generateSources

    public AudioSource[] generateSources(int numSources)

  Creates the specified number of hardware audio sources required to actually play the sample data stored in `AudioBuffer`s.

  Parameters:
    `numSources` - number of sources required
  Returns:
    array

### getAL

    public net.java.games.joal.AL getAL()

  Returns a direct reference to the OpenAL API.

  Returns:
    JOAL context

### getDeviceList

    public java.lang.String[] getDeviceList()

  Retrieves a list of available OpenAL compatible audio devices. This method can be called before a call to `init()`.

  Returns:
    array of device names

### getListener

    public SoundListener getListener()

  Returns the `SoundListener` instance for the associated OpenAL context.

  Returns:
    listener object

### init

    public boolean init()

  Initializes the OpenAL context. Safe to be called multiple times (only first time is executed).

  Returns:
    true, if successful

### init

    public boolean init(java.lang.String deviceName,
                        boolean attemptEAX)

  Initializes the OpenAL context and if parameter is true, will attempt to also setup an EAX environment. The method does nothing if it had been called previously and not been `shutdown()` meanwhile.

  Parameters:
    `attemptEAX` -
  Returns:
    true, if successful (does not care if EAX is supported & has succeeded).

### isEAXSupported

    public boolean isEAXSupported()

  Checks if EAX are supported by the underlying hardware.

  Returns:
    true, if supported.

### loadBuffer

    public AudioBuffer loadBuffer(java.io.InputStream is)
                           throws javax.sound.sampled.UnsupportedAudioFileException,
                                  java.io.IOException

  Loads a WAV file from the given `InputStream`.

  Parameters:
    `is` - input stream
  Returns:
    buffer wrapper instance
  Throws:
    `javax.sound.sampled.UnsupportedAudioFileException`
    `java.io.IOException`

### loadBuffer

    public AudioBuffer loadBuffer(java.lang.String fileName)

  Loads a WAV file (mono/stereo) from the specified file name

  Parameters:
    `fileName` - audio file name
  Returns:
    buffer wrapper instance
  Throws:
    `java.io.IOException`
    `javax.sound.sampled.UnsupportedAudioFileException`

### shutdown

    public void shutdown()

  Destroys all objects, sources, buffers, contexts created by this class.

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