osci-render/Source/PluginProcessor.h

97 wiersze
3.3 KiB
C++

/*
==============================================================================
This file contains the basic framework code for a JUCE plugin processor.
==============================================================================
*/
#pragma once
#include <JuceHeader.h>
#include "shape/Shape.h"
#include "parser/FileParser.h"
#include "parser/FrameProducer.h"
#include "parser/FrameConsumer.h"
//==============================================================================
/**
*/
class OscirenderAudioProcessor : public juce::AudioProcessor
#if JucePlugin_Enable_ARA
, public juce::AudioProcessorARAExtension
#endif
, public FrameConsumer
{
public:
//==============================================================================
OscirenderAudioProcessor();
~OscirenderAudioProcessor() override;
//==============================================================================
void prepareToPlay (double sampleRate, int samplesPerBlock) override;
void releaseResources() override;
#ifndef JucePlugin_PreferredChannelConfigurations
bool isBusesLayoutSupported (const BusesLayout& layouts) const override;
#endif
void processBlock (juce::AudioBuffer<float>&, juce::MidiBuffer&) override;
//==============================================================================
juce::AudioProcessorEditor* createEditor() override;
bool hasEditor() const override;
//==============================================================================
const juce::String getName() const override;
bool acceptsMidi() const override;
bool producesMidi() const override;
bool isMidiEffect() const override;
double getTailLengthSeconds() const override;
//==============================================================================
int getNumPrograms() override;
int getCurrentProgram() override;
void setCurrentProgram (int index) override;
const juce::String getProgramName (int index) override;
void changeProgramName (int index, const juce::String& newName) override;
//==============================================================================
void getStateInformation (juce::MemoryBlock& destData) override;
void setStateInformation (const void* data, int sizeInBytes) override;
float noteOnVel;
float frequency = 0.0f;
double currentSampleRate = 0.0;
FileParser parser;
std::unique_ptr<FrameProducer> producer;
void updateAngleDelta();
void addFrame(std::vector<std::unique_ptr<Shape>> frame) override;
private:
double theta = 0.0;
double thetaDelta = 0.0;
juce::AbstractFifo frameFifo{ 10 };
std::vector<std::unique_ptr<Shape>> frameBuffer[10];
int currentShape = 0;
std::vector<std::unique_ptr<Shape>> frame;
double frameLength;
double shapeDrawn = 0.0;
double frameDrawn = 0.0;
double lengthIncrement = 0.0;
void updateFrame();
void updateLengthIncrement();
const double MIN_LENGTH_INCREMENT = 0.000001;
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OscirenderAudioProcessor)
};