Om  1.0.0
A universal framework for multimedia simulation
Public Member Functions | Static Public Attributes | List of all members
om::sound::base::Sound Class Reference

A class that represents either a streaming or memory-resident sound resource. More...

#include <omSound.h>

Inheritance diagram for om::sound::base::Sound:
om::sound::base::SoundInputStream

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 SoundFormatgetFormat () 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...
 
SoundFormatSettingsgetFormatSettings ()
 Return the settings for the preferred encoded format of this sound. More...
 
const SoundFormatSettingsgetFormatSettings () 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...
 
UBytegetEncodedData ()
 Return a pointer to the encoded data for this sound. More...
 
const UBytegetEncodedData () 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

Detailed Description

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.

Constructor & Destructor Documentation

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.

Member Function Documentation

Bool om::sound::base::Sound::hasStream ( ) const
inline

Return whether or not this resource has a streaming source of sound data.

const Shared<SoundInputStream>& om::sound::base::Sound::getStream ( ) const
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.

Bool om::sound::base::Sound::hasBuffer ( ) const
inline

Return whether or not this resource has a memory-resident buffer of sound data.

const Shared<SoundBuffer>& om::sound::base::Sound::getBuffer ( ) const
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.

Bool om::sound::base::Sound::loadBuffer ( Bool  releaseStream = false)

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 Bool om::sound::base::Sound::canSeek ( ) const
virtual

Return whether or not seeking is allowed in this sound resource input stream.

Reimplemented from om::sound::base::SoundInputStream.

virtual Bool om::sound::base::Sound::canSeek ( Int64  relativeSampleOffset) const
virtual

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.

virtual Int64 om::sound::base::Sound::seek ( Int64  relativeSampleOffset)
virtual

Move the current sample frame position in the resource stream by the specified signed amount.

Reimplemented from om::sound::base::SoundInputStream.

virtual SoundSize om::sound::base::Sound::getSamplesRemaining ( ) const
virtual

Return the number of samples remaining in the sound resource input stream.

Implements om::sound::base::SoundInputStream.

virtual SampleIndex om::sound::base::Sound::getPosition ( ) const
virtual

Return the current position of the stream within itself.

Implements om::sound::base::SoundInputStream.

virtual Size om::sound::base::Sound::getChannelCount ( ) const
virtual

Return the number of channels that are in the sound resource input stream.

Implements om::sound::base::SoundInputStream.

virtual SampleRate om::sound::base::Sound::getSampleRate ( ) const
virtual

Return the sample rate of the sound resource input stream's source audio data.

Implements om::sound::base::SoundInputStream.

virtual SampleType om::sound::base::Sound::getNativeSampleType ( ) const
virtual

Return the actual sample type used in the resource stream.

Implements om::sound::base::SoundInputStream.

virtual Bool om::sound::base::Sound::isValid ( ) const
virtual

Return whether or not the resource has a valid source of sound data.

Implements om::sound::base::SoundInputStream.

const SoundFormat& om::sound::base::Sound::getFormat ( ) const
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.

SoundFormatSettings& om::sound::base::Sound::getFormatSettings ( )
inline

Return the settings for the preferred encoded format of this sound.

const SoundFormatSettings& om::sound::base::Sound::getFormatSettings ( ) const
inline

Return the settings for the preferred encoded format of this sound.

void om::sound::base::Sound::setFormatSettings ( const SoundFormatSettings newFormatSettings)
inline

Change the settings for the preferred encoded format of this sound.

Bool om::sound::base::Sound::hasEncodedData ( ) const
inline

Return whether or not this sound has any encoded data.

UByte* om::sound::base::Sound::getEncodedData ( )
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.

const UByte* om::sound::base::Sound::getEncodedData ( ) const
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.

Size om::sound::base::Sound::getEncodedDataSize ( ) const
inline

Return the size in bytes of the encoded data for this sound.

Bool om::sound::base::Sound::setEncodedDataSize ( Size  newEncodedDataSize)

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.

Member Data Documentation

const om::resources::ResourceType om::sound::base::Sound::RESOURCE_TYPE
static

The resource type for a sound.


The documentation for this class was generated from the following file: