Om
1.0.0
A universal framework for multimedia simulation
|
A class that represents either a streaming or memory-resident sound resource. More...
#include <omSound.h>
Public Member Functions | |
Sound () | |
Create a new sound resource that has no sound data. More... | |
Sound (const SoundBuffer &buffer) | |
Create a new sound resource for the specified memory-resident sound buffer. More... | |
Sound (const SoundBuffer &buffer, Size numSamples) | |
Create a new sound resource for the specified memory-resident sound buffer. More... | |
Sound (const Shared< SoundBuffer > &buffer) | |
Create a new sound resource that shares the specified memory-resident sound buffer. More... | |
Sound (const Shared< SoundInputStream > &stream) | |
Create a new sound resource for the specified sound input stream. More... | |
~Sound () | |
Destroy a sound and release its stream and/or buffer. More... | |
Bool | hasStream () const |
Return whether or not this resource has a streaming source of sound data. More... | |
const Shared< SoundInputStream > & | getStream () const |
Return a pointer to this sound resource's streaming source of sound data. More... | |
Bool | setStream (const Shared< SoundInputStream > &newStream) |
Set a pointer to this sound resource's streaming source of sound data. More... | |
Bool | hasBuffer () const |
Return whether or not this resource has a memory-resident buffer of sound data. More... | |
const Shared< SoundBuffer > & | getBuffer () const |
Return a pointer to this sound resource's internal memory-resident buffer of sound data. More... | |
void | setBuffer (const Shared< SoundBuffer > &newBuffer) |
Set a pointer to this sound resource's internal memory-resident buffer of sound data. More... | |
Bool | loadBuffer (Bool releaseStream=false) |
Load this resource from its stream into a buffer if possible. More... | |
Bool | unloadBuffer () |
Destroy the buffer for this resource, and revert to using the stream if possible. More... | |
virtual Bool | canSeek () const |
Return whether or not seeking is allowed in this sound resource input stream. More... | |
virtual Bool | canSeek (Int64 relativeSampleOffset) const |
Return whether or not this resource stream's current position can be moved by the specified signed sample offset. More... | |
virtual Int64 | seek (Int64 relativeSampleOffset) |
Move the current sample frame position in the resource stream by the specified signed amount. More... | |
virtual SoundSize | getSamplesRemaining () const |
Return the number of samples remaining in the sound resource input stream. More... | |
virtual SampleIndex | getPosition () const |
Return the current position of the stream within itself. More... | |
virtual Size | getChannelCount () const |
Return the number of channels that are in the sound resource input stream. More... | |
virtual SampleRate | getSampleRate () const |
Return the sample rate of the sound resource input stream's source audio data. More... | |
virtual SampleType | getNativeSampleType () const |
Return the actual sample type used in the resource stream. More... | |
virtual Bool | isValid () const |
Return whether or not the resource has a valid source of sound data. More... | |
const SoundFormat & | getFormat () const |
Return an object that describes the perferred encoded format of this sound. More... | |
void | setFormat (const SoundFormat &newFormat) |
Change the preferred encoded format of this sound. More... | |
SoundFormatSettings & | getFormatSettings () |
Return the settings for the preferred encoded format of this sound. More... | |
const SoundFormatSettings & | getFormatSettings () const |
Return the settings for the preferred encoded format of this sound. More... | |
void | setFormatSettings (const SoundFormatSettings &newFormatSettings) |
Change the settings for the preferred encoded format of this sound. More... | |
Bool | hasEncodedData () const |
Return whether or not this sound has any encoded data. More... | |
UByte * | getEncodedData () |
Return a pointer to the encoded data for this sound. More... | |
const UByte * | getEncodedData () const |
Return a pointer to the encoded data for this sound. More... | |
Size | getEncodedDataSize () const |
Return the size in bytes of the encoded data for this sound. More... | |
Bool | setEncodedDataSize (Size newEncodedDataSize) |
Set the size of the encoded data for this sound. More... | |
Bool | setEncodedData (const UByte *newEncodedData, Size newEncodedDataSize) |
Set the encoded data for this sound. More... | |
Bool | setEncodedData (const UByte *newEncodedData, Size newEncodedDataSize, const SoundFormat &format) |
Set the encoded data for this sound. More... | |
void | clearEncodedData () |
Deallocate any previous encoded sound data. More... | |
Public Member Functions inherited from om::sound::base::SoundInputStream | |
virtual | ~SoundInputStream () |
Destroy this sound input stream and release any resources associated with it. More... | |
SoundResult | read (SoundBuffer &buffer, Size numSamples) |
Read the specified number of samples from the input stream into a sound buffer. More... | |
Bool | hasSamplesRemaining () const |
Return whether or not this sound input stream has any samples remaining in the stream. More... | |
Static Public Attributes | |
static const om::resources::ResourceType | RESOURCE_TYPE |
The resource type for a sound. More... | |
Additional Inherited Members |
A class that represents either a streaming or memory-resident sound resource.
This class allows the user to reference a source of sound data without knowing its storage type. The source could be a memory-resident SoundBuffer which contains the referenced sound data or the source could be a streaming source of data (i.e. from a file). Thus, this allows both streaming and non-streaming sounds to be treated the same.
om::sound::base::Sound::Sound | ( | ) |
Create a new sound resource that has no sound data.
om::sound::base::Sound::Sound | ( | const SoundBuffer & | buffer | ) |
Create a new sound resource for the specified memory-resident sound buffer.
This constructor copies the contents of the specified buffer into a new internal buffer.
om::sound::base::Sound::Sound | ( | const SoundBuffer & | buffer, |
Size | numSamples | ||
) |
Create a new sound resource for the specified memory-resident sound buffer.
This constructor copies the specified number of samples from the specified buffer into a new internal buffer.
om::sound::base::Sound::Sound | ( | const Shared< SoundBuffer > & | buffer | ) |
Create a new sound resource that shares the specified memory-resident sound buffer.
om::sound::base::Sound::Sound | ( | const Shared< SoundInputStream > & | stream | ) |
Create a new sound resource for the specified sound input stream.
This constructor allows the user to optionally specify if the data pointed to by the stream should be read entirely into memory, rather than being streamed in real time. The default is to use pure streaming.
om::sound::base::Sound::~Sound | ( | ) |
Destroy a sound and release its stream and/or buffer.
|
inline |
Return whether or not this resource has a streaming source of sound data.
|
inline |
Return a pointer to this sound resource's streaming source of sound data.
Bool om::sound::base::Sound::setStream | ( | const Shared< SoundInputStream > & | newStream | ) |
Set a pointer to this sound resource's streaming source of sound data.
The sound uses the current position within the sound stream as the start of the sound.
|
inline |
Return whether or not this resource has a memory-resident buffer of sound data.
|
inline |
Return a pointer to this sound resource's internal memory-resident buffer of sound data.
void om::sound::base::Sound::setBuffer | ( | const Shared< SoundBuffer > & | newBuffer | ) |
Set a pointer to this sound resource's internal memory-resident buffer of sound data.
Load this resource from its stream into a buffer if possible.
The method returns whether or not the resource was able to be loaded. If the parameter is set to TRUE, the backing stream is released upon load.
Bool om::sound::base::Sound::unloadBuffer | ( | ) |
Destroy the buffer for this resource, and revert to using the stream if possible.
The method returns whether or not the resource was able to be unloaded. The method fails if there is no stream for the resource.
|
virtual |
Return whether or not seeking is allowed in this sound resource input stream.
Reimplemented from om::sound::base::SoundInputStream.
Return whether or not this resource stream's current position can be moved by the specified signed sample offset.
Reimplemented from om::sound::base::SoundInputStream.
Move the current sample frame position in the resource stream by the specified signed amount.
Reimplemented from om::sound::base::SoundInputStream.
|
virtual |
Return the number of samples remaining in the sound resource input stream.
Implements om::sound::base::SoundInputStream.
|
virtual |
Return the current position of the stream within itself.
Implements om::sound::base::SoundInputStream.
|
virtual |
Return the number of channels that are in the sound resource input stream.
Implements om::sound::base::SoundInputStream.
|
virtual |
Return the sample rate of the sound resource input stream's source audio data.
Implements om::sound::base::SoundInputStream.
|
virtual |
Return the actual sample type used in the resource stream.
Implements om::sound::base::SoundInputStream.
|
virtual |
Return whether or not the resource has a valid source of sound data.
Implements om::sound::base::SoundInputStream.
|
inline |
Return an object that describes the perferred encoded format of this sound.
void om::sound::base::Sound::setFormat | ( | const SoundFormat & | newFormat | ) |
Change the preferred encoded format of this sound.
This call deallocates the sound's encoded data if it was allocated and the new format is not compatible with the previous encoded data format.
|
inline |
Return the settings for the preferred encoded format of this sound.
|
inline |
Return the settings for the preferred encoded format of this sound.
|
inline |
Change the settings for the preferred encoded format of this sound.
|
inline |
Return whether or not this sound has any encoded data.
|
inline |
Return a pointer to the encoded data for this sound.
If the returned pointer is NULL, it indicates the start of memory containing the sound's encoded data in its format.
|
inline |
Return a pointer to the encoded data for this sound.
If the returned pointer is NULL, it indicates the start of memory containing the sound's encoded data in its format.
|
inline |
Return the size in bytes of the encoded data for this sound.
Set the size of the encoded data for this sound.
The sound allocates internal space for the specified number of bytes of encoded sound data. The contents of the encoded data are undefined.
Bool om::sound::base::Sound::setEncodedData | ( | const UByte * | newEncodedData, |
Size | newEncodedDataSize | ||
) |
Set the encoded data for this sound.
The sound copies the sound data to internal memory and the current sound format is used. The method returns whether or not the operation was successful.
Bool om::sound::base::Sound::setEncodedData | ( | const UByte * | newEncodedData, |
Size | newEncodedDataSize, | ||
const SoundFormat & | format | ||
) |
Set the encoded data for this sound.
The sound copies the sound data to internal memory and the sound format is set to the specified format. The method returns whether or not the operation was successful.
void om::sound::base::Sound::clearEncodedData | ( | ) |
Deallocate any previous encoded sound data.
This method is used to discard a previously encoded version of an sound so that will be re-encoded when it is next saved. This method should be called whenever an sound's pixel data is edited.
|
static |
The resource type for a sound.