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 &) | |
AudiopointerList & | operator= (const AudiopointerList &) |
Private Attributes | |
pointerListInternals * | internals |
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.
Superpowered::AudiopointerList::AudiopointerList | ( | unsigned int | bytesPerFrame, |
unsigned int | initialNumElements | ||
) |
Creates an audio buffer list.
bytesPerFrame | Frame size. For example: 4 for 16-bit stereo, 8 for 32-bit stereo audio. |
initialNumElements | Each list item uses 52 bytes memory. This number sets the initial memory usage of this list. |
Superpowered::AudiopointerList::~AudiopointerList | ( | ) |
|
private |
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.
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.
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.
void Superpowered::AudiopointerList::forwardToLastSliceBuffer | ( | ) |
Jumps the enumerator to the last buffer.
Safe to use in a real-time thread.
int Superpowered::AudiopointerList::getLengthFrames | ( | ) |
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.
int64_t Superpowered::AudiopointerList::getPositionFrames | ( | ) |
Returns the start position in an audio file or stream.
Safe to use in a real-time thread.
int64_t Superpowered::AudiopointerList::getSlicePositionFrames | ( | ) |
Returns the slice start position in an audio file or stream.
Safe to use in a real-time thread.
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.
bool Superpowered::AudiopointerList::makeSlice | ( | int | fromFrame, |
int | lengthFrames | ||
) |
Creates a "virtual slice" from this list.
Safe to use in a real-time thread.
fromFrame | The slice will start from this frame. |
lengthFrames | The slice will contain this number of frames. |
void* Superpowered::AudiopointerList::nextSliceItem | ( | int * | lengthFrames, |
float * | framesUsed = 0 , |
||
int | stereoPairIndex = 0 |
||
) |
lengthFrames | Returns the number of frames in audio. |
framesUsed | Returns 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. |
stereoPairIndex | Index of AudiopointerlistElement.buffers. |
|
private |
void* Superpowered::AudiopointerList::prevSliceItem | ( | int * | lengthFrames, |
float * | framesUsed = 0 , |
||
int | stereoPairIndex = 0 |
||
) |
lengthFrames | Returns the number of frames in audio. |
framesUsed | Returns 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. |
stereoPairIndex | Index of AudiopointerlistElement.buffers. |
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.
numFrames | The number of frames to remove. |
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.
numFrames | The number of frames to remove. |
void Superpowered::AudiopointerList::rewindSlice | ( | ) |
Returns the slice enumerator to the first buffer.
Safe to use in a real-time thread.
|
private |