SuperpoweredSDK  v2.0.2
Superpowered Audio SDK
Superpowered::AudiopointerList Class Reference

Manages an audio buffer list. More...

#include "SuperpoweredAudioBuffers.h"

Public Member Functions

 AudiopointerList (unsigned int bytesPerFrame, unsigned int initialNumElements)
 Creates an audio buffer list. More...
 
 ~AudiopointerList ()
 
void append (AudiopointerlistElement *buffer)
 Append a buffer to the end of the list. More...
 
void clear ()
 Remove everything from the list. More...
 
void copyAllBuffersTo (AudiopointerList *anotherList)
 Append all buffers to another buffer list. More...
 
void forwardToLastSliceBuffer ()
 Jumps the enumerator to the last buffer. More...
 
int getLengthFrames ()
 
int64_t getNextPositionFrames ()
 Returns the end position in an audio file or stream, plus 1. More...
 
int64_t getPositionFrames ()
 Returns the start position in an audio file or stream. More...
 
int64_t getSlicePositionFrames ()
 Returns the slice start position in an audio file or stream. More...
 
void insert (AudiopointerlistElement *buffer)
 Insert a buffer before the beginning of the list. More...
 
bool makeSlice (int fromFrame, int lengthFrames)
 Creates a "virtual slice" from this list. More...
 
void * nextSliceItem (int *lengthFrames, float *framesUsed=0, int stereoPairIndex=0)
 
void * prevSliceItem (int *lengthFrames, float *framesUsed=0, int stereoPairIndex=0)
 
void removeFromEnd (int numFrames)
 Remove frames from the end. More...
 
void removeFromStart (int numFrames)
 Remove frames from the beginning. More...
 
void rewindSlice ()
 Returns the slice enumerator to the first buffer. More...
 

Private Member Functions

 AudiopointerList (const AudiopointerList &)
 
AudiopointerListoperator= (const AudiopointerList &)
 

Private Attributes

pointerListInternals * internals
 

Detailed Description

Manages an audio buffer list.

Instead of circular buffers and too many memmove/memcpy, this object maintains an audio buffer "chain". You can append, insert, truncate, slice, extend, etc. this without the expensive memory operations. Check the offline example project on how to use.

Constructor & Destructor Documentation

◆ AudiopointerList() [1/2]

Superpowered::AudiopointerList::AudiopointerList ( unsigned int  bytesPerFrame,
unsigned int  initialNumElements 
)

Creates an audio buffer list.

Parameters
bytesPerFrameFrame size. For example: 4 for 16-bit stereo, 8 for 32-bit stereo audio.
initialNumElementsEach list item uses 52 bytes memory. This number sets the initial memory usage of this list.

◆ ~AudiopointerList()

Superpowered::AudiopointerList::~AudiopointerList ( )

◆ AudiopointerList() [2/2]

Superpowered::AudiopointerList::AudiopointerList ( const AudiopointerList )
private

Member Function Documentation

◆ append()

void Superpowered::AudiopointerList::append ( AudiopointerlistElement buffer)

Append a buffer to the end of the list.

The list will increase the retain count of the buffer by 1, similar to Objective-C. Not safe to use in a real-time thread, because it may use blocking memory operations.

◆ clear()

void Superpowered::AudiopointerList::clear ( )

Remove everything from the list.

It will decrease the retain count of all buffers by 1. Safe to use in a real-time thread.

◆ copyAllBuffersTo()

void Superpowered::AudiopointerList::copyAllBuffersTo ( AudiopointerList anotherList)

Append all buffers to another buffer list.

The anotherList will increase the retain count of all buffers by 1. Not safe to use in a real-time thread, because it may use blocking memory operations.

◆ forwardToLastSliceBuffer()

void Superpowered::AudiopointerList::forwardToLastSliceBuffer ( )

Jumps the enumerator to the last buffer.

Safe to use in a real-time thread.

◆ getLengthFrames()

int Superpowered::AudiopointerList::getLengthFrames ( )
Returns
Returns with the length of audio in the list.

◆ getNextPositionFrames()

int64_t Superpowered::AudiopointerList::getNextPositionFrames ( )

Returns the end position in an audio file or stream, plus 1.

Safe to use in a real-time thread.

◆ getPositionFrames()

int64_t Superpowered::AudiopointerList::getPositionFrames ( )

Returns the start position in an audio file or stream.

Safe to use in a real-time thread.

◆ getSlicePositionFrames()

int64_t Superpowered::AudiopointerList::getSlicePositionFrames ( )

Returns the slice start position in an audio file or stream.

Safe to use in a real-time thread.

◆ insert()

void Superpowered::AudiopointerList::insert ( AudiopointerlistElement buffer)

Insert a buffer before the beginning of the list.

The list will increase the retain count of the buffer by 1, similar to Objective-C. Not safe to use in a real-time thread, because it may use blocking memory operations.

◆ makeSlice()

bool Superpowered::AudiopointerList::makeSlice ( int  fromFrame,
int  lengthFrames 
)

Creates a "virtual slice" from this list.

Safe to use in a real-time thread.

Parameters
fromFrameThe slice will start from this frame.
lengthFramesThe slice will contain this number of frames.

◆ nextSliceItem()

void* Superpowered::AudiopointerList::nextSliceItem ( int *  lengthFrames,
float *  framesUsed = 0,
int  stereoPairIndex = 0 
)
Returns
This the slice's forward enumerator method to go through all buffers in it. Returns a pointer to the audio, or NULL. Safe to use in a real-time thread.
Parameters
lengthFramesReturns the number of frames in audio.
framesUsedReturns the number of original number of frames, creating this chunk of audio. Good for time-stretching for example, to track the movement of the playhead.
stereoPairIndexIndex of AudiopointerlistElement.buffers.

◆ operator=()

AudiopointerList& Superpowered::AudiopointerList::operator= ( const AudiopointerList )
private

◆ prevSliceItem()

void* Superpowered::AudiopointerList::prevSliceItem ( int *  lengthFrames,
float *  framesUsed = 0,
int  stereoPairIndex = 0 
)
Returns
This the slice's backwards (reverse) enumerator method to go through all buffers in it. Returns a pointer to the audio, or NULL. Safe to use in a real-time thread.
Parameters
lengthFramesReturns the number of frames in audio.
framesUsedReturns the number of original number of frames, creating this chunk of audio. Good for time-stretching for example, to track the movement of the playhead.
stereoPairIndexIndex of AudiopointerlistElement.buffers.

◆ removeFromEnd()

void Superpowered::AudiopointerList::removeFromEnd ( int  numFrames)

Remove frames from the end.

If all of a buffer's contents are from this list, it will decrease the buffer's retain count by 1. Safe to use in a real-time thread.

Parameters
numFramesThe number of frames to remove.

◆ removeFromStart()

void Superpowered::AudiopointerList::removeFromStart ( int  numFrames)

Remove frames from the beginning.

If all of a buffer's contents are from this list, it will decrease the buffer's retain count by 1. Safe to use in a real-time thread.

Parameters
numFramesThe number of frames to remove.

◆ rewindSlice()

void Superpowered::AudiopointerList::rewindSlice ( )

Returns the slice enumerator to the first buffer.

Safe to use in a real-time thread.

Member Data Documentation

◆ internals

pointerListInternals* Superpowered::AudiopointerList::internals
private

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