arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
ChunkedSampleTableStore< T, ChunkSize > Class Template Reference

RAM-backed like RamSampleTableStore, but grows by allocating additional fixed-size chunks instead of reallocating and copying one single growing array. More...

#include <SampleTableStore.h>

Inheritance diagram for ChunkedSampleTableStore< T, ChunkSize >:
SampleTableStore< T >

Public Member Functions

 ~ChunkedSampleTableStore ()
 
void append (T value) override
 Appends one entry - call in file order, once per table entry.
 
void clear () override
 Resets to empty - call once per begin()/track.
 
get (size_t index) override
 Reads back entry 'index' - index must be < size().
 
virtual void setNextEntryOffset (uint64_t fileOffset)
 
virtual void setOnDiskEntrySize (size_t bytes)
 
size_t size () override
 Number of entries appended so far.
 

Protected Attributes

Vector< T * > chunks
 
size_t count = 0
 

Detailed Description

template<typename T, size_t ChunkSize = 4096>
class audio_tools::ChunkedSampleTableStore< T, ChunkSize >

RAM-backed like RamSampleTableStore, but grows by allocating additional fixed-size chunks instead of reallocating and copying one single growing array.

This project's Vector<T>::push_back() (AudioBasic/Collections/Vector.h) allocates exactly the new size on every growth, with no spare capacity

This store sidesteps that by keeping a Vector of chunk pointers rather than a Vector of T directly: growing by one chunk means appending one more pointer (cheap - the pointer vector itself stays tiny, e.g. ~70 pointers for 288K entries at the default chunk size) and allocating a fresh fixed-size block, without ever touching or copying any previously-appended data. Same total memory as RamSampleTableStore, but O(1) amortized append instead of O(N) - the same idea behind this project's DynamicMultiBuffer (AudioTools/Sandbox/DynamicMultiBuffer.h), reimplemented directly here rather than wrapped: that class's public API is a sequential read()/write() cursor, not the indexed get() ChunkedSampleTableStore needs, and as Sandbox-status code it's not something to take a hard dependency on from a container decoder.

Constructor & Destructor Documentation

◆ ~ChunkedSampleTableStore()

template<typename T , size_t ChunkSize = 4096>
~ChunkedSampleTableStore ( )
inline

Member Function Documentation

◆ append()

template<typename T , size_t ChunkSize = 4096>
void append ( value)
inlineoverridevirtual

Appends one entry - call in file order, once per table entry.

Implements SampleTableStore< T >.

◆ clear()

template<typename T , size_t ChunkSize = 4096>
void clear ( )
inlineoverridevirtual

Resets to empty - call once per begin()/track.

Implements SampleTableStore< T >.

◆ get()

template<typename T , size_t ChunkSize = 4096>
T get ( size_t  index)
inlineoverridevirtual

Reads back entry 'index' - index must be < size().

Implements SampleTableStore< T >.

◆ setNextEntryOffset()

template<typename T >
virtual void setNextEntryOffset ( uint64_t  fileOffset)
inlinevirtualinherited

Only meaningful for SourceSeekSampleTableStore: the absolute byte offset (from the start of the original MP4 file) of the entry about to be appended next. Default no-op - other implementations ignore it, so callers can always call this unconditionally before append() without needing to know which implementation is active.

Reimplemented in SourceSeekSampleTableStore< T >.

◆ setOnDiskEntrySize()

template<typename T >
virtual void setOnDiskEntrySize ( size_t  bytes)
inlinevirtualinherited

Only meaningful for SourceSeekSampleTableStore, and only for tables whose on-disk width isn't a fixed sizeof(T) - see its comment. Default no-op.

Reimplemented in SourceSeekSampleTableStore< T >.

◆ size()

template<typename T , size_t ChunkSize = 4096>
size_t size ( )
inlineoverridevirtual

Number of entries appended so far.

Implements SampleTableStore< T >.

Member Data Documentation

◆ chunks

template<typename T , size_t ChunkSize = 4096>
Vector<T*> chunks
protected

◆ count

template<typename T , size_t ChunkSize = 4096>
size_t count = 0
protected

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