-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPluginProcessor.h
More file actions
65 lines (51 loc) · 2.7 KB
/
Copy pathPluginProcessor.h
File metadata and controls
65 lines (51 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#pragma once
#include <juce_audio_processors/juce_audio_processors.h>
// Forward-declared so PluginProcessor.h stays free of UI headers.
// The editor is included in PluginProcessor.cpp only.
class PluginEditor;
// =============================================================================
class PluginProcessor : public juce::AudioProcessor
{
public:
PluginProcessor ();
~PluginProcessor () override;
// ---- AudioProcessor interface -------------------------------------------
void prepareToPlay (double sampleRate, int samplesPerBlock) override;
void releaseResources () override;
void processBlock (juce::AudioBuffer<float>&, juce::MidiBuffer&) override;
juce::AudioProcessorEditor* createEditor () override;
bool hasEditor () const override { return true; }
const juce::String getName () const override { return "SpectralWaterfall"; }
bool acceptsMidi () const override { return false; }
bool producesMidi () const override { return false; }
bool isMidiEffect () const override { return false; }
double getTailLengthSeconds () const override { return 0.0; }
int getNumPrograms () override { return 1; }
int getCurrentProgram () override { return 0; }
void setCurrentProgram (int) override {}
const juce::String getProgramName (int) override { return {}; }
void changeProgramName (int, const juce::String&) override {}
void getStateInformation (juce::MemoryBlock&) override {}
void setStateInformation (const void*, int) override {}
bool isBusesLayoutSupported (const BusesLayout& layouts) const override;
// ---- Called by PluginEditor on construction / destruction ---------------
//
// The processor needs to push audio into the waterfall component owned
// by the editor. Rather than giving the processor a hard dependency on
// the editor class, we expose a minimal interface: the editor registers
// itself atomically so processBlock can call it safely even on the RT
// thread while the editor is being constructed or torn down on the
// message thread.
void registerEditor (PluginEditor* e);
void unregisterEditor (PluginEditor* e);
private:
// Non-owning, atomic. Written only on the message thread (JUCE guarantees
// createEditor / deleteEditor are message-thread-only). Read on the RT
// thread in processBlock with acquire ordering.
std::atomic<PluginEditor*> activeEditor{nullptr};
// Scratch mono buffer allocated in prepareToPlay to avoid heap allocation
// on the RT thread. processBlock mixes channels into this before handing
// samples to the waterfall.
std::vector<float> monoScratch;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PluginProcessor)
};