Files
pete/Source/PluginProcessor.cpp

139 lines
3.5 KiB
C++

#include "PluginProcessor.h"
#include "PluginEditor.h"
LampshadeAudioProcessor::LampshadeAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
: AudioProcessor (BusesProperties()
#if ! JucePlugin_IsMidiEffect
#if ! JucePlugin_IsSynth
.withInput ("Input", AudioChannelSet::stereo(), true)
#endif
.withOutput ("Output", AudioChannelSet::stereo(), true)
#endif
)
#endif
{
}
LampshadeAudioProcessor::~LampshadeAudioProcessor()
{
}
const String LampshadeAudioProcessor::getName() const
{
return JucePlugin_Name;
}
bool LampshadeAudioProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
return true;
#else
return false;
#endif
}
bool LampshadeAudioProcessor::producesMidi() const
{
return false;
}
double LampshadeAudioProcessor::getTailLengthSeconds() const
{
return 0.0;
}
int LampshadeAudioProcessor::getNumPrograms()
{
return 1;
}
int LampshadeAudioProcessor::getCurrentProgram()
{
return 0;
}
void LampshadeAudioProcessor::setCurrentProgram (int index)
{
}
const String LampshadeAudioProcessor::getProgramName (int index)
{
return {};
}
void LampshadeAudioProcessor::changeProgramName (int index, const String& newName)
{
}
void LampshadeAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
myYin = Yin(sampleRate, samplesPerBlock);
}
void LampshadeAudioProcessor::releaseResources()
{
}
#ifndef JucePlugin_PreferredChannelConfigurations
bool LampshadeAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
{
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
return false;
#if ! JucePlugin_IsSynth
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
return false;
#endif
return true;
}
#endif
void LampshadeAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
const int totalNumInputChannels = getTotalNumInputChannels();
const int totalNumOutputChannels = getTotalNumOutputChannels();
// In case we have more outputs than inputs, this code clears any output
// channels that didn't contain input data, (because these aren't
// guaranteed to be empty - they may contain garbage).
// This is here to avoid people getting screaming feedback
// when they first compile a plugin, but obviously you don't need to keep
// this code if your algorithm always overwrites all the output channels.
for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear(i, 0, buffer.getNumSamples());
float pitch = myYin.getPitch(buffer.getWritePointer (0)); // returns Pitch in Hertz
printf("pitch: %f", pitch);
for (int channel = 0; channel < totalNumInputChannels; ++channel) {
//float* channelData = buffer.getWritePointer (channel);
}
}
bool LampshadeAudioProcessor::hasEditor() const
{
return true;
}
AudioProcessorEditor* LampshadeAudioProcessor::createEditor()
{
return new LampshadeAudioProcessorEditor(*this);
}
void LampshadeAudioProcessor::getStateInformation (MemoryBlock& destData)
{
}
void LampshadeAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
}
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new LampshadeAudioProcessor();
}