mirror of
https://codeberg.org/armin/horizont.git
synced 2026-09-01 12:20:47 +02:00
81 lines
2.6 KiB
C
81 lines
2.6 KiB
C
|
|
#pragma once
|
||
|
|
|
||
|
|
#include <JuceHeader.h>
|
||
|
|
|
||
|
|
#include <atomic>
|
||
|
|
|
||
|
|
#include "Presets.h"
|
||
|
|
#include "HorizontEngine.h"
|
||
|
|
|
||
|
|
class HorizontAudioProcessor : public juce::AudioProcessor
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
HorizontAudioProcessor();
|
||
|
|
~HorizontAudioProcessor() override;
|
||
|
|
|
||
|
|
void prepareToPlay (double sampleRate, int samplesPerBlock) override;
|
||
|
|
void releaseResources() override;
|
||
|
|
|
||
|
|
bool isBusesLayoutSupported (const BusesLayout& layouts) const override;
|
||
|
|
|
||
|
|
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;
|
||
|
|
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;
|
||
|
|
|
||
|
|
juce::AudioProcessorValueTreeState::ParameterLayout createParameterLayout();
|
||
|
|
|
||
|
|
void applyPreset (const Preset& preset);
|
||
|
|
const std::vector<Preset>& getPresets() const noexcept { return presets; }
|
||
|
|
|
||
|
|
void pushWetSamples (const float* data, int numToWrite);
|
||
|
|
int readWetSamples (float* dest, int numToRead);
|
||
|
|
|
||
|
|
void appendDrySamples (const float* data, int numToWrite);
|
||
|
|
int copyRecentDrySamples (float* dest, int numToRead);
|
||
|
|
|
||
|
|
juce::AudioProcessorValueTreeState apvts;
|
||
|
|
|
||
|
|
private:
|
||
|
|
void updateParameters();
|
||
|
|
|
||
|
|
HorizontEngine engine;
|
||
|
|
std::vector<Preset> presets;
|
||
|
|
int currentProgram = 0;
|
||
|
|
|
||
|
|
juce::AbstractFifo wetFifo { 2048 };
|
||
|
|
juce::AudioBuffer<float> wetRing { 1, 2048 };
|
||
|
|
std::vector<float> wetScratch;
|
||
|
|
|
||
|
|
std::vector<float> dryScratch;
|
||
|
|
static constexpr int dryRingSize = 4096;
|
||
|
|
std::vector<float> dryRingLive = std::vector<float> (dryRingSize, 0.0f);
|
||
|
|
std::atomic<size_t> dryWritePos { 0 };
|
||
|
|
std::atomic<size_t> dryTotalWritten { 0 };
|
||
|
|
|
||
|
|
std::atomic<float>* lowCutParam = nullptr;
|
||
|
|
std::atomic<float>* highCutParam = nullptr;
|
||
|
|
std::atomic<float>* decayParam = nullptr;
|
||
|
|
std::atomic<float>* sizeParam = nullptr;
|
||
|
|
std::atomic<float>* diffusionParam = nullptr;
|
||
|
|
std::atomic<float>* brightnessParam = nullptr;
|
||
|
|
std::atomic<float>* feedbackParam = nullptr;
|
||
|
|
std::atomic<float>* pitchParam = nullptr;
|
||
|
|
std::atomic<float>* dryWetParam = nullptr;
|
||
|
|
|
||
|
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (HorizontAudioProcessor)
|
||
|
|
};
|