Audacity 3.2.0
WideSampleSource.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file WideSampleSource.h
6 @brief Adapter of WideSampleSequence to the interface AudioGraph::Source
7
8 Dominic Mazzoni
9 Vaughan Johnson
10
11 Paul Licameli split from PerTrackEffect.h
12
13**********************************************************************/
14#ifndef __AUDACITY_WIDE_SAMPLE_SOURCE__
15#define __AUDACITY_WIDE_SAMPLE_SOURCE__
16
17#include "AudioGraphSource.h" // to inherit
18#include "SampleCount.h"
19#include <functional>
20
22
24class MIXER_API WideSampleSource final : public AudioGraph::Source {
25public:
27 using Poller = std::function<bool(sampleCount blockSize)>;
28
33 WideSampleSource(const WideSampleSequence &sequence, size_t nChannels,
34 sampleCount start, sampleCount len, Poller pollUser);
36
39 bool AcceptsBuffers(const Buffers &buffers) const override;
40
42 bool AcceptsBlockSize(size_t blockSize) const override;
43
44 std::optional<size_t> Acquire(Buffers &data, size_t bound) override;
45 sampleCount Remaining() const override;
47 bool Release() override;
48private:
50 const size_t mnChannels;
52
54 sampleCount mOutputRemaining{};
55 size_t mLastProduced{};
56 size_t mFetched{};
57 bool mInitialized{ false };
58};
59#endif
Accumulates (non-interleaved) data during effect processing.
Upstream producer of sample streams, taking Buffers as external context.
virtual sampleCount Remaining() const =0
Result includes any amount Acquired and not yet Released.
virtual bool AcceptsBlockSize(size_t blockSize) const =0
virtual bool AcceptsBuffers(const Buffers &buffers) const =0
virtual std::optional< size_t > Acquire(Buffers &data, size_t bound)=0
Occupy vacant space in Buffers with some data.
virtual bool Release()=0
Caller is done examining last Acquire()d positions.
Adapts WideSampleSequence to the interface AudioGraph::Source.
const WideSampleSequence & mSequence
~WideSampleSource() override
const Poller mPollUser
std::function< bool(sampleCount blockSize)> Poller
Type of function returning false if user cancels progress.
const size_t mnChannels
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19