tracktion-engine 3.0-10-g034fdde4aa5
Tracktion Engine — High level data model for audio applications

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_BufferedAudioReader.h
Go to the documentation of this file.
1 /*
2 ,--. ,--. ,--. ,--.
3 ,-' '-.,--.--.,--,--.,---.| |,-.,-' '-.`--' ,---. ,--,--, Copyright 2024
4 '-. .-'| .--' ,-. | .--'| /'-. .-',--.| .-. || \ Tracktion Software
5 | | | | \ '-' \ `--.| \ \ | | | |' '-' '| || | Corporation
6 `---' `--' `--`--'`---'`--'`--' `---' `--' `---' `--''--' www.tracktion.com
7
8 Tracktion Engine uses a GPL/commercial licence - see LICENCE.md for details.
9*/
10
11namespace tracktion { inline namespace engine
12{
13
14//==============================================================================
15//==============================================================================
18{
19public:
21
23 ~BufferedAudioReader() override;
24
26 float getProportionComplete() const;
27
29 bool readSamples (int* const* destSamples, int numDestChannels, int startOffsetInDestBuffer,
30 juce::int64 startSampleInFile, int numSamples) override;
31
33 int useTimeSlice() override;
34
35private:
38
39 choc::buffer::ChannelArrayBuffer<float> data;
41 const choc::buffer::FrameCount sourceLength { static_cast<choc::buffer::FrameCount> (source->lengthInSamples) };
42
43 static constexpr choc::buffer::FrameCount chunkSize = 65'536;
44
45 bool readNextChunk();
46 bool readIntoBuffer (choc::buffer::FrameRange);
47};
48
50{
51public:
53 : source (std::move (s))
54 {
55 assert (source);
56
57 sampleRate = source->sampleRate;
58 bitsPerSample = source->bitsPerSample;
59 lengthInSamples = source->lengthInSamples;
60 numChannels = source->numChannels;
61 usesFloatingPointData = source->usesFloatingPointData;
62 metadataValues = source->metadataValues;
63 }
64
66 void setReadTimeout (int) override
67 {}
68
70 bool readSamples (int* const* destSamples, int numDestChannels, int startOffsetInDestBuffer,
71 juce::int64 startSampleInFile, int numSamples) override
72 {
73 return source->readSamples (destSamples, numDestChannels, startOffsetInDestBuffer,
74 startSampleInFile, numSamples);
75 }
76
77private:
79};
80
81//==============================================================================
82//==============================================================================
84{
85public:
87
89
90private:
91 Engine& engine;
92 juce::TimeSliceThread readThread { "Audio file decompressing" };
94 LambdaTimer timer { [this] { cleanUp(); } };
95
96 void cleanUp();
98};
99
100}} // namespace tracktion { inline namespace engine
assert
StringPairArray metadataValues
unsigned int bitsPerSample
unsigned int numChannels
float getProportionComplete() const
Returns the proportion of the source that has been cached.
void setReadTimeout(int) override
Subclassed must override this to set the timeout.
The Engine is the central class for all tracktion sessions.
long long int64