reVeno/Source/PluginProcessor.cpp

147 lines
4.1 KiB
C++
Raw Normal View History

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-04-03 13:23:19 +02:00
VenoAudioProcessor::VenoAudioProcessor()
2020-06-13 10:56:20 +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-06-13 10:56:20 +02:00
#endif*/
: AudioProcessor(BusesProperties().withInput("Input", AudioChannelSet::stereo(), true).withOutput("Output",
AudioChannelSet::stereo(),
true)) {
instance = VenoInstance::createInstance(m_id);
2020-04-03 13:23:19 +02:00
}
2020-06-13 10:56:20 +02:00
VenoAudioProcessor::~VenoAudioProcessor() {
VenoInstance::deleteInstance(m_id);
2020-04-03 13:23:19 +02:00
}
2020-06-13 10:56:20 +02:00
const String VenoAudioProcessor::getName() const {
2020-04-03 13:23:19 +02:00
return JucePlugin_Name;
}
2020-06-13 10:56:20 +02:00
bool VenoAudioProcessor::acceptsMidi() const {
#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 10:56:20 +02:00
bool VenoAudioProcessor::producesMidi() const {
#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 10:56:20 +02:00
bool VenoAudioProcessor::isMidiEffect() const {
#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 10:56:20 +02:00
double VenoAudioProcessor::getTailLengthSeconds() const {
2020-04-03 13:23:19 +02:00
return 0.0;
}
2020-06-13 10:56:20 +02:00
int VenoAudioProcessor::getNumPrograms() {
return 1;
2020-04-03 13:23:19 +02:00
}
2020-06-13 10:56:20 +02:00
int VenoAudioProcessor::getCurrentProgram() {
2020-04-03 13:23:19 +02:00
return 0;
}
2020-06-13 10:56:20 +02:00
void VenoAudioProcessor::setCurrentProgram(int index) {
2020-04-03 13:23:19 +02:00
}
2020-06-13 10:56:20 +02:00
const String VenoAudioProcessor::getProgramName(int index) {
2020-04-03 13:23:19 +02:00
return {};
}
2020-06-13 10:56:20 +02:00
void VenoAudioProcessor::changeProgramName(int index, const String &newName) {
2020-04-03 13:23:19 +02:00
}
//==============================================================================
2020-06-13 10:56:20 +02:00
void VenoAudioProcessor::prepareToPlay(double sampleRate, int samplesPerBlock) {
auto audioConfig = AudioConfig::getInstance();
audioConfig->setSampleRate(sampleRate);
audioConfig->initWaveTables();
2020-04-03 13:23:19 +02:00
}
2020-06-13 10:56:20 +02:00
void VenoAudioProcessor::releaseResources() {
2020-04-03 13:23:19 +02:00
}
#ifndef JucePlugin_PreferredChannelConfigurations
2020-06-13 10:56:20 +02:00
bool VenoAudioProcessor::isBusesLayoutSupported(const BusesLayout &layouts) const {
#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-04-03 13:23:19 +02:00
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
2020-06-13 10:56:20 +02:00
&& 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 10:56:20 +02:00
void VenoAudioProcessor::processBlock(AudioBuffer<float> &buffer, MidiBuffer &midiMessages) {
2020-04-03 13:23:19 +02:00
ScopedNoDenormals noDenormals;
2020-06-13 10:56:20 +02:00
instance->audioBuffer->reset(buffer.getNumSamples());
int numChannels = buffer.getNumChannels();
for (int i = 0; i < numChannels; ++i) {
auto c = buffer.getReadPointer(i);
for (int j = 0; j < buffer.getNumSamples(); ++j) {
instance->fft.pushNextSampleIntoFifo(c[j]);
instance->audioBuffer->addMonoSample(c[j], j);
if (i == 0) {
instance->audioBuffer->addLeftSample(c[j], j);
}
if (i == 1 || numChannels == 1) {
instance->audioBuffer->addRightSample(c[j], j);
}
}
2020-04-03 13:23:19 +02:00
}
}
//==============================================================================
2020-06-13 10:56:20 +02:00
bool VenoAudioProcessor::hasEditor() const {
return true;
2020-04-03 13:23:19 +02:00
}
2020-06-13 10:56:20 +02:00
AudioProcessorEditor *VenoAudioProcessor::createEditor() {
return new VenoAudioProcessorEditor(*this);
2020-04-03 13:23:19 +02:00
}
//==============================================================================
2020-06-13 10:56:20 +02:00
void VenoAudioProcessor::getStateInformation(MemoryBlock &destData) {
2020-04-03 13:23:19 +02:00
}
2020-06-13 10:56:20 +02:00
void VenoAudioProcessor::setStateInformation(const void *data, int sizeInBytes) {
2020-04-03 13:23:19 +02:00
}
2020-06-13 10:56:20 +02:00
AudioProcessor *JUCE_CALLTYPE createPluginFilter() {
2020-04-03 13:23:19 +02:00
return new VenoAudioProcessor();
}