Skip to content

Commit

Permalink
Removed dc and amplitude from Oscillator, as it is redundand with Gain
Browse files Browse the repository at this point in the history
  • Loading branch information
ffAudio committed May 12, 2024
1 parent 7692453 commit 32e5cd6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion modules/foleys_dsp_magic/DSP/foleys_DspProgram.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class DspProgram
MagicDspBuilder& dspBuilder;
MagicProcessorState& magicState;

juce::UndoManager* undoManager = nullptr;
juce::ValueTree dspConfig { "Program" };
juce::UndoManager* undoManager = nullptr;

std::vector<std::unique_ptr<DspNode>> nodes;
std::map<int, DspNode*> nodeLookup;
Expand Down
17 changes: 16 additions & 1 deletion modules/foleys_dsp_magic/Nodes/foleys_Gain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Gain::Gain (DspProgram& program, const juce::ValueTree& config) : DspNode (progr
addAudioInput (TRANS ("Audio In"));
addParameterInput (TRANS ("Gain"));
addParameterInput (TRANS ("DC"));
addParameterInput (TRANS ("Phase"));

addAudioOutput (TRANS ("Audio Out"));
}
Expand All @@ -31,10 +32,24 @@ void Gain::process ([[maybe_unused]] int numSamples)
else
return;

bool phaseSwap = false;
if (auto* phaseParameter = getConnectedOutput (ConnectionType::Parameter, 2))
phaseSwap = phaseParameter->getStaticValue() < 0.5f;

if (auto* gain = getConnectedOutput (ConnectionType::Parameter, 0))
{
gain->multiply (audioOutput->getAudio(), 0.0f, 1.0f);
if (phaseSwap)
gain->multiply (audioOutput->getAudio(), 0.0f, -1.0f);
else
gain->multiply (audioOutput->getAudio(), 0.0f, 1.0f);
}
else if (phaseSwap)
{
audioOutput->getAudio().multiplyBy (-1.0);
}

if (auto* offset = getConnectedOutput (ConnectionType::Parameter, 1))
offset->add (audioOutput->getAudio(), -1.0f, 1.0f);
}


Expand Down
10 changes: 0 additions & 10 deletions modules/foleys_dsp_magic/Nodes/foleys_Oscillator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ Oscillator::Oscillator (DspProgram& program, const juce::ValueTree& config) : Ds

addParameterInput (TRANS ("Signal Type"));
addParameterInput (TRANS ("Frequency"));
addParameterInput (TRANS ("Amplitude"));
addParameterInput (TRANS ("Offset"));

// make sure to repeat the first sample at the end for interpolation
wavetable.resize (wavetablesize + 1, 0);
Expand Down Expand Up @@ -66,8 +64,6 @@ void Oscillator::process (int numSamples)

auto* signalType = getConnectedOutput (ConnectionType::Parameter, 0);
auto* frequency = getConnectedOutput (ConnectionType::Parameter, 1);
auto* amplitude = getConnectedOutput (ConnectionType::Parameter, 2);
auto* dcOffset = getConnectedOutput (ConnectionType::Parameter, 3);

if (signalType)
setWaveType (static_cast<WaveType> (signalType->getStaticValue()));
Expand Down Expand Up @@ -111,12 +107,6 @@ void Oscillator::process (int numSamples)
}
}

if (amplitude)
amplitude->multiply (block, 0.0f, 1.0f);

if (dcOffset)
dcOffset->add (block, -1.0f, 1.0f);

for (size_t ch = 1; ch < block.getNumChannels(); ++ch)
block.getSingleChannelBlock (ch).copyFrom (block.getSingleChannelBlock (0));

Expand Down
6 changes: 3 additions & 3 deletions modules/foleys_dsp_magic/Nodes/foleys_Oscilloscope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Oscilloscope::Oscilloscope (DspProgram& program, const juce::ValueTree& config)
addAudioInput (TRANS ("Audio In"));
addAudioOutput (TRANS ("Audio Out"));

addParameterInput (TRANS ("Parameter Input"));
addParameterInput (TRANS ("Param In"));

auto& state = program.getMagicProcessorState();
scope = state.getObjectWithType<MagicOscilloscope> (getName());
Expand All @@ -26,7 +26,7 @@ void Oscilloscope::prepare (juce::dsp::ProcessSpec spec)
if (!scope)
return;

scope->prepareToPlay (spec.sampleRate, spec.maximumBlockSize);
scope->prepareToPlay (spec.sampleRate, static_cast<int> (spec.maximumBlockSize));
}

void Oscilloscope::process ([[maybe_unused]] int numSamples)
Expand All @@ -50,7 +50,7 @@ void Oscilloscope::process ([[maybe_unused]] int numSamples)
if (audio.getNumSamples() == 0)
return;

float* pointers[audio.getNumChannels()];
float* pointers[64]; // needs to be fixed
for (size_t c = 0; c < audio.getNumChannels(); ++c)
pointers[c] = audio.getChannelPointer (c);

Expand Down

0 comments on commit 32e5cd6

Please sign in to comment.