Skip to content

Commit

Permalink
some adjustments for modern juce projects
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrugalla committed Jan 6, 2023
1 parent f12a000 commit 49e7382
Show file tree
Hide file tree
Showing 21 changed files with 114 additions and 93 deletions.
4 changes: 3 additions & 1 deletion Project.jucer
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
pluginDesc="Outputs a MIDI-triggered ADSR modulator as audio signal"
pluginManufacturer="Mrugalla" pluginManufacturerCode="Mrug" pluginCode="ID12"
pluginVSTNumMidiInputs="1" pluginVST3Category="Fx,Generator,Modulation,Tools"
cppLanguageStandard="20" pluginName="ADSR" defines="PPDEditorWidth=946
PPDEditorHeight=574

PPDHasEditor=true
PPDHasPatchBrowser=true

PPDHasSidechain=false

PPDHasGainIn=false
PPDHasUnityGain=false
PPDHasGainOut=true
PPDHasHQ=false
PPDHasStereoConfig=false
PPDHasPolarity=false
PPDHasLookahead=true
PPDHasDelta=false
PPDHasClipper=false

PPDFPSKnobs=40
PPDFPSMeters=40
PPDFPSTextEditor=3

PPDMetersUseRMS=true

PPDGainInDecibels=true
PPD_GainIn_Min=-12
PPD_GainIn_Max=12
PPD_GainOut_Min=-12
PPD_GainOut_Max=12
PPD_UnityGainDefault=true

PPD_MixOrGainDry=0
PPD_MIDINumVoices=2
PPDHasTuningEditor=false
PPD_MaxXen=128"
cppLanguageStandard="20" pluginName="ADSR" defines="PPDEditorWidth=946
PPDEditorHeight=574

PPDHasEditor=false
PPDHasPatchBrowser=true

PPDHasSidechain=false

PPDHasGainIn=false
PPDHasUnityGain=false
PPDHasGainOut=true
PPDHasHQ=false
PPDHasStereoConfig=false
PPDHasPolarity=false
PPDHasLookahead=true
PPDHasDelta=false
PPDHasClipper=false

PPDFPSKnobs=40
PPDFPSMeters=40
PPDFPSTextEditor=3

PPDMetersUseRMS=true

PPDGainInDecibels=true
PPD_GainIn_Min=-12
PPD_GainIn_Max=12
PPD_GainOut_Min=-12
PPD_GainOut_Max=12
PPD_UnityGainDefault=true

PPD_MixOrGainDry=0
PPD_MIDINumVoices=2
PPDHasTuningEditor=false
PPD_MaxXen=128"
maxBinaryFileSize="20971520" pluginAAXCategory="2048,32" pluginVSTCategory="kPlugCategGenerator">
<MAINGROUP id="c82PPq" name="ADSR">
<GROUP id="{329F0704-CF49-5A90-357A-72806BBA6C7A}" name="Source">
Expand Down Expand Up @@ -229,6 +229,8 @@
<CONFIGURATION isDebug="1" name="Debug" enablePluginBinaryCopyStep="1"/>
<CONFIGURATION isDebug="0" name="Release" enablePluginBinaryCopyStep="1" useRuntimeLibDLL="0"
winArchitecture="x64"/>
<CONFIGURATION isDebug="1" name="ReleaseWithDebugInfo" enablePluginBinaryCopyStep="1"
useRuntimeLibDLL="0" winArchitecture="x64"/>
</CONFIGURATIONS>
<MODULEPATHS>
<MODULEPATH id="juce_audio_basics" path="../../JUCE/modules"/>
Expand Down
21 changes: 13 additions & 8 deletions Source/Processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,10 @@ namespace audio
shallForcePrepare = true;
#endif

if (shallForcePrepare)
forcePrepareToPlay();
if (!shallForcePrepare)
return;

forcePrepareToPlay();
}

void ProcessorBackEnd::processBlockBypassed(AudioBuffer& buffer, juce::MidiBuffer&)
Expand Down Expand Up @@ -279,6 +281,7 @@ namespace audio

void Processor::processBlock(AudioBuffer& buffer, MIDIBuffer& midi)
{
///*
const ScopedNoDenormals noDenormals;

macroProcessor();
Expand Down Expand Up @@ -309,7 +312,8 @@ namespace audio
const auto _playHead = getPlayHead();
const auto _playHeadPos = _playHead->getPosition();
const bool playHeadValid = _playHeadPos.hasValue();
if (playHeadValid)
if (playHeadValid && _playHeadPos->getBpm() && _playHeadPos->getPpqPosition()
&& _playHeadPos->getIsPlaying() && _playHeadPos->getTimeInSamples())
{
playHeadPos.bpm = *_playHeadPos->getBpm();
playHeadPos.ppqPosition = *_playHeadPos->getPpqPosition();
Expand Down Expand Up @@ -376,7 +380,6 @@ namespace audio
auto resampledBuf = &buffer;
#endif
auto resampledMainBuf = mainBus->getBusBuffer(*resampledBuf);

#if PPDHasSidechain
if (wrapperType != wrapperType_Standalone)
{
Expand Down Expand Up @@ -469,6 +472,7 @@ namespace audio
}
}
#endif
//*/
}

void Processor::processBlockBypassed(AudioBuffer& buffer, juce::MidiBuffer& midi)
Expand All @@ -489,7 +493,7 @@ namespace audio
ProcessorBackEnd::processBlockBypassed(buffer, midi);
}

void Processor::processBlockPreUpscaled(float** samples, int numChannels, int numSamples,
void Processor::processBlockPreUpscaled(float* const* samples, int numChannels, int numSamples,
MIDIBuffer& midi) noexcept
{
if (params[PID::Lookahead]->getValMod() > .5f)
Expand Down Expand Up @@ -534,8 +538,9 @@ namespace audio

oscope(envGenMIDI.data(), numSamples, playHeadPos);

const auto mode = static_cast<int>(std::round(params[PID::EnvGenMode]->getValModDenorm()));
enum { DirectOut, Gain, MIDICC, NumModes };
//const auto mode = static_cast<int>(std::round(params[PID::EnvGenMode]->getValModDenorm()));
const auto mode = static_cast<int>(params[PID::EnvGenMode]->getValModDenorm() + .5f);
enum { DirectOut, Gain, MIDICC, NumModes };
int midiCh, midiCC;
switch (mode)
{
Expand All @@ -561,7 +566,7 @@ namespace audio
}
}

void Processor::processBlockUpsampled(float**, int, int
void Processor::processBlockUpsampled(float* const*, int, int
#if PPDHasSidechain
, float**, int
#endif
Expand Down
4 changes: 2 additions & 2 deletions Source/Processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ namespace audio
void processBlockBypassed(AudioBuffer&, juce::MidiBuffer&) override;

/* samples, numChannels, numSamples, midi, samplesSC, numChannelsSC */
void processBlockPreUpscaled(float**, int numChannels, int numSamples, juce::MidiBuffer& midi) noexcept;
void processBlockPreUpscaled(float* const*, int numChannels, int numSamples, juce::MidiBuffer& midi) noexcept;

/* samples, numChannels, numSamples, samplesSC, numChannelsSC */
void processBlockUpsampled(float**, int, int
void processBlockUpsampled(float* const*, int, int
#if PPDHasSidechain
, float**, int
#endif
Expand Down
2 changes: 1 addition & 1 deletion Source/audio/AutoGain.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace audio
/* sampleRate, blockSize */
using OnPrepare = std::function<void(float, int)>;
/* samples, numChannels, numSamples, valP */
using OnProcess = std::function<void(float**, int, int, float)>;
using OnProcess = std::function<void(float* const*, int, int, float)>;
using OnClear = std::function<void()>;
using Range = makeRange::Range;

Expand Down
6 changes: 3 additions & 3 deletions Source/audio/CombFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ namespace audio
lp.makeFromDecayInHz(1000.f, Fs);
}

void CombFilter::DelayFeedback::operator()(float** samples, int numChannels, int numSamples,
void CombFilter::DelayFeedback::operator()(float* const* samples, int numChannels, int numSamples,
const int* wHead, const float* fbBuf, const float* dampBuf,
const float** readHead) noexcept
const float* const* readHead) noexcept
{
auto ringBuf = ringBuffer.getArrayOfWritePointers();

Expand Down Expand Up @@ -88,7 +88,7 @@ namespace audio
retuneP.prepare(sampleRate, blockSize, 10.f);
}

void CombFilter::operator()(float** samples, int numChannels, int numSamples,
void CombFilter::operator()(float* const* samples, int numChannels, int numSamples,
float _feedback, float _damp, float _retune) noexcept
{
writeHead(numSamples);
Expand Down
4 changes: 2 additions & 2 deletions Source/audio/CombFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace audio
void prepare(float, int);

//samples, numChannels, numSamples, wHead, feedbackBuffer[-1,1], dampBuf, readHead
void operator()(float**, int, int, const int*, const float*, const float*, const float**) noexcept;
void operator()(float* const*, int, int, const int*, const float*, const float*, const float* const*) noexcept;

protected:
AudioBuffer ringBuffer;
Expand All @@ -37,7 +37,7 @@ namespace audio
void prepare(float, int);

/* samples, numChannels, numSamples, feedback ]-1,1[, damp ]0, 22050[hz, retune [-n,n]semi */
void operator()(float**, int, int, float, float, float) noexcept;
void operator()(float* const*, int, int, float, float, float) noexcept;

protected:
MIDIVoices& midiVoices;
Expand Down
8 changes: 4 additions & 4 deletions Source/audio/DryWetMix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace audio
buffers.setSize(NumBufs, blockSize, false, true, false);
}

void DryWetMix::saveDry(float** samples, int numChannels, int numSamples,
void DryWetMix::saveDry(float* const* samples, int numChannels, int numSamples,
#if PPDHasGainIn
float gainInP,
#if PPDHasUnityGain
Expand Down Expand Up @@ -89,7 +89,7 @@ namespace audio
#endif
}

void DryWetMix::processBypass(float** samples, int numChannels, int numSamples) noexcept
void DryWetMix::processBypass(float* const* samples, int numChannels, int numSamples) noexcept
{
latencyCompensation
(
Expand All @@ -109,7 +109,7 @@ namespace audio
}

#if PPDHasGainOut
void DryWetMix::processOutGain(float** samples, int numChannels, int numSamples) const noexcept
void DryWetMix::processOutGain(float* const* samples, int numChannels, int numSamples) const noexcept
{
auto bufs = buffers.getArrayOfReadPointers();
const auto gainBuf = bufs[GainOut];
Expand All @@ -119,7 +119,7 @@ namespace audio
}
#endif

void DryWetMix::processMix(float** samples, int numChannels, int numSamples
void DryWetMix::processMix(float* const* samples, int numChannels, int numSamples
#if PPDHasDelta
, bool deltaP
#endif
Expand Down
8 changes: 4 additions & 4 deletions Source/audio/DryWetMix.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace audio
/* samples, numChannels, numSamples, gainInP, unityGainP, mixP, gainOutP, polarityP */
void saveDry
(
float**, int, int,
float* const*, int, int,
#if PPDHasGainIn
float,
#if PPDHasUnityGain
Expand All @@ -44,15 +44,15 @@ namespace audio
) noexcept;

/* samples, numChannels, numSamples */
void processBypass(float**, int, int) noexcept;
void processBypass(float* const*, int, int) noexcept;

#if PPDHasGainOut
/* samples, numChannels, numSamples */
void processOutGain(float**, int, int) const noexcept;
void processOutGain(float* const*, int, int) const noexcept;
#endif

/* samples, numChannels, numSamples, delta */
void processMix(float**, int, int
void processMix(float* const*, int, int
#if PPDHasDelta
, bool
#endif
Expand Down
2 changes: 1 addition & 1 deletion Source/audio/EnvelopeGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ namespace audio
public:
static float getSkewed(float x, float bias) noexcept
{
const auto b2 = 2.f * bias;
const auto b2 = bias + bias;
const auto bM = 1.f - bias;
const auto xy = bM - x + b2 * x;
if (xy == 0.f)
Expand Down
4 changes: 2 additions & 2 deletions Source/audio/LatencyCompensation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace audio
}
}

void LatencyCompensation::operator()(float** dry, float** inputSamples, int numChannels, int numSamples) noexcept
void LatencyCompensation::operator()(float* const* dry, float* const* inputSamples, int numChannels, int numSamples) noexcept
{
if (latency != 0)
{
Expand Down Expand Up @@ -61,7 +61,7 @@ namespace audio
SIMD::copy(dry[ch], inputSamples[ch], numSamples);
}

void LatencyCompensation::operator()(float** samples, int numChannels, int numSamples) noexcept
void LatencyCompensation::operator()(float* const* samples, int numChannels, int numSamples) noexcept
{
if (latency != 0)
{
Expand Down
4 changes: 2 additions & 2 deletions Source/audio/LatencyCompensation.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ namespace audio
void prepare(int, int);

/* dry, inputSamples, numChannels, numSamples */
void operator()(float**, float**, int, int) noexcept;
void operator()(float* const*, float* const*, int, int) noexcept;

/* samples, numChannels, numSamples */
void operator()(float**, int, int) noexcept;
void operator()(float* const*, int, int) noexcept;

protected:
AudioBuffer ring;
Expand Down
16 changes: 8 additions & 8 deletions Source/audio/Manta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace audio
filta()
{}

void Manta::Filter::operator()(float** laneBuf, float** samples, int numChannels, int numSamples,
void Manta::Filter::operator()(float* const* laneBuf, float* const* samples, int numChannels, int numSamples,
float* fcBuf, float* resoBuf, int stage) noexcept
{
{
Expand Down Expand Up @@ -55,7 +55,7 @@ namespace audio
ringBuffer.setSize(2, size, false, true, false);
}

void Manta::DelayFeedback::operator()(float** samples, int numChannels, int numSamples, const int* wHead, const float* rHead,
void Manta::DelayFeedback::operator()(float* const* samples, int numChannels, int numSamples, const int* wHead, const float* rHead,
const float* feedback) noexcept
{
auto ringBuffr = ringBuffer.getArrayOfWritePointers();
Expand Down Expand Up @@ -101,7 +101,7 @@ namespace audio
oscBuffer.resize(blockSize, 0.f);
}

void Manta::RingMod::operator()(float** samples, int numChannels, int numSamples,
void Manta::RingMod::operator()(float* const* samples, int numChannels, int numSamples,
float* _rmDepth, float* _freqHz) noexcept
{
for (auto s = 0; s < numSamples; ++s)
Expand Down Expand Up @@ -173,7 +173,7 @@ namespace audio
delaySizeF = static_cast<float>(delaySize);
}

void Manta::Lane::operator()(float** samples, int numChannels, int numSamples,
void Manta::Lane::operator()(float* const* samples, int numChannels, int numSamples,
bool enabled, float _pitch, float _resonance, int _slope, float _drive, float _feedback,
float _oct, float _semi, float _rmOct, float _rmSemi, float _rmDepth, float _gain,
const int* wHead, const XenManager& xen) noexcept
Expand Down Expand Up @@ -234,7 +234,7 @@ namespace audio
ringMod.waveTable.loadPatch(state, "manta/lane" + String(i));
}

void Manta::Lane::addTo(float** samples, int numChannels, int numSamples) noexcept
void Manta::Lane::addTo(float* const* samples, int numChannels, int numSamples) noexcept
{
auto lane = laneBuffer.getArrayOfReadPointers();

Expand Down Expand Up @@ -264,7 +264,7 @@ namespace audio
return x + d * (w - x);
}

void Manta::Lane::distort(float** samples, int numChannels, int numSamples, const float* driveBuf) noexcept
void Manta::Lane::distort(float* const* samples, int numChannels, int numSamples, const float* driveBuf) noexcept
{
for (auto ch = 0; ch < numChannels; ++ch)
{
Expand All @@ -275,7 +275,7 @@ namespace audio
}
}

void Manta::Lane::applyGain(float** samples, int numChannels, int numSamples, const float* gainBuf) noexcept
void Manta::Lane::applyGain(float* const* samples, int numChannels, int numSamples, const float* gainBuf) noexcept
{
for (auto ch = 0; ch < numChannels; ++ch)
SIMD::multiply(samples[ch], gainBuf, numSamples);
Expand All @@ -302,7 +302,7 @@ namespace audio
writeHead.prepare(blockSize, delaySize);
}

void Manta::operator()(float** samples, int numChannels, int numSamples,
void Manta::operator()(float* const* samples, int numChannels, int numSamples,
bool l1Enabled, bool l1Snap, float l1Pitch, float l1Resonance, int l1Slope, float l1Drive, float l1Feedback, float l1Oct, float l1Semi, float l1RMOct, float l1RMSemi, float l1RMDepth, float l1Gain,
bool l2Enabled, bool l2Snap, float l2Pitch, float l2Resonance, int l2Slope, float l2Drive, float l2Feedback, float l2Oct, float l2Semi, float l2RMOct, float l2RMSemi, float l2RMDepth, float l2Gain,
bool l3Enabled, bool l3Snap, float l3Pitch, float l3Resonance, int l3Slope, float l3Drive, float l3Feedback, float l3Oct, float l3Semi, float l3RMOct, float l3RMSemi, float l3RMDepth, float l3Gain) noexcept
Expand Down
16 changes: 8 additions & 8 deletions Source/audio/Manta.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace audio
Filter();

/* laneBuf, samples, numChannels, numSamples, fcBuf, resoBuf, stage */
void operator()(float**, float**, int, int,
void operator()(float* const*, float* const*, int, int,
float*, float*, int) noexcept;

protected:
Expand All @@ -40,7 +40,7 @@ namespace audio
void prepare(int);

/* samples, numChannels, numSamples, wHead, rHead, feedback */
void operator()(float**, int, int, const int*, const float*, const float*) noexcept;
void operator()(float* const*, int, int, const int*, const float*, const float*) noexcept;

AudioBuffer ringBuffer;
int size;
Expand All @@ -58,7 +58,7 @@ namespace audio
void prepare(float, int);

/* samples, numChannels, numSamples, rmDepth, freqHz */
void operator()(float**, int, int, float*, float*) noexcept;
void operator()(float* const*, int, int, float*, float*) noexcept;

WT waveTable;
protected:
Expand All @@ -75,7 +75,7 @@ namespace audio

/* samples, numChannels, numSamples, enabled, pitch, resonance, slope, drive, feedback,
oct, semi, rmOct, rmSemi, rmDepth, gain, wHead, xen */
void operator()(float**, int, int, bool, float, float, int, float, float,
void operator()(float* const*, int, int, bool, float, float, int, float, float,
float, float, float, float, float, float, const int*, const XenManager&) noexcept;

/* state, laneIndex */
Expand All @@ -85,7 +85,7 @@ namespace audio
void loadPatch(sta::State&, int);

/* samples, numChannels, numSamples */
void addTo(float**, int, int) noexcept;
void addTo(float* const*, int, int) noexcept;

RingMod ringMod;
protected:
Expand All @@ -103,10 +103,10 @@ namespace audio
float distort(float, float) const noexcept;

/* samples, numChannels, numSamples, driveBuf */
void distort(float**, int, int, const float*) noexcept;
void distort(float* const*, int, int, const float*) noexcept;

/* samples, numChannels, numSamples, gainBuf */
void applyGain(float**, int, int, const float*) noexcept;
void applyGain(float* const*, int, int, const float*) noexcept;
};

public:
Expand All @@ -120,7 +120,7 @@ namespace audio
* l2Enabled [0, 1], l2Snap, l2Pitch [12, N]note, l2Resonance [1, N]q, l2Slope [1, 4]db/oct, l2Drive [0, 1]%, l2Feedback [0, 1]%, l2Oct[-3,3], l2Semi[-12,12], l2RMOct[-3,3], l2RMSemi[-12,12], l2RMDepth[0,1], l2Gain [-60, 60]db
* l3Enabled [0, 1], l3Snap, l3Pitch [12, N]note, l3Resonance [1, N]q, l3Slope [1, 4]db/oct, l3Drive [0, 1]%, l3Feedback [0, 1]%, l3Oct[-3,3], l3Semi[-12,12], l3RMOct[-3,3], l3RMSemi[-12,12], l3RMDepth[0,1], l3Gain [-60, 60]db
*/
void operator()(float**, int, int,
void operator()(float* const*, int, int,
bool, bool, float, float, int, float, float, float, float, float, float, float, float,
bool, bool, float, float, int, float, float, float, float, float, float, float, float,
bool, bool, float, float, int, float, float, float, float, float, float, float, float) noexcept;
Expand Down
Loading

0 comments on commit 49e7382

Please sign in to comment.