diff --git a/modules/foleys_dsp_magic/DSP/foleys_DspProgram.h b/modules/foleys_dsp_magic/DSP/foleys_DspProgram.h index f4e71af2..ec291017 100644 --- a/modules/foleys_dsp_magic/DSP/foleys_DspProgram.h +++ b/modules/foleys_dsp_magic/DSP/foleys_DspProgram.h @@ -45,8 +45,8 @@ class DspProgram MagicDspBuilder& dspBuilder; MagicProcessorState& magicState; - juce::UndoManager* undoManager = nullptr; juce::ValueTree dspConfig { "Program" }; + juce::UndoManager* undoManager = nullptr; std::vector> nodes; std::map nodeLookup; diff --git a/modules/foleys_dsp_magic/Nodes/foleys_Gain.cpp b/modules/foleys_dsp_magic/Nodes/foleys_Gain.cpp index 60c10109..ef01a8c3 100644 --- a/modules/foleys_dsp_magic/Nodes/foleys_Gain.cpp +++ b/modules/foleys_dsp_magic/Nodes/foleys_Gain.cpp @@ -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")); } @@ -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); } diff --git a/modules/foleys_dsp_magic/Nodes/foleys_Oscillator.cpp b/modules/foleys_dsp_magic/Nodes/foleys_Oscillator.cpp index 0e8846b0..da3ce669 100644 --- a/modules/foleys_dsp_magic/Nodes/foleys_Oscillator.cpp +++ b/modules/foleys_dsp_magic/Nodes/foleys_Oscillator.cpp @@ -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); @@ -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 (signalType->getStaticValue())); @@ -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)); diff --git a/modules/foleys_dsp_magic/Nodes/foleys_Oscilloscope.cpp b/modules/foleys_dsp_magic/Nodes/foleys_Oscilloscope.cpp index a75d75b2..4388786a 100644 --- a/modules/foleys_dsp_magic/Nodes/foleys_Oscilloscope.cpp +++ b/modules/foleys_dsp_magic/Nodes/foleys_Oscilloscope.cpp @@ -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 (getName()); @@ -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 (spec.maximumBlockSize)); } void Oscilloscope::process ([[maybe_unused]] int numSamples) @@ -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);