12namespace tracktion {
inline namespace engine
16 : input (
std::move (inputNode)), channelMap (
std::move (channelMapToUse))
20 for (
auto& chan : channelMap)
23 maxNumChannels =
std::max (maxNumChannels,
27 for (
size_t chan = 0; chan < 2; ++chan)
28 lastGain[chan] = dbToGain (
std::get<2> (channelMap[chan])->getCurrentValue());
34 return { input.get() };
39 auto props = input->getNodeProperties();
40 props.numberOfChannels = (
int) maxNumChannels;
42 props.hasAudio =
true;
49 if (input->numOutputNodes > 1)
52 const auto inputNumChannels = input->getNodeProperties().numberOfChannels;
55 if (info.enableNodeMemorySharing && inputNumChannels >= desiredNumChannels)
57 canUseSourceBuffers =
true;
59 tracktion::graph::AllocateAudioBuffer::no });
65 return input->hasProcessed();
70 if (canUseSourceBuffers)
76 assert ((
int) pc.buffers.audio.getNumChannels() == maxNumChannels);
77 auto inputBuffers = input->getProcessedOutput();
80 pc.buffers.midi.copyFrom (inputBuffers.midi);
85 for (
auto& chan : channelMap)
96 if ((choc::buffer::ChannelCount) srcChan >= inputBuffers.audio.getNumChannels())
99 auto src = inputBuffers.audio.getChannel ((choc::buffer::ChannelCount) srcChan);
100 auto dest = pc.buffers.audio.getChannel ((choc::buffer::ChannelCount) destChan);
101 auto gain = dbToGain (
std::get<2> (chan)->getCurrentValue());
103 copyIfNotAliased (dest, src);
105 if (gain == lastGain[channel])
108 applyGain (dest, gain);
114 smoother.
reset ((
int) dest.getNumFrames());
115 applyGainPerFrame (dest, [&] {
return smoother.
getNextValue(); });
117 lastGain[channel] = gain;
FloatType getNextValue() noexcept
void reset(double sampleRate, double rampLengthInSeconds) noexcept
void setTargetValue(FloatType newValue) noexcept
void process(ProcessContext &) override
Called when the node is to be processed.
std::vector< Node * > getDirectInputNodes() override
Should return all the inputs directly feeding in to this node.
void prepareToPlay(const tracktion::graph::PlaybackInitialisationInfo &) override
Called once before playback begins for each node.
RackInstanceNode(std::unique_ptr< Node >, ChannelMap channelMap)
Creates a RackInstanceNode that maps an input node channel to an output channel and applies a gain pa...
tracktion::graph::NodeProperties getNodeProperties() override
Should return the properties of the node.
void preProcess(choc::buffer::FrameCount, juce::Range< int64_t >) override
Called when the node is to be processed, just before process.
bool isReadyToProcess() override
Should return true when this node is ready to be processed.
void setOptimisations(NodeOptimisations)
This can be called to provide some hints about allocating or playing back a Node to improve efficienc...
void setBufferViewToUse(Node *sourceNode, const choc::buffer::ChannelArrayView< float > &)
This can be called during prepareToPlay to set a BufferView to use which can improve efficiency.
Struct to describe a single iteration of a process call.
Holds some really basic properties of a node.
Passed into Nodes when they are being initialised, to give them useful contextual information that th...