Skip to content

Commit

Permalink
Clean up processBlock().
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesStubbsEng committed Jun 2, 2023
1 parent 7c7f546 commit e613c11
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
16 changes: 6 additions & 10 deletions Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ void TS808UltraAudioProcessor::prepareToPlay (double sampleRate, int samplesPerB
outputGain.prepare(spec);

oversampling.initProcessing (samplesPerBlock);
parallelBuffer.setSize(spec.numChannels, spec.maximumBlockSize);

for (int ch = 0; ch < 2; ++ch)
{
Expand Down Expand Up @@ -190,8 +191,7 @@ void TS808UltraAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer, j
inputGain.process(context);

// copy original dry signal into a buffer
AudioBuffer<float> parallelBuffer;
parallelBuffer.makeCopyOf(buffer);
parallelBuffer.makeCopyOf(buffer, true);
dsp::AudioBlock<float> parallelBlock(parallelBuffer);
auto parallelContext = juce::dsp::ProcessContextReplacing<float>(parallelBlock);

Expand All @@ -208,19 +208,15 @@ void TS808UltraAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer, j


//--------start of TS808 processing------------



auto osBlock = oversampling.processSamplesUp (block);

float* ptrArray[] = {osBlock.getChannelPointer (0), osBlock.getChannelPointer (1)};
AudioBuffer<float> osBuffer (ptrArray, 2, static_cast<int> (osBlock.getNumSamples()));

for (int ch = 0; ch < osBuffer.getNumChannels(); ++ch)
for (int ch = 0; ch < osBlock.getNumChannels(); ++ch)
{
clippingStage[ch].setDrive (*driveParameter);
auto* x = osBuffer.getWritePointer (ch);
auto* x = osBlock.getChannelPointer(ch);

for (int n = 0; n < osBuffer.getNumSamples(); ++n)
for (int n = 0; n < osBlock.getNumSamples(); ++n)
x[n] = clippingStage[ch].processSample (x[n]);
}

Expand Down
2 changes: 2 additions & 0 deletions Source/PluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class TS808UltraAudioProcessor : public juce::AudioProcessor

dsp::Gain<float> inputGain;
dsp::Gain<float> outputGain;

AudioBuffer<float> parallelBuffer;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TS808UltraAudioProcessor)
};
2 changes: 1 addition & 1 deletion TS-808-Ultra.jucer
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<JUCERPROJECT id="DrALJH" name="TS-808-Ultra" projectType="audioplug" useAppConfig="0"
addUsingNamespaceToJuceHeader="1" jucerFormatVersion="1" companyName="JamesStubbsEng"
cppLanguageStandard="17">
cppLanguageStandard="17" displaySplashScreen="1">
<MAINGROUP id="W2mLIt" name="TS-808-Ultra">
<GROUP id="{48C82606-B5CD-EABF-3AB3-AAD2A587A3AA}" name="External">
<GROUP id="{6F0C429A-E614-C409-E219-9F3FD672B817}" name="SimpleComp">
Expand Down

0 comments on commit e613c11

Please sign in to comment.