-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial juce::AudioProcessor overrides
- Loading branch information
1 parent
98aaef3
commit b194cc2
Showing
5 changed files
with
129 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,58 @@ | ||
/** | ||
* @file PluginProcessor.cpp | ||
* @author StoneyDSP ([email protected]) | ||
* @brief | ||
* @version 0.1 | ||
* @date 2023-09-07 | ||
* | ||
* @copyright Copyright (c) 2023 | ||
* | ||
*/ | ||
|
||
#include "StoneyDSP/Biquads/PluginProcessor.hpp" | ||
#include "StoneyDSP/Biquads/PluginEditor.hpp" | ||
|
||
//============================================================================== | ||
BiquadsAudioProcessor::BiquadsAudioProcessor() | ||
: AudioProcessor (BusesProperties() | ||
#if ! JucePlugin_IsMidiEffect | ||
#if ! JucePlugin_IsSynth | ||
.withInput ("Input", juce::AudioChannelSet::stereo(), true) | ||
#endif | ||
.withOutput ("Output", juce::AudioChannelSet::stereo(), true) | ||
#endif | ||
) | ||
: AudioProcessor (BusesProperties() | ||
#if ! JucePlugin_IsMidiEffect | ||
#if ! JucePlugin_IsSynth | ||
.withInput ("Input", juce::AudioChannelSet::stereo(), true) | ||
#endif | ||
.withOutput ("Output", juce::AudioChannelSet::stereo(), true) | ||
#endif | ||
) | ||
, undoManager() | ||
, apvts(*this, &undoManager, "Parameters", createParameterLayout()) | ||
, bypassState (dynamic_cast<juce::AudioParameterBool*>(apvts.getParameter("bypassID"))) | ||
{ | ||
} | ||
|
||
BiquadsAudioProcessor::~BiquadsAudioProcessor() | ||
{ | ||
} | ||
|
||
//============================================================================== | ||
juce::AudioProcessorParameter* BiquadsAudioProcessor::getBypassParameter() const | ||
{ | ||
return bypassState; | ||
} | ||
|
||
bool BiquadsAudioProcessor::isBypassed() const noexcept | ||
{ | ||
return bypassState->get() == true; | ||
} | ||
|
||
void BiquadsAudioProcessor::setBypassParameter(juce::AudioParameterBool* newBypass) noexcept | ||
{ | ||
if (bypassState != newBypass) | ||
{ | ||
bypassState = newBypass; | ||
releaseResources(); | ||
reset(); | ||
} | ||
} | ||
|
||
//============================================================================== | ||
const juce::String BiquadsAudioProcessor::getName() const | ||
{ | ||
|
@@ -164,20 +199,53 @@ juce::AudioProcessorEditor* BiquadsAudioProcessor::createEditor() | |
return new BiquadsAudioProcessorEditor (*this); | ||
} | ||
|
||
juce::AudioProcessorValueTreeState::ParameterLayout BiquadsAudioProcessor::createParameterLayout() | ||
{ | ||
juce::AudioProcessorValueTreeState::ParameterLayout parameterLayout; | ||
|
||
parameterLayout.add(std::make_unique<juce::AudioParameterBool>("bypassID", "Bypass", false)); | ||
|
||
// Parameters::setParameterLayout(parameterLayout); | ||
|
||
return parameterLayout; | ||
} | ||
|
||
//============================================================================== | ||
void BiquadsAudioProcessor::getStateInformation (juce::MemoryBlock& destData) | ||
{ | ||
// You should use this method to store your parameters in the memory block. | ||
// You could do that either as raw data, or use the XML or ValueTree classes | ||
// as intermediaries to make it easy to save and load complex data. | ||
juce::ignoreUnused (destData); | ||
auto state = apvts.copyState(); | ||
std::unique_ptr<juce::XmlElement> xml(state.createXml()); | ||
copyXmlToBinary(*xml, destData); | ||
} | ||
|
||
void BiquadsAudioProcessor::getCurrentProgramStateInformation(juce::MemoryBlock& destData) | ||
{ | ||
auto state = apvts.copyState(); | ||
std::unique_ptr<juce::XmlElement> xml(state.createXml()); | ||
copyXmlToBinary(*xml, destData); | ||
} | ||
|
||
void BiquadsAudioProcessor::setStateInformation (const void* data, int sizeInBytes) | ||
{ | ||
// You should use this method to restore your parameters from this memory block, | ||
// whose contents will have been created by the getStateInformation() call. | ||
juce::ignoreUnused (data, sizeInBytes); | ||
std::unique_ptr<juce::XmlElement> xmlState(getXmlFromBinary(data, sizeInBytes)); | ||
|
||
if (xmlState.get() != nullptr) | ||
if (xmlState->hasTagName(apvts.state.getType())) | ||
apvts.replaceState(juce::ValueTree::fromXml(*xmlState)); | ||
} | ||
|
||
void BiquadsAudioProcessor::setCurrentProgramStateInformation(const void* data, int sizeInBytes) | ||
{ | ||
std::unique_ptr<juce::XmlElement> xmlState(getXmlFromBinary(data, sizeInBytes)); | ||
|
||
if (xmlState.get() != nullptr) | ||
if (xmlState->hasTagName(apvts.state.getType())) | ||
apvts.replaceState(juce::ValueTree::fromXml(*xmlState)); | ||
} | ||
|
||
//============================================================================== | ||
|