2023-01-09 21:58:49 +00:00
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
This file contains the basic framework code for a JUCE plugin processor.
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <JuceHeader.h>
|
2023-01-15 17:01:27 +00:00
|
|
|
#include "shape/Shape.h"
|
|
|
|
#include "parser/FileParser.h"
|
|
|
|
#include "parser/FrameProducer.h"
|
|
|
|
#include "parser/FrameConsumer.h"
|
2023-03-25 20:24:10 +00:00
|
|
|
#include "audio/Effect.h"
|
|
|
|
#include "audio/BitCrushEffect.h"
|
2023-03-26 12:58:31 +00:00
|
|
|
#include "audio/BulgeEffect.h"
|
2023-01-09 21:58:49 +00:00
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
class OscirenderAudioProcessor : public juce::AudioProcessor
|
|
|
|
#if JucePlugin_Enable_ARA
|
|
|
|
, public juce::AudioProcessorARAExtension
|
|
|
|
#endif
|
2023-01-15 17:01:27 +00:00
|
|
|
, public FrameConsumer
|
2023-01-09 21:58:49 +00:00
|
|
|
{
|
|
|
|
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;
|
2023-03-28 12:44:46 +00:00
|
|
|
float frequency = 440.0f;
|
2023-01-15 17:01:27 +00:00
|
|
|
|
|
|
|
double currentSampleRate = 0.0;
|
|
|
|
|
2023-03-26 12:58:31 +00:00
|
|
|
std::vector<std::shared_ptr<Effect>> allEffects;
|
|
|
|
std::shared_ptr<std::vector<std::shared_ptr<Effect>>> enabledEffects = std::make_shared<std::vector<std::shared_ptr<Effect>>>();
|
2023-03-25 20:24:10 +00:00
|
|
|
|
|
|
|
BitCrushEffect bitCrushEffect = BitCrushEffect();
|
2023-03-26 12:58:31 +00:00
|
|
|
BulgeEffect bulgeEffect = BulgeEffect();
|
2023-03-25 20:24:10 +00:00
|
|
|
|
2023-03-30 16:28:47 +00:00
|
|
|
std::vector<std::shared_ptr<FileParser>> parsers;
|
|
|
|
std::vector<std::shared_ptr<juce::MemoryBlock>> fileBlocks;
|
|
|
|
std::vector<juce::File> files;
|
|
|
|
int currentFile = -1;
|
|
|
|
|
2023-01-15 17:01:27 +00:00
|
|
|
std::unique_ptr<FrameProducer> producer;
|
|
|
|
|
|
|
|
void updateAngleDelta();
|
2023-03-26 12:58:31 +00:00
|
|
|
void addFrame(std::vector<std::unique_ptr<Shape>> frame) override;
|
|
|
|
void enableEffect(std::shared_ptr<Effect> effect);
|
2023-03-29 09:55:11 +00:00
|
|
|
void disableEffect(std::shared_ptr<Effect> effect);
|
2023-03-28 15:21:18 +00:00
|
|
|
void updateEffectPrecedence();
|
2023-03-30 16:28:47 +00:00
|
|
|
void updateFileBlock(int index, std::shared_ptr<juce::MemoryBlock> block);
|
|
|
|
void addFile(juce::File file);
|
|
|
|
void removeFile(int index);
|
|
|
|
int numFiles();
|
|
|
|
void openFile(int index);
|
|
|
|
int getCurrentFile();
|
|
|
|
std::shared_ptr<juce::MemoryBlock> getFileBlock(int index);
|
2023-01-09 21:58:49 +00:00
|
|
|
private:
|
2023-01-15 17:01:27 +00:00
|
|
|
double theta = 0.0;
|
|
|
|
double thetaDelta = 0.0;
|
|
|
|
|
|
|
|
juce::AbstractFifo frameFifo{ 10 };
|
|
|
|
std::vector<std::unique_ptr<Shape>> frameBuffer[10];
|
|
|
|
|
|
|
|
int currentShape = 0;
|
2023-01-15 22:34:02 +00:00
|
|
|
std::vector<std::unique_ptr<Shape>> frame;
|
2023-01-15 17:01:27 +00:00
|
|
|
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;
|
|
|
|
|
2023-01-09 21:58:49 +00:00
|
|
|
//==============================================================================
|
|
|
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OscirenderAudioProcessor)
|
|
|
|
};
|