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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_SharedLevelMeasuringNode.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
15SharedLevelMeasuringNode::SharedLevelMeasuringNode (SharedLevelMeasurer::Ptr source, std::unique_ptr<Node> inputNode)
16 : levelMeasurer (std::move (source)), input (std::move (inputNode))
17{
18 jassert (levelMeasurer != nullptr);
19
20 setOptimisations ({ tracktion::graph::ClearBuffers::no,
21 tracktion::graph::AllocateAudioBuffer::no });
22}
23
24std::vector<tracktion::graph::Node*> SharedLevelMeasuringNode::getDirectInputNodes()
25{
26 return { input.get() };
27}
28
29tracktion::graph::NodeProperties SharedLevelMeasuringNode::getNodeProperties()
30{
31 return input->getNodeProperties();
32}
33
34void SharedLevelMeasuringNode::prepareToPlay (const tracktion::graph::PlaybackInitialisationInfo& info)
35{
36 sampleRate = info.sampleRate;
37 levelMeasurer->setSize (2, info.blockSize);
38}
39
40bool SharedLevelMeasuringNode::isReadyToProcess()
41{
42 return input->hasProcessed();
43}
44
45void SharedLevelMeasuringNode::prefetchBlock (juce::Range<int64_t> referenceSampleRange)
46{
47 levelMeasurer->startNextBlock (tracktion::graph::sampleToTime (referenceSampleRange.getStart(), sampleRate));
48}
49
50void SharedLevelMeasuringNode::process (ProcessContext& pc)
51{
52 SCOPED_REALTIME_CHECK
53
54 // Pass on input to output
55 auto sourceBuffers = input->getProcessedOutput();
56
57 setAudioOutput (input.get(), sourceBuffers.audio);
58 pc.buffers.midi.copyFrom (sourceBuffers.midi);
59
60 // And pass audio to level measurer
61 auto buffer = tracktion::graph::toAudioBuffer (sourceBuffers.audio);
62 levelMeasurer->addBuffer (buffer, 0, buffer.getNumSamples());
63}
64
65}} // namespace tracktion { inline namespace engine
constexpr ValueType getStart() const noexcept
Struct to describe a single iteration of a process call.
#define jassert(expression)
T move(T... args)
Holds some really basic properties of a node.
Passed into Nodes when they are being initialised, to give them useful contextual information that th...