Om
1.0.0
A universal framework for multimedia simulation
|
A class that allows the user to trigger multiple sound stream to be played. More...
#include <omSoundPlayer.h>
Classes | |
class | Instance |
A class that contains information about a single playback instance for a sound player. More... | |
Public Types | |
typedef Index | InstanceID |
The type to use to represent the ID of a instance that is currently playing in the player. More... | |
Public Member Functions | |
SoundPlayer () | |
Create a new default player which has no sounds currently playing. More... | |
SoundPlayer (const ChannelLayout &newOutputChannelLayout, SampleRate newSampleRate=SampleRate(44100), Size newMaxInstanceCount=Size(100)) | |
Create a new player which has no sounds currently playing and the specified attributes. More... | |
SoundPlayer (const SoundPlayer &other) | |
Create a copy of the specified player with all stream playback state exactly the same. More... | |
~SoundPlayer () | |
Destroy this player and any associated resources. More... | |
SoundPlayer & | operator= (const SoundPlayer &other) |
Assign the entire state of another player to this one, including stream playback state. More... | |
Size | getMaxInstanceCount () const |
Return the maximum number of simultaneous playback instances that this player is allowed to play. More... | |
void | setMaxInstanceCount (Size newMaxStreamCount) |
Set the maximum number of simultaneous playback instances that this player is allowed to play. More... | |
Size | getInstanceCount () const |
Return the total number of streams that are currently playing in this player. More... | |
const Instance & | getInstance (InstanceID instanceID) const |
Return a reference to the instance data for the playback instance with the given ID. More... | |
InstanceID | play (const Instance &instance) |
Play a sound playback instance with the specified instance data. More... | |
Bool | isPlaying (InstanceID instanceID) const |
Return whether or not the stream with the specified ID is currently playing. More... | |
Bool | update (InstanceID instanceID, const Instance &instance) |
Update the playback state for the instance with the specified ID. More... | |
Bool | pause (InstanceID instanceID) |
Pause playback for the instance with the specified ID. More... | |
Bool | resume (InstanceID instanceID) |
Resume playback for the previously paused instance with the specified ID. More... | |
Bool | stop (InstanceID instanceID) |
Stop playback for the instance with the specified ID and remove it from the player. More... | |
void | pauseAll () |
Pause playback for all currently playing instances in this player. More... | |
void | resumeAll () |
Resume playback for all currently paused instances in this player. More... | |
void | stopAll () |
Remove and stop playing all currently playing streams from this player. More... | |
Bool | updateUserID (Index userID, const Instance &instance) |
Update playback for all instances that have the specified user ID. More... | |
Bool | pauseUserID (Index userID) |
Pause playback for all instances that have the specified user ID. More... | |
Bool | resumeUserID (Index userID) |
Resume playback for all instances that have the specified user ID. More... | |
Bool | stopUserID (Index userID) |
Stop playing all instances that have the specified user ID. More... | |
const ChannelLayout & | getOutputChannelLayout () const |
Return a reference to an object that describes the output channel format for this player. More... | |
void | setOutputChannelLayout (const ChannelLayout &newChannelLayout) |
Change the output channel format for this player. More... | |
SampleRate | getOutputSampleRate () const |
Return the output sample rate for this player. More... | |
void | setOutputSampleRate (SampleRate newSampleRate) |
Set the output sample rate for this player. More... | |
virtual Bool | canSeek () const |
Return whether or not seeking is allowed in this input stream. More... | |
virtual Bool | canSeek (Int64 relativeSampleOffset) const |
Return whether or not this input 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 stream by the specified signed amount. More... | |
virtual SoundSize | getSamplesRemaining () const |
Return the number of samples remaining in the sound input stream. More... | |
virtual SampleIndex | getPosition () const |
Return the current position of the stream in samples relative to the start of the stream. More... | |
virtual Size | getChannelCount () const |
Return the number of channels that are in the sound input stream. More... | |
virtual SampleRate | getSampleRate () const |
Return the sample rate of the sound input stream's source audio data. More... | |
virtual SampleType | getNativeSampleType () const |
Return the actual sample type used in the stream. More... | |
virtual Bool | isValid () const |
Return whether or not the stream has a valid source of sound data. More... | |
virtual UTF8String | getName () const |
Return a human-readable name for this player. More... | |
virtual UTF8String | getManufacturer () const |
Return the manufacturer name of this player. More... | |
virtual FilterVersion | getVersion () const |
Return an object representing the version of this player. More... | |
virtual FilterCategory | getCategory () const |
Return an object that describes the category of effect that this filter implements. More... | |
virtual Bool | allowsInPlaceProcessing () const |
Return whether or not this player can process audio data in-place. More... | |
Public Member Functions inherited from om::sound::filters::SoundFilter | |
virtual | ~SoundFilter () |
Destroy this sound filter object. More... | |
SoundResult | read (SoundBuffer &outputBuffer, Size numSamples) |
Fill the specified output buffer with the requested number of samples, based on internal filter state. More... | |
SoundResult | read (SoundFrame &outputFrame, Size numSamples) |
Fill the specified output frame with the requested number of samples, based on internal filter state. More... | |
SoundResult | write (const SoundBuffer &inputBuffer, Size numSamples) |
Process the specified input buffer samples and do something with them. More... | |
SoundResult | write (const SoundFrame &inputFrame, Size numSamples) |
Process the specified input frame samples and do something with them. More... | |
SoundResult | process (const SoundBuffer &inputBuffer, SoundBuffer &outputBuffer, Size numSamples) |
Apply this filter to the specified input buffer data, placing the result in the output buffer. More... | |
SoundResult | process (const SoundBuffer &inputBuffer, SoundFrame &outputFrame, Size numSamples) |
Apply this filter to the specified input buffer data, placing the result in the output frame. More... | |
SoundResult | process (const SoundFrame &inputFrame, SoundFrame &outputFrame, Size numSamples) |
Apply this filter to the specified input frame data, placing the result in the output frame. More... | |
SoundResult | process (const SoundFrame &inputBuffer, SoundBuffer &outputBuffer, Size numSamples) |
Apply this filter to the specified input frame data, placing the result in the output buffer. More... | |
void | reset () |
Signal to the filter that the audio stream is restarting. More... | |
UInt64 | getFrameIndex () const |
Return the index of the next frame to be processed (or the current one if currently processing). More... | |
Size | getInputCount () const |
Return the current number of audio inputs that this filter has. More... | |
virtual UTF8String | getInputName (Index inputIndex) const |
Return a human-readable name of the filter audio input at the specified index. More... | |
Size | getOutputCount () const |
Return the current number of audio outputs that this filter has. More... | |
virtual UTF8String | getOutputName (Index outputIndex) const |
Return a human-readable name of the filter audio output at the specified index. More... | |
Size | getMIDIInputCount () const |
Return the current number of MIDI inputs that this filter has. More... | |
virtual UTF8String | getMIDIInputName (Index inputIndex) const |
Return a human-readable name of the filter MIDI input at the specified index. More... | |
Size | getMIDIOutputCount () const |
Return the current number of MIDI outputs that this filter has. More... | |
virtual UTF8String | getMIDIOutputName (Index outputIndex) const |
Return a human-readable name of the filter MIDI output at the specified index. More... | |
virtual Time | getLatency () const |
Return a Time value indicating the latency of this sound filter in seconds. More... | |
virtual Size | getParameterCount () const |
Return the total number of generic accessible parameters this filter has. More... | |
virtual Bool | getParameterIndex (const UTF8String ¶meterName, Index ¶meterIndex) const |
Query the index of the parameter with the specified name. More... | |
virtual Bool | getParameterInfo (Index parameterIndex, FilterParameterInfo &info) const |
Get information about the filter parameter at the specified index. More... | |
virtual Bool | getParameterValueName (Index parameterIndex, const FilterParameter &value, UTF8String &name) const |
Get any special name associated with the specified value of an indexed parameter. More... | |
Bool | getParameter (Index parameterIndex, FilterParameter &value) const |
Place the value of the parameter at the specified index in the output parameter. More... | |
Bool | getParameter (Index parameterIndex, Bool &value) const |
Place the value of the parameter at the specified index in the output parameter. More... | |
Bool | getParameter (Index parameterIndex, Int64 &value) const |
Place the value of the parameter at the specified index in the output parameter. More... | |
Bool | getParameter (Index parameterIndex, Float32 &value) const |
Place the value of the parameter at the specified index in the output parameter. More... | |
Bool | getParameter (Index parameterIndex, Float64 &value) const |
Place the value of the parameter at the specified index in the output parameter. More... | |
template<typename ParameterType > | |
Bool | getParameter (const UTF8String &name, ParameterType &value) const |
Place the value of the parameter with the specified name in the output parameter. More... | |
template<typename ParameterType > | |
Bool | getParameter (const char *name, ParameterType &value) const |
Place the value of the parameter with the specified name in the output parameter. More... | |
Bool | setParameter (Index parameterIndex, const FilterParameter &value) |
Attempt to set the parameter value at the specified index. More... | |
Bool | setParameter (Index parameterIndex, Bool value) |
Attempt to set the parameter value at the specified index. More... | |
Bool | setParameter (Index parameterIndex, Int64 value) |
Attempt to set the parameter value at the specified index. More... | |
Bool | setParameter (Index parameterIndex, Float32 value) |
Attempt to set the parameter value at the specified index. More... | |
Bool | setParameter (Index parameterIndex, Float64 value) |
Attempt to set the parameter value at the specified index. More... | |
template<typename ParameterType > | |
Bool | setParameter (const UTF8String &name, ParameterType value) |
Attempt to set the parameter value with the specified name. More... | |
template<typename ParameterType > | |
Bool | setParameter (const char *name, ParameterType value) |
Attempt to set the parameter value with the specified name. More... | |
virtual Bool | writeState (DataOutputStream &stream) const |
Write the current state of this sound filter to a data output stream. More... | |
virtual Bool | readState (DataInputStream &stream) |
Read a previously saved filter state from the specified data input stream and replace the filter's state. More... | |
virtual Size | getPresetCount () const |
Return the number of standard configuration presets that this sound filter has. More... | |
virtual Bool | getPreset (Index presetIndex, FilterPreset &preset) const |
Get the standard preset for this sound filter with the specified index. More... | |
Bool | getIsSynchronized () const |
Return whether or not this sound filter performs thread synchronization. More... | |
void | setIsSynchronized (Bool newIsSynchronized) |
Set whether or not this sound filter performs thread synchronization. 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 UTF8String | NAME |
A string indicating the human-readable name of this player. More... | |
static const UTF8String | MANUFACTURER |
A string indicating the manufacturer name of this player. More... | |
static const FilterVersion | VERSION |
An object indicating the version of this player. More... | |
Static Public Attributes inherited from om::sound::filters::SoundFilter | |
static const om::resources::ResourceType | RESOURCE_TYPE |
The resource type for a sound filter. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from om::sound::filters::SoundFilter | |
static Size | getMaximumNumberOfInputs () |
Return the maximum number of audio inputs that a SoundFilter can support. More... | |
static Size | getMaximumNumberOfOutputs () |
Return the maximum number of audio outputs that a SoundFilter can support. More... | |
static Size | getMaximumNumberOfMIDIInputs () |
Return the maximum number of MIDI inputs that a SoundFilter can support. More... | |
static Size | getMaximumNumberOfMIDIOutputs () |
Return the maximum number of MIDI outputs that a SoundFilter can support. More... | |
Protected Member Functions inherited from om::sound::filters::SoundFilter | |
SoundFilter () | |
Create a new sound filter with 1 audio input and output, and no MIDI inputs or outputs. More... | |
SoundFilter (Size numInputs, Size numOutputs) | |
Create a new sound filter with the specified number of audio inputs and outputs. More... | |
SoundFilter (Size numInputs, Size numOutputs, Size numMIDIInputs, Size numMIDIOutputs) | |
Create a new sound filter with the specified number of audio inputs and outputs. More... | |
virtual Bool | getParameterValue (Index parameterIndex, FilterParameter &value) const |
Place the value of the parameter at the specified index in the output parameter. More... | |
virtual Bool | setParameterValue (Index parameterIndex, const FilterParameter &value) |
Attempt to set the parameter value at the specified index. More... | |
void | setInputCount (Size newNumInputs) |
Set the number of inputs that this filter should have. More... | |
void | setOutputCount (Size newNumOutputs) |
Set the number of outputs that this filter should have. More... | |
void | setMIDIInputCount (Size newNumMIDIInputs) |
Set the number of MIDI inputs that this filter should have. More... | |
void | setMIDIOutputCount (Size newNumMIDIOutputs) |
Set the number of MIDI outputs that this filter should have. More... | |
Bool | isFirstFrame () const |
Return whether or not the filter's next frame to be processed is also its first frame. More... | |
void | lockMutex () const |
Acquire a mutex which handles subclass rendering parameter synchronization. More... | |
void | unlockMutex () const |
Release a mutex which handles subclass rendering parameter synchronization. More... | |
A class that allows the user to trigger multiple sound stream to be played.
These triggered streams are then played back using the provided parameters and mixed together at the output of the player. The streams are automatically mapped to the output channel layout and sample rate converted to the output sample rate if necessary.
The type to use to represent the ID of a instance that is currently playing in the player.
om::sound::filters::SoundPlayer::SoundPlayer | ( | ) |
Create a new default player which has no sounds currently playing.
The player has the default stereo output channel layout and output sample rate of 44100 kHz.
om::sound::filters::SoundPlayer::SoundPlayer | ( | const ChannelLayout & | newOutputChannelLayout, |
SampleRate | newSampleRate = SampleRate(44100) , |
||
Size | newMaxInstanceCount = Size(100) |
||
) |
Create a new player which has no sounds currently playing and the specified attributes.
This constructor allows the user to specify the output channel layout for the player, the output sample rate, and the maximum number of simultaneously playing instances.
If the specified sample rate is invalid, the default sample rate of 44100 kHz is used instead.
om::sound::filters::SoundPlayer::SoundPlayer | ( | const SoundPlayer & | other | ) |
Create a copy of the specified player with all stream playback state exactly the same.
om::sound::filters::SoundPlayer::~SoundPlayer | ( | ) |
Destroy this player and any associated resources.
SoundPlayer& om::sound::filters::SoundPlayer::operator= | ( | const SoundPlayer & | other | ) |
Assign the entire state of another player to this one, including stream playback state.
|
inline |
Return the maximum number of simultaneous playback instances that this player is allowed to play.
If an attempt is made to play an instance using a player that is at its maximum capacity will cause the player to replace the previously playing stream with the lowest priority and/or the oldest age.
|
inline |
Set the maximum number of simultaneous playback instances that this player is allowed to play.
If an attempt is made to play an instance using a player that is at its maximum capacity will cause the player to replace the previously playing stream with the lowest priority and/or the oldest age.
|
inline |
Return the total number of streams that are currently playing in this player.
|
inline |
Return a reference to the instance data for the playback instance with the given ID.
InstanceID om::sound::filters::SoundPlayer::play | ( | const Instance & | instance | ) |
Play a sound playback instance with the specified instance data.
The method returns 0 if playing the stream failed, otherwise, the returned integer indicates an ID for the new playback instance which can be used to modify its parameters during playback.
|
inline |
Return whether or not the stream with the specified ID is currently playing.
Bool om::sound::filters::SoundPlayer::update | ( | InstanceID | instanceID, |
const Instance & | instance | ||
) |
Update the playback state for the instance with the specified ID.
Bool om::sound::filters::SoundPlayer::pause | ( | InstanceID | instanceID | ) |
Pause playback for the instance with the specified ID.
Bool om::sound::filters::SoundPlayer::resume | ( | InstanceID | instanceID | ) |
Resume playback for the previously paused instance with the specified ID.
Bool om::sound::filters::SoundPlayer::stop | ( | InstanceID | instanceID | ) |
Stop playback for the instance with the specified ID and remove it from the player.
void om::sound::filters::SoundPlayer::pauseAll | ( | ) |
Pause playback for all currently playing instances in this player.
void om::sound::filters::SoundPlayer::resumeAll | ( | ) |
Resume playback for all currently paused instances in this player.
void om::sound::filters::SoundPlayer::stopAll | ( | ) |
Remove and stop playing all currently playing streams from this player.
Update playback for all instances that have the specified user ID.
Pause playback for all instances that have the specified user ID.
Resume playback for all instances that have the specified user ID.
Stop playing all instances that have the specified user ID.
|
inline |
Return a reference to an object that describes the output channel format for this player.
void om::sound::filters::SoundPlayer::setOutputChannelLayout | ( | const ChannelLayout & | newChannelLayout | ) |
Change the output channel format for this player.
|
inline |
Return the output sample rate for this player.
The default sample rate is 44100 kHz.
void om::sound::filters::SoundPlayer::setOutputSampleRate | ( | SampleRate | newSampleRate | ) |
Set the output sample rate for this player.
If the new sample rate is less than or equal to 0, the method fails and has no effect. The default sample rate is 44100 kHz.
|
virtual |
Return whether or not seeking is allowed in this input stream.
Reimplemented from om::sound::base::SoundInputStream.
Return whether or not this input 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 stream by the specified signed amount.
Reimplemented from om::sound::base::SoundInputStream.
|
virtual |
Return the number of samples remaining in the sound input stream.
The value returned must only be a lower bound on the total number of sample frames in the stream. For instance, if there are samples remaining, the method should return at least 1. If there are no samples remaining, the method should return 0. This behavior is allowed in order to support never-ending streams which might not have a defined endpoint.
Implements om::sound::base::SoundInputStream.
|
virtual |
Return the current position of the stream in samples relative to the start of the stream.
The returned value indicates the sample index of the current read position within the sound stream. For unbounded streams, this indicates the number of samples that have been read by the stream since it was opened.
Implements om::sound::base::SoundInputStream.
|
virtual |
Return the number of channels that are in the sound input stream.
Implements om::sound::base::SoundInputStream.
|
virtual |
Return the sample rate of the sound input stream's source audio data.
Implements om::sound::base::SoundInputStream.
|
virtual |
Return the actual sample type used in the stream.
Implements om::sound::base::SoundInputStream.
|
virtual |
Return whether or not the stream has a valid source of sound data.
Implements om::sound::base::SoundInputStream.
|
virtual |
Return a human-readable name for this player.
The method returns the string "SoundPlayer".
Reimplemented from om::sound::filters::SoundFilter.
|
virtual |
Return the manufacturer name of this player.
The method returns the string "Om Sound".
Reimplemented from om::sound::filters::SoundFilter.
|
virtual |
Return an object representing the version of this player.
Reimplemented from om::sound::filters::SoundFilter.
|
virtual |
Return an object that describes the category of effect that this filter implements.
This method returns the value FilterCategory::PLAYBACK.
Reimplemented from om::sound::filters::SoundFilter.
|
virtual |
Return whether or not this player can process audio data in-place.
This method always returns TRUE, player can process audio data in-place.
Reimplemented from om::sound::filters::SoundFilter.
|
static |
A string indicating the human-readable name of this player.
|
static |
A string indicating the manufacturer name of this player.
|
static |
An object indicating the version of this player.