32 #include <condition_variable>
34 namespace cinder {
namespace audio {
53 virtual void seek(
size_t positionFrames ) = 0;
107 virtual void seek(
size_t readPositionFrames )
override;
132 virtual void stop()
override;
133 virtual void seek(
size_t readPositionFrames )
override;
std::atomic< size_t > mReadPos
Definition: SamplePlayerNode.h:93
std::shared_ptr< Buffer > BufferRef
Definition: Buffer.h:293
size_t getReadPosition() const
Returns the current read position in frames.
Definition: SamplePlayerNode.h:58
std::shared_ptr< class FilePlayerNode > FilePlayerNodeRef
Definition: SamplePlayerNode.h:38
SamplePlayerNode(const Format &format=Format())
Definition: SamplePlayerNode.cpp:38
std::shared_ptr< class SourceFile > SourceFileRef
Definition: Source.h:34
std::shared_ptr< class BufferPlayerNode > BufferPlayerNodeRef
Definition: SamplePlayerNode.h:37
void seekImpl(size_t readPos)
Definition: SamplePlayerNode.cpp:433
void setLoopEndTime(double positionSeconds)
Sets the end loop marker in seconds (default = getNumSeconds(), max = getNumSeconds()).
Definition: SamplePlayerNode.cpp:79
void seekToTime(double positionSeconds)
Seek to read position readPositionSeconds,.
Definition: SamplePlayerNode.cpp:69
bool mAsyncReadShouldQuit
Definition: SamplePlayerNode.h:169
std::atomic< size_t > mLoopBegin
Definition: SamplePlayerNode.h:93
void readAsyncImpl()
Definition: SamplePlayerNode.cpp:385
BufferDynamic mIoBuffer
Definition: SamplePlayerNode.h:160
void setLoopBegin(size_t positionFrames)
Sets the begin loop marker in frames (default = 0, max = getNumFrames()).
Definition: SamplePlayerNode.cpp:56
std::vector< dsp::RingBuffer > mRingBuffers
Definition: SamplePlayerNode.h:159
virtual void seek(size_t positionFrames)=0
Seek the read position to readPositionFrames.
double getLoopBeginTime() const
Returns the begin loop marker in seconds.
Definition: SamplePlayerNode.cpp:89
File-based SamplePlayerNode, where samples are constantly streamed from file. Suitable for large audi...
Definition: SamplePlayerNode.h:124
virtual ~FilePlayerNode()
Definition: SamplePlayerNode.cpp:226
virtual void enableProcessing() override
Callled when this Node should enable processing. Initiated from Node::enable().
Definition: SamplePlayerNode.cpp:123
uint64_t getLastOverrun()
Returns the frame of the last buffer overrun or 0 if none since the last time this method was called...
Definition: SamplePlayerNode.cpp:342
size_t mBufferFramesThreshold
Definition: SamplePlayerNode.h:163
BufferRef mBuffer
Definition: SamplePlayerNode.h:120
bool isLoopEnabled() const
Gets whether playing continues from beginning after the end is reached (default = false) ...
Definition: SamplePlayerNode.h:71
void setBuffer(const BufferRef &buffer)
Sets the current Buffer. Safe to do while enabled.
Definition: SamplePlayerNode.cpp:139
void setLoopEnabled(bool b=true)
Sets whether playing continues from beginning after the end is reached (default = false) ...
Definition: SamplePlayerNode.h:69
void readImpl()
Definition: SamplePlayerNode.cpp:404
BufferPlayerNode(const Format &format=Format())
Constructs a BufferPlayerNode without a buffer, with the assumption one will be set later...
Definition: SamplePlayerNode.cpp:108
void loadBuffer(const SourceFileRef &sourceFile)
Loads and stores a reference to a Buffer created from the entire contents of sourceFile.
Definition: SamplePlayerNode.cpp:162
std::mutex mAsyncReadMutex
Definition: SamplePlayerNode.h:167
size_t getNumFrames() const
Returns the total number of frames this SamplePlayerNode will play from beginning to end...
Definition: SamplePlayerNode.h:64
bool isReadAsync() const
Returns whether reading occurs asynchronously (default is false). If true, file reading is done from ...
Definition: SamplePlayerNode.h:136
void setLoopEnd(size_t positionFrames)
Sets the end loop marker in frames (default = getNumFrames(), max = getNumFrames()).
Definition: SamplePlayerNode.cpp:61
virtual void seek(size_t readPositionFrames) override
Seek the read position to readPositionFrames.
Definition: SamplePlayerNode.cpp:133
virtual void process(Buffer *buffer) override
Override to perform audio processing on buffer.
Definition: SamplePlayerNode.cpp:173
size_t getLoopEnd() const
Returns the end loop marker in frames.
Definition: SamplePlayerNode.h:85
double getNumSeconds() const
Returns the total number of seconds this SamplePlayerNode will play from beginning to end...
Definition: SamplePlayerNode.cpp:99
GLuint buffer
Definition: GLee.h:2065
uint64_t getLastUnderrun()
Returns the frame of the last buffer underrun or 0 if none since the last time this method was called...
Definition: SamplePlayerNode.cpp:335
virtual void stop()
Stops playing the sample, returns the read position to the beginning and disables processing...
Definition: SamplePlayerNode.cpp:50
double getReadPositionTime() const
Returns the current read position in seconds.
Definition: SamplePlayerNode.cpp:84
virtual void stop() override
Stops playing the sample, returns the read position to the beginning and disables processing...
Definition: SamplePlayerNode.cpp:278
virtual void seek(size_t readPositionFrames) override
Seek the read position to readPositionFrames.
Definition: SamplePlayerNode.cpp:293
void setSourceFile(const SourceFileRef &sourceFile)
Definition: SamplePlayerNode.cpp:307
std::unique_ptr< std::thread > mReadThread
Definition: SamplePlayerNode.h:166
GLboolean GLboolean GLboolean b
Definition: GLee.h:2964
virtual ~BufferPlayerNode()
Definition: SamplePlayerNode.h:105
void enableProcessing() override
Callled when this Node should enable processing. Initiated from Node::enable().
Definition: SamplePlayerNode.cpp:264
size_t getLoopBegin() const
Returns the begin loop marker in frames.
Definition: SamplePlayerNode.h:81
void initialize() override
Called before audio buffers need to be used. There is always a valid Context at this point...
Definition: SamplePlayerNode.cpp:232
std::atomic< uint64_t > mLastOverrun
Definition: SamplePlayerNode.h:164
bool mIsReadAsync
Definition: SamplePlayerNode.h:169
const BufferRef & getBuffer() const
returns a shared_ptr to the current Buffer.
Definition: SamplePlayerNode.h:114
void disableProcessing() override
Callled when this Node should disable processing. Initiated from Node::disable(). ...
Definition: SamplePlayerNode.cpp:274
Buffer-based SamplePlayerNode, where all samples are loaded into memory before playback.
Definition: SamplePlayerNode.h:98
size_t mRingBufferPaddingFactor
Definition: SamplePlayerNode.h:163
std::atomic< size_t > mLoopEnd
Definition: SamplePlayerNode.h:93
double getLoopEndTime() const
Returns the end loop marker in seconds.
Definition: SamplePlayerNode.cpp:94
virtual void start()
Starts playing the sample from the beginning.
Definition: SamplePlayerNode.cpp:44
virtual ~SamplePlayerNode()
Definition: SamplePlayerNode.h:46
GLenum GLsizei GLenum format
Definition: GLee.h:969
void setLoopBeginTime(double positionSeconds)
Sets the begin loop marker in seconds (default = 0, max = getNumSeconds()).
Definition: SamplePlayerNode.cpp:74
SourceFileRef mSourceFile
Definition: SamplePlayerNode.h:162
std::atomic< uint64_t > mLastUnderrun
Definition: SamplePlayerNode.h:164
FilePlayerNode(const Format &format=Format())
Constructs a FilePlayerNode with optional format.
Definition: SamplePlayerNode.cpp:207
std::shared_ptr< class SamplePlayerNode > SamplePlayerNodeRef
Definition: SamplePlayerNode.h:36
size_t mNumFrames
Definition: SamplePlayerNode.h:92
std::atomic< bool > mLoop
Definition: SamplePlayerNode.h:94
std::atomic< bool > mIsEof
Definition: SamplePlayerNode.h:94
void destroyReadThreadImpl()
Definition: SamplePlayerNode.cpp:442
std::condition_variable mIssueAsyncReadCond
Definition: SamplePlayerNode.h:168
bool isEof() const
Returns whether the SamplePlayerNode has reached EOF (end of file). If true, isEnabled() will also re...
Definition: SamplePlayerNode.h:66
Base Node class for sampled audio playback. Can do operations like seek and loop. ...
Definition: SamplePlayerNode.h:44
void uninitialize() override
Called once the contents of initialize are no longer relevant, i.e. connections have changed...
Definition: SamplePlayerNode.cpp:259
const SourceFileRef & getSourceFile() const
Definition: SamplePlayerNode.h:140
void process(Buffer *buffer) override
Override to perform audio processing on buffer.
Definition: SamplePlayerNode.cpp:349