Package toxi.audio

Class JOALUtil

java.lang.Object
toxi.audio.JOALUtil

public class JOALUtil extends Object
JOAL convenience wrapper. Full documentation forthcoming. Please see the attached Processing demo & source distribution of this package for basic usage.
  • Field Details

    • HARDWARE

      public static String HARDWARE
    • SOFTWARE

      public static String SOFTWARE
    • logger

      public static final Logger logger
  • Method Details

    • 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(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 AudioBuffers.
      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 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(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

      Loads a WAV file from the given InputStream.
      Parameters:
      is - input stream
      Returns:
      buffer wrapper instance
      Throws:
      UnsupportedAudioFileException
      IOException
    • loadBuffer

      public AudioBuffer loadBuffer(String fileName)
      Loads a WAV file (mono/stereo) from the specified file name
      Parameters:
      fileName - audio file name
      Returns:
      buffer wrapper instance
      Throws:
      IOException
      UnsupportedAudioFileException
    • shutdown

      public void shutdown()
      Destroys all objects, sources, buffers, contexts created by this class.