Audacity 3.2.0
AudioGraphBuffers.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file AudioGraphBuffers.h
6 @brief Buffers that mediate data transfer between a Source and a Sink
7
8 Paul Licameli split from PerTrackEffect.h
9
10**********************************************************************/
11
12#ifndef __AUDACITY_AUDIO_GRAPH_BUFFERS__
13#define __AUDACITY_AUDIO_GRAPH_BUFFERS__
14
15#include "SampleFormat.h"
16#include <vector>
17
18namespace AudioGraph {
20
30class AUDIO_GRAPH_API Buffers {
31public:
38 explicit Buffers(size_t blockSize = 512);
48 Buffers(unsigned nChannels, size_t blockSize, size_t nBlocks,
49 size_t padding = 0);
50 unsigned Channels() const { return mBuffers.size(); }
51 size_t BufferSize() const { return mBufferSize; }
52 size_t BlockSize() const { return mBlockSize; }
53 size_t Position() const {
54 return mBuffers.empty() ? 0
55 : Positions()[0]
56 - reinterpret_cast<const float*>(GetReadPosition(0));
57 }
58 size_t Remaining() const { return BufferSize() - Position(); }
59 bool IsRewound() const { return BufferSize() == Remaining(); }
69 void Reinit(unsigned nChannels, size_t blockSize, size_t nBlocks,
70 size_t padding = 0);
72 float *const *Positions() const { return mPositions.data(); }
74
80 void Discard(size_t drop, size_t keep);
82
86 void Advance(size_t count);
88
91 void Rewind();
93
97 size_t Rotate();
98
100
106 constSamplePtr GetReadPosition(unsigned iChannel) const;
107
109
113 float &GetWritePosition(unsigned iChannel);
114
117 void ClearBuffer(unsigned iChannel, size_t n);
118private:
119 std::vector<std::vector<float>> mBuffers;
120 std::vector<float *> mPositions;
121 size_t mBufferSize{ 0 };
122 size_t mBlockSize{ 0 };
123};
124}
125#endif
constexpr int BufferSize
const char * constSamplePtr
Definition: SampleFormat.h:58
Accumulates (non-interleaved) data during effect processing.
size_t BlockSize() const
size_t Position() const
size_t Remaining() const
size_t BufferSize() const
std::vector< std::vector< float > > mBuffers
unsigned Channels() const
float *const * Positions() const
Get array of positions in the buffers.
std::vector< float * > mPositions