155 lines
4.4 KiB
C++
155 lines
4.4 KiB
C++
/*
|
|
==============================================================================
|
|
|
|
This file contains the basic framework code for a JUCE plugin processor.
|
|
|
|
==============================================================================
|
|
*/
|
|
|
|
#include "PluginProcessor.h"
|
|
#include "PluginEditor.h"
|
|
|
|
#include <iostream>
|
|
|
|
//==============================================================================
|
|
CustomDrumsAudioProcessor::CustomDrumsAudioProcessor()
|
|
: AudioProcessor(BusesProperties()
|
|
.withOutput("Output", juce::AudioChannelSet::stereo(), true)
|
|
)
|
|
{
|
|
}
|
|
|
|
CustomDrumsAudioProcessor::~CustomDrumsAudioProcessor()
|
|
{
|
|
}
|
|
|
|
//==============================================================================
|
|
const juce::String CustomDrumsAudioProcessor::getName() const
|
|
{
|
|
return JucePlugin_Name;
|
|
}
|
|
|
|
bool CustomDrumsAudioProcessor::acceptsMidi() const
|
|
{
|
|
return true;
|
|
}
|
|
|
|
bool CustomDrumsAudioProcessor::producesMidi() const
|
|
{
|
|
return true;
|
|
}
|
|
|
|
bool CustomDrumsAudioProcessor::isMidiEffect() const
|
|
{
|
|
return true;
|
|
}
|
|
|
|
double CustomDrumsAudioProcessor::getTailLengthSeconds() const
|
|
{
|
|
return 0.0;
|
|
}
|
|
|
|
int CustomDrumsAudioProcessor::getNumPrograms()
|
|
{
|
|
return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs,
|
|
// so this should be at least 1, even if you're not really implementing programs.
|
|
}
|
|
|
|
int CustomDrumsAudioProcessor::getCurrentProgram()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
void CustomDrumsAudioProcessor::setCurrentProgram(int index)
|
|
{
|
|
}
|
|
|
|
const juce::String CustomDrumsAudioProcessor::getProgramName(int index)
|
|
{
|
|
return {};
|
|
}
|
|
|
|
void CustomDrumsAudioProcessor::changeProgramName(int index, const juce::String& newName)
|
|
{
|
|
}
|
|
|
|
//==============================================================================
|
|
void CustomDrumsAudioProcessor::prepareToPlay(double sampleRate, int samplesPerBlock)
|
|
{
|
|
// Use this method as the place to do any pre-playback
|
|
// initialisation that you need..
|
|
}
|
|
|
|
void CustomDrumsAudioProcessor::releaseResources()
|
|
{
|
|
// When playback stops, you can use this as an opportunity to free up any
|
|
// spare memory, etc.
|
|
}
|
|
|
|
bool CustomDrumsAudioProcessor::isBusesLayoutSupported(const BusesLayout& layouts) const
|
|
{
|
|
juce::ignoreUnused(layouts);
|
|
return true;
|
|
}
|
|
|
|
void CustomDrumsAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages)
|
|
{
|
|
juce::ScopedNoDenormals noDenormals;
|
|
auto totalNumInputChannels = getTotalNumInputChannels();
|
|
auto totalNumOutputChannels = getTotalNumOutputChannels();
|
|
|
|
buffer.clear();
|
|
|
|
juce::MidiBuffer processedMidi;
|
|
|
|
for (const auto metadata : midiMessages)
|
|
{
|
|
auto message = metadata.getMessage();
|
|
const auto time = metadata.samplePosition;
|
|
|
|
if (message.isNoteOn())
|
|
{
|
|
|
|
const int firstNote = 24;
|
|
|
|
std::cout << "Processed Input ! " << message.getChannel() << " " << abs(message.getNoteNumber() - 24) << std::endl;
|
|
}
|
|
|
|
processedMidi.addEvent(message, time);
|
|
}
|
|
|
|
midiMessages.swapWith(processedMidi);
|
|
}
|
|
|
|
//==============================================================================
|
|
bool CustomDrumsAudioProcessor::hasEditor() const
|
|
{
|
|
return true; // (change this to false if you choose to not supply an editor)
|
|
}
|
|
|
|
juce::AudioProcessorEditor* CustomDrumsAudioProcessor::createEditor()
|
|
{
|
|
return new CustomDrumsAudioProcessorEditor(*this);
|
|
}
|
|
|
|
//==============================================================================
|
|
void CustomDrumsAudioProcessor::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.
|
|
}
|
|
|
|
void CustomDrumsAudioProcessor::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.
|
|
}
|
|
|
|
//==============================================================================
|
|
// This creates new instances of the plugin..
|
|
juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter()
|
|
{
|
|
return new CustomDrumsAudioProcessor();
|
|
}
|