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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_LevelMeasuringNode.cpp
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
12namespace tracktion { inline namespace engine
13{
14
15LevelMeasuringNode::LevelMeasuringNode (std::unique_ptr<tracktion::graph::Node> inputNode, LevelMeasurer& measurer)
16 : input (std::move (inputNode)), levelMeasurer (measurer)
17{
18 setOptimisations ({ tracktion::graph::ClearBuffers::no,
19 tracktion::graph::AllocateAudioBuffer::no });
20}
21
22void LevelMeasuringNode::process (tracktion::graph::Node::ProcessContext& pc)
23{
24 auto sourceBuffers = input->getProcessedOutput();
25 jassert (pc.buffers.audio.getSize() == sourceBuffers.audio.getSize());
26
27 // Just pass out input on to our output
28 setAudioOutput (input.get(), sourceBuffers.audio);
29
30 // If the source only outputs to this node, we can steal its data
31 if (input->numOutputNodes == 1)
32 pc.buffers.midi.swapWith (sourceBuffers.midi);
33 else
34 pc.buffers.midi.copyFrom (sourceBuffers.midi);
35
36 // Then update the levels
37 if (sourceBuffers.audio.getNumChannels() > 0)
38 {
39 auto buffer = tracktion::graph::toAudioBuffer (sourceBuffers.audio);
40 levelMeasurer.processBuffer (buffer, 0, buffer.getNumSamples());
41 }
42
43 levelMeasurer.processMidi (pc.buffers.midi, nullptr);
44}
45
46}} // namespace tracktion { inline namespace engine
Struct to describe a single iteration of a process call.
#define jassert(expression)
T move(T... args)