quentinc.audio
Class AudioManager

java.lang.Object
  extended by quentinc.audio.Channel
      extended by quentinc.audio.ChannelGroup
          extended by quentinc.audio.AudioManager
All Implemented Interfaces:
java.lang.Runnable

public class AudioManager
extends ChannelGroup
implements java.lang.Runnable

Main class of the system. Provide basic services related to the API.


Constructor Summary
AudioManager()
          Default constructor.
AudioManager(int sampleRate, float bufferMs)
          Create a new AudioManager on system's default sound card with specified rendering sample rate and internal buffer size expressed in seconds.
AudioManager(javax.sound.sampled.Mixer.Info mixerInfo, int sampleRate, float bufferMs)
          Create a new AudioManager on the specified sound card, with sample rate and buffer size given.
 
Method Summary
 void close()
          Close the audio manager and release all associated resources
 DistanceModel getDistanceModel()
          Get the distance model
 Vector getListenerOrientation()
          Get the orientation of the listener.
 Vector getListenerPosition()
          Get the position of the listener in the world space
 Vector getListenerUpwards()
          Get the up vector.
 SpatializationModel getSpatializationModel()
          Get the spatialisation model
 Sample loadSample(java.io.File f)
          Load a sample from a file
 Sample loadSample(java.io.InputStream in)
          Load a sample from an InputStream
 Sample loadSample(java.io.InputStream in, javax.sound.sampled.AudioFormat fmt, int length)
          Load a sample from an InputStream, with format and length given
 Sample loadSample(short[] data, int sampleRate, boolean stereo)
          Load a sample from raw data, with sample rate and mono/stereo mode given.
 Sample loadSample(java.net.URL u)
          Load a sample from an URL
 Stream loadStream(java.io.File f)
          Load a stream from a file
 Stream loadStream(java.io.InputStream in)
          Load a stream from an InputStream
 Stream loadStream(java.io.InputStream in, javax.sound.sampled.AudioFormat fmt)
          Load a stream from an InputStream, with format given.
 Stream loadStream(java.io.InputStream in, javax.sound.sampled.AudioFormat fmt, int length)
          Load a stream from an InputStream, with format and length given.
 Stream loadStream(java.net.URL f)
          Load a stream from an URL
 void run()
          Run method inherited from Runnable interface.
 AudioManager setDistanceModel(DistanceModel dm)
          Set the distance model, the algorythm used to calculate the volume of a playing sound corresponding to a given distance to the listener.
 AudioManager setListenerAttributes(Vector pos, Vector fw, Vector up)
          Set the listener position, orientation and up in a single call.
 AudioManager setListenerOrientation(Vector v)
          Set the listener orientation
 AudioManager setListenerPosition(Vector v)
          Set the listener position
 AudioManager setListenerUpwards(Vector v)
          Set the up vector
 AudioManager setSpatializationModel(SpatializationModel m)
          Set the spatialisation model, the algorythm used to calculate the panning of a playing sound corresponding to a given angle.
 void start()
          Start or restart main audio thread and audio playback.
 void stop()
          Pause main audio thread and audio playback.
 AudioManager update3D()
          Actually update volume and panning of the currently playing sounds corresponding to the current 3D state.
 
Methods inherited from class quentinc.audio.ChannelGroup
createGroup, loop, play, play, setPosition, setPositionInFrames, setVolume
 
Methods inherited from class quentinc.audio.Channel
addChannelListener, addDSP, get3DPosition, getDuration, getDurationInFrames, getPan, getParentChannel, getPitch, getPosition, getPositionInFrames, getReferenceDistance, getRemainingDuration, getRemainingDurationInFrames, getVolume, getVolumeInDB, isActive, isLoop, isPaused, isVirtual, removeChannelListener, removeDSP, set3DPosition, setLoop, setPan, setPaused, setPitch, setReferenceDistance, setRelative3DPosition, setVolumeInDB
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AudioManager

public AudioManager()
             throws javax.sound.sampled.LineUnavailableException
Default constructor. Initialize a new AudioManager on system's default sound card, with a default rendering sample rate of 44100Hz (Standard CD quality) and a default internal buffer size of 70ms.

Throws:
javax.sound.sampled.LineUnavailableException

AudioManager

public AudioManager(int sampleRate,
                    float bufferMs)
             throws javax.sound.sampled.LineUnavailableException
Create a new AudioManager on system's default sound card with specified rendering sample rate and internal buffer size expressed in seconds.

Throws:
javax.sound.sampled.LineUnavailableException

AudioManager

public AudioManager(javax.sound.sampled.Mixer.Info mixerInfo,
                    int sampleRate,
                    float bufferMs)
             throws javax.sound.sampled.LineUnavailableException
Create a new AudioManager on the specified sound card, with sample rate and buffer size given.

Throws:
javax.sound.sampled.LineUnavailableException
Method Detail

getListenerPosition

public Vector getListenerPosition()
Get the position of the listener in the world space


getListenerOrientation

public Vector getListenerOrientation()
Get the orientation of the listener.


getListenerUpwards

public Vector getListenerUpwards()
Get the up vector.


setListenerPosition

public AudioManager setListenerPosition(Vector v)
Set the listener position


setListenerOrientation

public AudioManager setListenerOrientation(Vector v)
Set the listener orientation


setListenerUpwards

public AudioManager setListenerUpwards(Vector v)
Set the up vector


setListenerAttributes

public AudioManager setListenerAttributes(Vector pos,
                                          Vector fw,
                                          Vector up)
Set the listener position, orientation and up in a single call.


setDistanceModel

public AudioManager setDistanceModel(DistanceModel dm)
Set the distance model, the algorythm used to calculate the volume of a playing sound corresponding to a given distance to the listener.


getDistanceModel

public DistanceModel getDistanceModel()
Get the distance model


setSpatializationModel

public AudioManager setSpatializationModel(SpatializationModel m)
Set the spatialisation model, the algorythm used to calculate the panning of a playing sound corresponding to a given angle.


getSpatializationModel

public SpatializationModel getSpatializationModel()
Get the spatialisation model


update3D

public AudioManager update3D()
Actually update volume and panning of the currently playing sounds corresponding to the current 3D state. Should be called once per frame.


run

public void run()
Run method inherited from Runnable interface.

Specified by:
run in interface java.lang.Runnable

close

public void close()
Close the audio manager and release all associated resources

Overrides:
close in class ChannelGroup

start

public void start()
Start or restart main audio thread and audio playback.


stop

public void stop()
Pause main audio thread and audio playback.

Overrides:
stop in class Channel

loadSample

public Sample loadSample(java.io.File f)
                  throws java.io.IOException,
                         javax.sound.sampled.UnsupportedAudioFileException
Load a sample from a file

Throws:
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException

loadSample

public Sample loadSample(java.net.URL u)
                  throws java.io.IOException,
                         javax.sound.sampled.UnsupportedAudioFileException
Load a sample from an URL

Throws:
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException

loadSample

public Sample loadSample(java.io.InputStream in)
                  throws java.io.IOException,
                         javax.sound.sampled.UnsupportedAudioFileException
Load a sample from an InputStream

Throws:
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException

loadSample

public Sample loadSample(java.io.InputStream in,
                         javax.sound.sampled.AudioFormat fmt,
                         int length)
                  throws java.io.IOException,
                         javax.sound.sampled.UnsupportedAudioFileException
Load a sample from an InputStream, with format and length given

Throws:
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException

loadSample

public Sample loadSample(short[] data,
                         int sampleRate,
                         boolean stereo)
Load a sample from raw data, with sample rate and mono/stereo mode given.


loadStream

public Stream loadStream(java.io.File f)
                  throws java.io.IOException,
                         javax.sound.sampled.UnsupportedAudioFileException
Load a stream from a file

Throws:
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException

loadStream

public Stream loadStream(java.net.URL f)
                  throws java.io.IOException,
                         javax.sound.sampled.UnsupportedAudioFileException
Load a stream from an URL

Throws:
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException

loadStream

public Stream loadStream(java.io.InputStream in)
                  throws java.io.IOException,
                         javax.sound.sampled.UnsupportedAudioFileException
Load a stream from an InputStream

Throws:
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException

loadStream

public Stream loadStream(java.io.InputStream in,
                         javax.sound.sampled.AudioFormat fmt)
                  throws java.io.IOException,
                         javax.sound.sampled.UnsupportedAudioFileException
Load a stream from an InputStream, with format given.

Throws:
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException

loadStream

public Stream loadStream(java.io.InputStream in,
                         javax.sound.sampled.AudioFormat fmt,
                         int length)
                  throws java.io.IOException,
                         javax.sound.sampled.UnsupportedAudioFileException
Load a stream from an InputStream, with format and length given.

Throws:
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException