TracktionEngine
Loading...
Searching...
No Matches
engine::soundtouch::FIFOSampleBuffer Class Reference

Sample buffer working in FIFO (first-in-first-out) principle. More...

#include <tracktion_TempoDetect.h>

Inheritance diagram for engine::soundtouch::FIFOSampleBuffer:

Public Member Functions

 FIFOSampleBuffer (int numChannels=2)
 Constructor.
 ~FIFOSampleBuffer ()
 destructor
virtual SAMPLETYPE * ptrBegin ()
 Returns a pointer to the beginning of the output samples.
SAMPLETYPE * ptrEnd (uint slackCapacity)
 Returns a pointer to the end of the used part of the sample buffer (i.e.
virtual void putSamples (const SAMPLETYPE *samples, uint numSamples)
 Adds 'numSamples' pcs of samples from the 'samples' memory position to the sample buffer.
virtual void putSamples (uint numSamples)
 Adjusts the book-keeping to increase number of samples in the buffer without copying any actual samples.
virtual uint receiveSamples (SAMPLETYPE *output, uint maxSamples)
 Output samples from beginning of the sample buffer.
virtual uint receiveSamples (uint maxSamples)
 Adjusts book-keeping so that given number of samples are removed from beginning of the sample buffer without copying them anywhere.
virtual uint numSamples () const
 Returns number of samples currently available.
void setChannels (int numChannels)
 Sets number of channels, 1 = mono, 2 = stereo.
int getChannels ()
 Get number of channels.
virtual int isEmpty () const
 Returns nonzero if there aren't any samples available for outputting.
virtual void clear ()
 Clears all the samples.
uint adjustAmountOfSamples (uint numSamples)
 allow trimming (downwards) amount of samples in pipeline.
Public Member Functions inherited from engine::soundtouch::FIFOSamplePipe
virtual ~FIFOSamplePipe ()
void moveSamples (FIFOSamplePipe &other)

Additional Inherited Members

Protected Member Functions inherited from engine::soundtouch::FIFOSamplePipe
bool verifyNumberOfChannels (int nChannels) const

Detailed Description

Sample buffer working in FIFO (first-in-first-out) principle.

The class takes care of storage size adjustment and data moving during input/output operations.

Notice that in case of stereo audio, one sample is considered to consist of both channel data.

Constructor & Destructor Documentation

◆ FIFOSampleBuffer()

engine::soundtouch::FIFOSampleBuffer::FIFOSampleBuffer ( int numChannels = 2)

Constructor.

Parameters
numChannelsNumber of channels, 1=mono, 2=stereo. Default is stereo.

◆ ~FIFOSampleBuffer()

engine::soundtouch::FIFOSampleBuffer::~FIFOSampleBuffer ( )

destructor

Member Function Documentation

◆ ptrBegin()

virtual SAMPLETYPE * engine::soundtouch::FIFOSampleBuffer::ptrBegin ( )
virtual

Returns a pointer to the beginning of the output samples.

This function is provided for accessing the output samples directly. Please be careful for not to corrupt the book-keeping!

When using this function to output samples, also remember to 'remove' the output samples from the buffer by calling the 'receiveSamples(numSamples)' function

Implements engine::soundtouch::FIFOSamplePipe.

◆ ptrEnd()

SAMPLETYPE * engine::soundtouch::FIFOSampleBuffer::ptrEnd ( uint slackCapacity)

Returns a pointer to the end of the used part of the sample buffer (i.e.

where the new samples are to be inserted). This function may be used for inserting new samples into the sample buffer directly. Please be careful not corrupt the book-keeping!

When using this function as means for inserting new samples, also remember to increase the sample count afterwards, by calling the 'putSamples(numSamples)' function.

Parameters
slackCapacityHow much free capacity (in samples) there at least should be so that the caller can successfully insert the desired samples to the buffer. If necessary, the function grows the buffer size to comply with this requirement.

◆ putSamples() [1/2]

virtual void engine::soundtouch::FIFOSampleBuffer::putSamples ( const SAMPLETYPE * samples,
uint numSamples )
virtual

Adds 'numSamples' pcs of samples from the 'samples' memory position to the sample buffer.

Parameters
samplesPointer to samples.
numSamplesNumber of samples to insert.

Implements engine::soundtouch::FIFOSamplePipe.

◆ putSamples() [2/2]

virtual void engine::soundtouch::FIFOSampleBuffer::putSamples ( uint numSamples)
virtual

Adjusts the book-keeping to increase number of samples in the buffer without copying any actual samples.

This function is used to update the number of samples in the sample buffer when accessing the buffer directly with 'ptrEnd' function. Please be careful though!

Parameters
numSamplesNumber of samples been inserted.

References numSamples().

◆ receiveSamples() [1/2]

virtual uint engine::soundtouch::FIFOSampleBuffer::receiveSamples ( SAMPLETYPE * output,
uint maxSamples )
virtual

Output samples from beginning of the sample buffer.

Copies requested samples to output buffer and removes them from the sample buffer. If there are less than 'numsample' samples in the buffer, returns all that available.

Returns
Number of samples returned.
Parameters
outputBuffer where to copy output samples.
maxSamplesHow many samples to receive at max.

Implements engine::soundtouch::FIFOSamplePipe.

◆ receiveSamples() [2/2]

virtual uint engine::soundtouch::FIFOSampleBuffer::receiveSamples ( uint maxSamples)
virtual

Adjusts book-keeping so that given number of samples are removed from beginning of the sample buffer without copying them anywhere.

Used to reduce the number of samples in the buffer when accessing the sample buffer directly with 'ptrBegin' function.

Parameters
maxSamplesRemove this many samples from the beginning of pipe.

Implements engine::soundtouch::FIFOSamplePipe.

◆ numSamples()

virtual uint engine::soundtouch::FIFOSampleBuffer::numSamples ( ) const
virtual

Returns number of samples currently available.

Implements engine::soundtouch::FIFOSamplePipe.

Referenced by putSamples().

◆ setChannels()

void engine::soundtouch::FIFOSampleBuffer::setChannels ( int numChannels)

Sets number of channels, 1 = mono, 2 = stereo.

◆ getChannels()

int engine::soundtouch::FIFOSampleBuffer::getChannels ( )

Get number of channels.

◆ isEmpty()

virtual int engine::soundtouch::FIFOSampleBuffer::isEmpty ( ) const
virtual

Returns nonzero if there aren't any samples available for outputting.

Implements engine::soundtouch::FIFOSamplePipe.

◆ clear()

virtual void engine::soundtouch::FIFOSampleBuffer::clear ( )
virtual

Clears all the samples.

Implements engine::soundtouch::FIFOSamplePipe.

◆ adjustAmountOfSamples()

uint engine::soundtouch::FIFOSampleBuffer::adjustAmountOfSamples ( uint numSamples)
virtual

allow trimming (downwards) amount of samples in pipeline.

Returns adjusted amount of samples

Implements engine::soundtouch::FIFOSamplePipe.


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