#include <SoundPlayer.h>
Inheritance diagram for ark::SoundPlayer:
Public Types | |
typedef impl::_SoundPlayerNotification | Notification |
This is the sound notification type. It contains all necessary data to update observers. | |
typedef GenericCommand< SoundPlayer > | Command |
Used to issue commands to the realtime thread context. | |
typedef AsyncNotifier< Notification, Observer< Notification >, SoundPlayer > | Notifier |
typedef Overflow_Template< Command > | ParamOverflow |
These exceptions are only thrown from a NON realtime NON render thread. | |
enum | NotificationType { PlayingDidChange, PlayPositionDidChange, PlayingDidLoop, LoopingDidChange, AmplitudeModDidChange, BalanceDidChange, SelectedRegionDidChange, StreamErrorOccured } |
enum | StreamError { UnknownError, UnderflowError, ParamError } |
Public Member Functions | |
SoundPlayer () | |
~SoundPlayer () | |
void | receiveNotification (Notification const ¬e) |
void | initialize () |
void | uninitialize () |
void | open (std::string const &path) |
void | setResource (boost::shared_ptr< SoundResource > const &rsrc) |
void | setResource (SoundChunk const &chunk, unsigned sampleRate) |
bool | isOpen () const |
void | close () |
void | setLive (bool b) |
bool | isLive () const |
void | setAmplitudeMod (float mod) |
float | amplitudeMod () const |
void | setBalance (float mod) |
float | balance () const |
unsigned | frameCount () const |
unsigned | channelCount () const |
unsigned | sampleRate () const |
void | play () |
void | pause (bool wait=false) |
bool | togglePlaying () |
void | stop (bool wait=false) |
bool | isPlaying () const |
unsigned | playPosition () const |
void | setPlayPosition (unsigned pos) |
void | setLooping (bool b) |
bool | isLooping () const |
bool | toggleLooping () |
void | setMute (bool b) |
bool | isMute () const |
bool | toggleMute () |
unsigned | nextChunk (SoundChunk &chunk, unsigned frames, SoundTime const &time) |
Static Public Member Functions | |
static unsigned | defaultRenderFrames () |
static void | setDefaultRenderFrames (unsigned) |
static unsigned | defaultCacheFrames () |
static void | setDefaultCacheFrames (unsigned) |
static bool | doesNotifyByDefault () |
static void | setNotifiesByDefault (bool) |
static boost::shared_ptr< Notifier > | notifier () |
Protected Types | |
typedef boost::mutex::scoped_lock | scoped_lock |
Private Member Functions | |
void | _rtSetPlayPosition (Notification const &) |
void | _rtSetSelectedRegion (Notification const &) |
void | _rtSetAmpMod (Notification const &) |
void | _rtSetBalance (Notification const &) |
void | _rtSetCurrentTime (SoundTime const &t) |
void | _rtIncrementTime (unsigned frames) |
SoundTime const & | _rtCurrentTime () const |
void | _resetState () |
void | _scheduleNotification (Notification const &) |
void | _rtStreamMaintenance (SoundTime const &) |
bool | _rtReceiveFromStreamer () |
void | _rtUpdateParams () |
void | _rtApplyParams (SoundChunk &) |
void | _rtStop (Notification const &) |
void | _rtSendNotification (Notification const &) |
Private Attributes | |
boost::mutex | _genMutex |
Generic instance mutex. | |
boost::shared_ptr< SoundStreamer > | _streamer |
boost::shared_ptr< Fifo< SoundStreamerChunk > > | _streamQueue |
SoundChunk | _cacheChunk |
Cached data. | |
unsigned | _renderChunkSize |
The size of the chunk the render thread will request. | |
unsigned | _cacheChunkSize |
The size of the cache, in frames. | |
SoundRegion | _cacheReg |
The region of sound that the cache stores. | |
unsigned | _minCacheSpace |
The threshold for ordering more chunks. | |
volatile bool | _waitingForCache |
True if we are waiting for a chunk from the feeder. | |
unsigned | _playPos |
The read head of the sound player. | |
volatile unsigned | _rt_playPos |
unsigned | _playerRate |
The sample rate of the player. | |
Atomic< bool > | _play |
True if we should keep playing. | |
Atomic< bool > | _loop |
True if we should loop. | |
Atomic< bool > | _mute |
Atomic< bool > | _doNotify |
double | _logicFrameMod |
Fifo< Command > | _paramPort |
This sends the parameter changes to the realtime context. | |
Semaphore | _fromRtSem |
This is a generic signal semaphore for RT to USER communication. | |
Atomic< bool > | _didSignal |
SoundRegion | _selectedReg |
SoundRegion | _rt_selectedReg |
SoundRegion | _pendingReg |
bool | _regIsPending |
float | _ampMod |
float | _rt_ampMod |
float | _rt_lastAmp |
float | _balance |
float | _rt_balance |
float | _rt_lastBal |
SoundTime | _rt_curTime |
Static Private Attributes | |
static boost::shared_ptr< Notifier > | _notifier = shared_ptr<SoundPlayer::Notifier>() |
static boost::shared_ptr< MessagePort< Notification > > | _noteQueue = shared_ptr<MessagePort<SoundPlayer::Notification> >() |
static MemoryGate | _rtGate = MemoryGate<>(ARK_SOUNDPLAYER_GATE_QUEUE_SIZE) |
static MemoryDeallocServer | _rtDeallocServer |
static boost::mutex | _sharedMutex |
static const unsigned | _paramTransFrames = 256 |
static unsigned | _defaultRenderFrames = ARK_SOUNDPLAYER_DEFAULT_RENDER_FRAMES |
static unsigned | _defaultCacheFrames = ARK_SOUNDPLAYER_DEFAULT_CACHE_FRAMES |
static bool | _doesNotifyByDefault = ARK_SOUNDPLAYER_DOES_NOTIFY_BY_DEFAULT |
static boost::mutex | _staticDataMutex |
|
Used to issue commands to the realtime thread context.
|
|
This is the sound notification type. It contains all necessary data to update observers. Types |
|
|
|
These exceptions are only thrown from a NON realtime NON render thread.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
amplitudeMod
|
|
balance
|
|
channelCount
|
|
close Stops the player and closes any open resources. This function blocks while waiting for stop confirmation.
|
|
|
|
|
|
|
|
frameCount
|
|
initialize Initializes the player to a state in which the play() function will succeed.
|
|
isLive
|
|
isLooping
|
|
isMute
|
|
isOpen
|
|
isPlaying
|
|
nextChunk Copies the next chunk in the sound to the passed chunk memory.
|
|
|
|
open Opens the file at the specififed path. Stops and closes any currently open resource. This function blocks while waiting for stop confirmation.
|
|
pause Sets up the player so that the next call to nextChunk() will clear the passed chunk and return immediatly. If wait is true, pause blocks until it receives confirmation that the player is paused.
|
|
play Sets the player up so that on the next call to nextChunk() it will return a chunk from it's loaded resource (if any). |
|
playPosition
|
|
receiveNotification Receives a notification concerning this from the standard notifier thread. Checks for param changes and propogates them to user readable objects in a thread-safe manner. This should NEVER be called from the realtime context.
Implements ark::Observer< impl::_SoundPlayerNotification >. |
|
sampleRate
|
|
setAmplitudeMod
|
|
setBalance
|
|
|
|
|
|
setLive Sets whether the player is attached to a live sink, that is if it receives periodic 'pull' requests. If live is false, a worker thread is marshalled to keep the player queues moving, thus allowing offline editing.
|
|
setLooping
|
|
setMute
|
|
|
|
setPlayPosition
|
|
setResource Stops and closes any currently open resource, and sets the passed chunk to be the in memory data source. Note that a side effect is that the streamer thread will be terminated. This function blocks while waiting for stop confirmation.
|
|
setResource Stops and closes any currently open resource, and uses the passed resource as the new sound data source. This function blocks while waiting for stop confirmation.
|
|
stop Sets up the player so that the play position is 0 and the next call to nextChunk() will clear the passed chunk and return immediatly. If wait is true, pause blocks until it receives confirmation that the player is stopped.
|
|
toggleLooping Toggles looping and returns loop status.
|
|
toggleMute Toggles muting and returns mute status.
|
|
togglePlaying Toggles playback and returns play status.
|
|
uinitialize Uninitializes the player to a state in which all supporting structures are uninitailized.
|
|
|
|
|
|
Cached data.
|
|
The size of the cache, in frames.
|
|
The region of sound that the cache stores.
|
|
|
|
|
|
|
|
|
|
|
|
This is a generic signal semaphore for RT to USER communication.
|
|
Generic instance mutex.
|
|
Multiply this by the _streamer->frameCount() to get the amount of frames after any time distorting operations, like sample rate conversion or time stretching. |
|
True if we should loop.
|
|
The threshold for ordering more chunks.
|
|
|
|
|
|
|
|
This sends the parameter changes to the realtime context.
|
|
|
|
|
|
True if we should keep playing.
|
|
The sample rate of the player.
|
|
The read head of the sound player.
|
|
|
|
The size of the chunk the render thread will request.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
True if we are waiting for a chunk from the feeder.
|