Can I ask for something? I made an addition to the AudioProcessorGraph, namely the possibility to add a property called "sendAmount" to a node, which can range from 0 to 1 where 0 is complete bypass and 1 a full insert. For this to work, I made the following changes to the ProcessBufferOp class (everything commented with "CS" is my stuff). I think this is a useful feature to have, any chance to add this to the official JUCE code?
- Code: Select all
class ProcessBufferOp : public AudioGraphRenderingOp
{
public:
ProcessBufferOp (const AudioProcessorGraph::Node::Ptr& node_,
const Array <int>& audioChannelsToUse_,
const int totalChans_,
const int midiBufferToUse_)
: node (node_),
processor (node_->getProcessor()),
audioChannelsToUse (audioChannelsToUse_),
totalChans (jmax (1, totalChans_)),
midiBufferToUse (midiBufferToUse_)
{
channels.calloc ((size_t) totalChans);
while (audioChannelsToUse.size() < totalChans)
audioChannelsToUse.add (0);
//begin CS
sendAmount=node->properties.getWithDefault("sendAmount",1);
delaySamples=node->getProcessor()->getLatencySamples();
DelayChannelOp *DOP=0;
if (delaySamples>0)
{
for (int i=0;i<totalChans;i++)
{
DOP = new DelayChannelOp(0,delaySamples); //buffer will be 1-D, so channel 0, not i
DelayOps.add(DOP);
}
}
//end CS
}
~ProcessBufferOp()
{
DelayOps.clear(true);
}
void perform (AudioSampleBuffer& sharedBufferChans, const OwnedArray <MidiBuffer>& sharedMidiBuffers, const int numSamples)
{
for (int i = totalChans; --i >= 0;)
channels[i] = sharedBufferChans.getSampleData (audioChannelsToUse.getUnchecked (i), 0);
AudioSampleBuffer buffer (channels, totalChans, numSamples);
//begin CS
AudioSampleBuffer bypassBuffer(totalChans, numSamples);
AudioSampleBuffer delayBuffer(1,numSamples);
if (sendAmount<1)
{
bypassBuffer=buffer;
buffer.applyGain(0,numSamples,sendAmount);
bypassBuffer.applyGain(0,numSamples,1-sendAmount);
}
//end CS
processor->processBlock (buffer, *sharedMidiBuffers.getUnchecked (midiBufferToUse));
//begin CS
if (sendAmount<1)
{
if (delaySamples>0)
for (int i=0;i<totalChans;i++)
{
delayBuffer.copyFrom(0,0,bypassBuffer,i,0,numSamples);
DelayOps[i]->perform(delayBuffer,sharedMidiBuffers,numSamples); //CS: MIDI buffers useless
bypassBuffer.copyFrom(i,0,delayBuffer,0,0,numSamples);
}
for (int i=0;i<totalChans;i++) buffer.addFrom(i,0,bypassBuffer,i,0,numSamples);
}
//end CS
}
const AudioProcessorGraph::Node::Ptr node;
AudioProcessor* const processor;
private:
Array <int> audioChannelsToUse;
HeapBlock <float*> channels;
OwnedArray<DelayChannelOp> DelayOps; //CS
float sendAmount; //CS
int delaySamples; //CS
int totalChans;
int midiBufferToUse;
JUCE_DECLARE_NON_COPYABLE (ProcessBufferOp);
};