31 #include <OpenAL/al.h> 32 #include <OpenAL/alc.h> 52 class SeekableReadStream;
118 SoundType type,
bool disposeAfterUse =
true);
193 typedef std::list<Channel *>
TypeList;
293 #define SoundMan Sound::SoundManager::instance() 295 #endif // SOUND_SOUND_H TypeList::iterator typeIt
Iterator into the type list.
bool _ready
Was the sound subsystem successfully initialized?
void getChannelPosition(const ChannelHandle &handle, float &x, float &y, float &z)
Get the position of the channel.
static AudioStream * makeAudioStream(Common::SeekableReadStream *stream)
Create an audio stream from this data stream.
void setTypeGain(SoundType type, float gain)
Set the gain/volume of all channels of a specific type.
Class and macro for implementing singletons.
float gain
The sound type's current gain.
void deinit()
Deinitialize the sound subsystem.
A class holding an UTF-8 string.
void init()
Initialize the sound subsystem.
void setChannelRelative(const ChannelHandle &handle, bool relative)
Set if the channel is relative.
ALint state
The sound's state.
TypeList list
The list of channels for that type.
bool isValidChannel(const ChannelHandle &handle) const
Does this channel handle point to an existing channel?
Common::ScopedPtr< Channel > _channels[kChannelCount]
The sound channels.
void startChannel(ChannelHandle &handle)
Start the channel.
void stopAll()
Stop all channels.
void setChannelPitch(const ChannelHandle &handle, float pitch)
Set the pitch of the channel.
void setListenerOrientation(float dirX, float dirY, float dirZ, float upX, float upY, float upZ)
Set the orientation of the listener.
std::list< Channel * > TypeList
A simple scoped smart pointer template.
std::list< ALuint > buffers
List of buffers for that channel.
Channel(uint32 i, size_t idx, SoundType t, const TypeList::iterator &ti, AudioStream *s, bool d)
Generic template base class for implementing the singleton design pattern.
float gain
The channel's gain.
A class that creates its own thread.
bool isPaused(const ChannelHandle &handle)
Is that channel currently paused?
ALuint source
OpenAL source for this channel.
uint64 getChannelDurationPlayed(const ChannelHandle &handle)
Return the time this channel has already played in milliseconds.
Common::Condition _needUpdate
Condition to signal that an update is needed.
void checkReady()
Check that the SoundManager was properly initialized.
void bufferData(Channel &channel)
Buffer more sound from the channel to the OpenAL buffers.
Common::UString formatChannel(const ChannelHandle &handle) const
Return a string representing the channel referenced by this handle.
void setChannelGain(const ChannelHandle &handle, float gain)
Set the gain/volume of the channel.
void update()
Update the sound information.
Low-level type definitions to handle fixed width types portably.
void setChannelPosition(const ChannelHandle &handle, float x, float y, float z)
Set the position the channel is being played.
void setListenerGain(float gain)
Set the gain of the listener (= the global master volume).
A scoped plain pointer, allowing pointer-y access and normal deletion.
SoundType type
The channel's sound type.
std::list< ALuint > freeBuffers
List of free buffers not filled with data.
A disposable plain pointer, allowing pointer-y access and normal deletion.
static const size_t kChannelCount
Maximal number of channels.
Type _types[kSoundTypeMAX]
The sound types.
std::map< ALuint, ALsizei > bufferSize
Size of a buffer in bytes.
uint32 _curID
The ID the next sound will get.
bool _hasSound
Do we have working sound output?
const Channel * getChannel(const ChannelHandle &handle) const
Return the channel the handle refers to.
void stopChannel(ChannelHandle &handle)
Stop and free the channel.
Generic audio input stream.
void setChannelDistance(const ChannelHandle &handle, float minDistance, float maxDistance)
Set the min and max distance for the channel.
ChannelHandle playAudioStream(AudioStream *audStream, SoundType type, bool disposeAfterUse=true)
Play an audio stream.
A smart pointer with a deletion flag.
uint32 id
The channel's ID.
bool _hasMultiChannel
Do we have the multi-channel extension?
A handle to a sound channel.
SoundType
The type of a sound.
void pauseChannel(ChannelHandle &handle, bool pause)
Pause the channel.
void setListenerPosition(float x, float y, float z)
Set the position of the listener.
void pauseAll(bool pause)
Pause all channels.
size_t index
The channel's index.
Common::DisposablePtr< AudioStream > stream
The actual audio stream.
void triggerUpdate()
Signal that one of streams currently being played has changed and should be updated immediately...
bool fillBuffer(const Channel &channel, ALuint alBuffer, AudioStream *stream, ALsizei &bufferedSize) const
Fill the buffer with data from the audio stream.
bool ready() const
Was the sound subsystem successfully initialized?
uint64 finishedBuffers
Number of bytes in all buffers that finished playing and were unqueued.
ChannelHandle playSoundFile(Common::SeekableReadStream *wavStream, SoundType type, bool loop=false)
Play a sound file.
uint64 getChannelSamplesPlayed(const ChannelHandle &handle)
Return the number of samples this channel has already played.
void freeChannel(ChannelHandle &handle)
Stop and free a channel.
bool isPlaying(const ChannelHandle &handle)
Is that channel currently playing a sound?
Interface for a seekable & readable data stream.
ALenum _format51
The value for the 5.1 multi-channel format.
ChannelHandle newChannel()
Look for a free place in the channel vector.