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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_NodeRenderContext.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
11#pragma once
12
13namespace tracktion { inline namespace engine
14{
15
16//==============================================================================
21{
22public:
30
33
34 //==============================================================================
38 juce::Result getStatus() const noexcept { return status; }
39
41 bool renderNextBlock (std::atomic<float>& progressToUpdate);
42
43 //==============================================================================
50 std::atomic<float>& progressToUpdate);
51
52private:
53 //==============================================================================
54 struct Ditherers
55 {
56 Ditherers (int num, int bitDepth)
57 {
58 while (ditherers.size() < num)
59 ditherers.add ({});
60
61 for (auto& d : ditherers)
62 d.reset (bitDepth);
63 }
64
65 void apply (juce::AudioBuffer<float>& buffer, int numSamples)
66 {
67 auto numChannels = buffer.getNumChannels();
68
69 for (int i = 0; i < numChannels; ++i)
70 ditherers.getReference (i).process (buffer.getWritePointer (i), numSamples);
71 }
72
73 juce::Array<Ditherer> ditherers;
74 };
75
76 //==============================================================================
77 Renderer::RenderTask& owner;
78 Renderer::Parameters r, originalParams;
79 bool needsToNormaliseAndTrim = false;
80
85
86 int numOutputChans = 0;
88 Plugin::Array plugins;
89 juce::Result status;
90
91 //==============================================================================
92 Ditherers ditherers;
93 MidiMessageArray midiBuffer;
94
95 const float thresholdForStopping { dbToGain (-70.0f) };
96 TimeDuration blockLength;
97 int numPreRenderBlocks = 0;
98 int numLatencySamplesToDrop = 0;
99 int realTimePerBlock = 0;
100
101 double lastTime = 0;
102 static const int sleepCounterMax = 100;
103 int sleepCounter = 0;
104
106 float peak = 0;
107 double rmsTotal = 0;
108 int64_t rmsNumSamps = 0;
109 int precount = 0;
110 TimePosition streamTime;
111
112 int64_t samplesTrimmed = 0;
113 bool hasStartedSavingToFile = 0;
114 int64_t samplesToWrite = 0, numSamplesWrittenToSource = 0;
115
118
119 //==============================================================================
120 enum class WriteResult
121 {
122 succeeded,
123 failed
124 };
125
126 WriteResult writeAudioBlock (choc::buffer::ChannelArrayView<float>);
127};
128
129}} // namespace tracktion { inline namespace engine
Type * getWritePointer(int channelNumber) noexcept
int getNumChannels() const noexcept
Holds the state of an audio render procedure so it can be rendered in blocks.
static juce::String renderMidi(Renderer::RenderTask &, Renderer::Parameters &, std::unique_ptr< tracktion::graph::Node >, std::unique_ptr< tracktion::graph::PlayHead >, std::unique_ptr< tracktion::graph::PlayHeadState >, std::unique_ptr< ProcessState >, std::atomic< float > &progressToUpdate)
Renders the MIDI of an Edit to a sequence.
bool renderNextBlock(std::atomic< float > &progressToUpdate)
Renders the next block of audio.
juce::Result getStatus() const noexcept
Returns the opening status of the render.
Task that actually performs the render operation in blocks.
typedef int64_t