2020-04-03 13:23:19 +02:00
|
|
|
#include "PluginProcessor.h"
|
|
|
|
#include "PluginEditor.h"
|
2020-06-13 10:56:20 +02:00
|
|
|
#include "Veno/Core/AudioConfig.h"
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
VenoAudioProcessor::VenoAudioProcessor ()
|
2020-07-09 16:31:33 +02:00
|
|
|
#ifndef JucePlugin_PreferredChannelConfigurations
|
2020-04-03 13:23:19 +02:00
|
|
|
: AudioProcessor (BusesProperties()
|
|
|
|
#if ! JucePlugin_IsMidiEffect
|
|
|
|
#if ! JucePlugin_IsSynth
|
|
|
|
.withInput ("Input", AudioChannelSet::stereo(), true)
|
|
|
|
#endif
|
|
|
|
.withOutput ("Output", AudioChannelSet::stereo(), true)
|
|
|
|
#endif
|
|
|
|
)
|
2020-07-09 16:31:33 +02:00
|
|
|
#endif
|
2020-06-13 16:52:16 +02:00
|
|
|
{
|
2020-06-14 21:14:28 +02:00
|
|
|
instance = VenoInstance::createInstance(m_id);
|
2020-07-09 16:31:33 +02:00
|
|
|
AudioConfig::registerInstance(m_id);
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
VenoAudioProcessor::~VenoAudioProcessor ()
|
|
|
|
{
|
2020-07-09 16:31:33 +02:00
|
|
|
instance.reset();
|
2020-06-14 21:14:28 +02:00
|
|
|
VenoInstance::deleteInstance(m_id);
|
2020-07-09 16:31:33 +02:00
|
|
|
AudioConfig::deleteInstance(m_id);
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
const String VenoAudioProcessor::getName () const
|
|
|
|
{
|
2020-04-03 13:23:19 +02:00
|
|
|
return JucePlugin_Name;
|
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
bool VenoAudioProcessor::acceptsMidi () const
|
|
|
|
{
|
2020-06-13 10:56:20 +02:00
|
|
|
#if JucePlugin_WantsMidiInput
|
2020-04-03 13:23:19 +02:00
|
|
|
return true;
|
2020-06-13 10:56:20 +02:00
|
|
|
#else
|
2020-04-03 13:23:19 +02:00
|
|
|
return false;
|
2020-06-13 10:56:20 +02:00
|
|
|
#endif
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
bool VenoAudioProcessor::producesMidi () const
|
|
|
|
{
|
2020-06-13 10:56:20 +02:00
|
|
|
#if JucePlugin_ProducesMidiOutput
|
2020-04-03 13:23:19 +02:00
|
|
|
return true;
|
2020-06-13 10:56:20 +02:00
|
|
|
#else
|
2020-04-03 13:23:19 +02:00
|
|
|
return false;
|
2020-06-13 10:56:20 +02:00
|
|
|
#endif
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
bool VenoAudioProcessor::isMidiEffect () const
|
|
|
|
{
|
2020-06-13 10:56:20 +02:00
|
|
|
#if JucePlugin_IsMidiEffect
|
2020-04-03 13:23:19 +02:00
|
|
|
return true;
|
2020-06-13 10:56:20 +02:00
|
|
|
#else
|
2020-04-03 13:23:19 +02:00
|
|
|
return false;
|
2020-06-13 10:56:20 +02:00
|
|
|
#endif
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
double VenoAudioProcessor::getTailLengthSeconds () const
|
|
|
|
{
|
2020-04-03 13:23:19 +02:00
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
int VenoAudioProcessor::getNumPrograms ()
|
|
|
|
{
|
2020-06-08 21:27:17 +02:00
|
|
|
return 1;
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
int VenoAudioProcessor::getCurrentProgram ()
|
|
|
|
{
|
2020-04-03 13:23:19 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
void VenoAudioProcessor::setCurrentProgram (int index)
|
|
|
|
{
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
const String VenoAudioProcessor::getProgramName (int index)
|
|
|
|
{
|
2020-04-03 13:23:19 +02:00
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
void VenoAudioProcessor::changeProgramName (int index, const String& newName)
|
|
|
|
{
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//==============================================================================
|
2020-06-13 16:52:16 +02:00
|
|
|
void VenoAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
|
|
|
|
{
|
2020-06-14 21:14:28 +02:00
|
|
|
auto audioConfig = AudioConfig::getInstance();
|
|
|
|
audioConfig->setSampleRate(sampleRate);
|
|
|
|
audioConfig->initWaveTables();
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
void VenoAudioProcessor::releaseResources ()
|
|
|
|
{
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef JucePlugin_PreferredChannelConfigurations
|
2020-06-13 10:56:20 +02:00
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
bool VenoAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
|
|
|
|
{
|
2020-06-13 10:56:20 +02:00
|
|
|
#if JucePlugin_IsMidiEffect
|
2020-04-03 13:23:19 +02:00
|
|
|
ignoreUnused (layouts);
|
|
|
|
return true;
|
2020-06-13 10:56:20 +02:00
|
|
|
#else
|
2020-06-14 21:14:28 +02:00
|
|
|
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
|
|
|
|
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
|
2020-04-03 13:23:19 +02:00
|
|
|
return false;
|
2020-06-13 10:56:20 +02:00
|
|
|
#if !JucePlugin_IsSynth
|
2020-04-03 13:23:19 +02:00
|
|
|
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
|
|
|
|
return false;
|
2020-06-13 10:56:20 +02:00
|
|
|
#endif
|
2020-04-03 13:23:19 +02:00
|
|
|
return true;
|
2020-06-13 10:56:20 +02:00
|
|
|
#endif
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
2020-06-13 10:56:20 +02:00
|
|
|
|
2020-04-03 13:23:19 +02:00
|
|
|
#endif
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
void VenoAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
|
|
|
|
{
|
2020-04-03 13:23:19 +02:00
|
|
|
ScopedNoDenormals noDenormals;
|
2020-06-14 21:14:28 +02:00
|
|
|
instance->matrix.updateSlots();
|
|
|
|
instance->audioBuffer->reset(buffer.getNumSamples());
|
|
|
|
int numChannels = buffer.getNumChannels();
|
2020-06-13 16:52:16 +02:00
|
|
|
for (int i = 0; i < numChannels; ++i)
|
|
|
|
{
|
2020-06-14 21:14:28 +02:00
|
|
|
auto c = buffer.getReadPointer(i);
|
|
|
|
for (int j = 0; j < buffer.getNumSamples(); ++j)
|
2020-06-13 16:52:16 +02:00
|
|
|
{
|
2020-06-14 21:14:28 +02:00
|
|
|
instance->audioBuffer->addMonoSample(c[j], j);
|
2020-06-13 16:52:16 +02:00
|
|
|
if (i == 0)
|
|
|
|
{
|
2020-06-14 21:14:28 +02:00
|
|
|
instance->audioBuffer->addLeftSample(c[j], j);
|
2020-06-13 10:56:20 +02:00
|
|
|
}
|
2020-06-13 16:52:16 +02:00
|
|
|
if (i == 1 || numChannels == 1)
|
|
|
|
{
|
2020-06-14 21:14:28 +02:00
|
|
|
instance->audioBuffer->addRightSample(c[j], j);
|
2020-06-13 10:56:20 +02:00
|
|
|
}
|
|
|
|
}
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
2020-07-09 16:31:33 +02:00
|
|
|
instance->audioBuffer->calcPeak ();
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//==============================================================================
|
2020-06-13 16:52:16 +02:00
|
|
|
bool VenoAudioProcessor::hasEditor () const
|
|
|
|
{
|
2020-06-08 21:27:17 +02:00
|
|
|
return true;
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
AudioProcessorEditor* VenoAudioProcessor::createEditor ()
|
|
|
|
{
|
2020-06-14 21:14:28 +02:00
|
|
|
return new VenoAudioProcessorEditor(*this);
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//==============================================================================
|
2020-06-13 16:52:16 +02:00
|
|
|
void VenoAudioProcessor::getStateInformation (MemoryBlock& destData)
|
|
|
|
{
|
2020-07-09 16:31:33 +02:00
|
|
|
auto matrixXML = instance->matrix.saveMatrixToXML();
|
|
|
|
if (matrixXML != nullptr) {
|
|
|
|
copyXmlToBinary(*matrixXML, destData);
|
|
|
|
} else {
|
|
|
|
DBG("Sorry something went wrong! xml is nullptr");
|
|
|
|
}
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
void VenoAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
|
|
|
|
{
|
2020-07-09 16:31:33 +02:00
|
|
|
std::unique_ptr<XmlElement> xmlState(getXmlFromBinary(data, sizeInBytes));
|
|
|
|
if (xmlState != nullptr)
|
|
|
|
instance->matrix.getMatrixFromXML(xmlState);
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
AudioProcessor* JUCE_CALLTYPE createPluginFilter ()
|
|
|
|
{
|
2020-06-14 21:14:28 +02:00
|
|
|
return new VenoAudioProcessor();
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|