quantumVERB  1.0.0
A FOSS convolution reverb plugin
UIGraphBlock.h
1 /*
2  ==============================================================================
3 
4  UIGraphBlock.h
5 
6  ==============================================================================
7 */
8 
9 #pragma once
10 
11 #include "../JuceLibraryCode/JuceHeader.h"
12 
13 #include "PluginProcessor.h"
14 #include "UIBlock.h"
15 
16 namespace reverb
17 {
18 
19  //==============================================================================
20  class UIGraphBlock : public juce::GroupComponent,
21  public juce::Button::Listener,
22  public juce::ComboBox::Listener,
23  public juce::Slider::Listener
24  {
25  public:
26  //==============================================================================
27  UIGraphBlock(AudioProcessor& processor);
28  ~UIGraphBlock();
29 
30  //==============================================================================
31  using Ptr = std::unique_ptr<UIGraphBlock>;
32 
33  //==============================================================================
34  void paint(juce::Graphics&) override;
35  void resized() override;
36 
37  //==============================================================================
38  virtual void buttonClicked(juce::Button *) override { notifyToUpdate(); }
39  virtual void comboBoxChanged(juce::ComboBox *) override { notifyToUpdate(); }
40  virtual void sliderValueChanged(juce::Slider *) override { notifyToUpdate(); }
41 
42  //==============================================================================
43  AudioProcessor * getProcessorInstance() { return &processor; }
44 
45  std::mutex updatingGraph;
46  std::condition_variable updateComplete;
47 
48  protected:
49  //==============================================================================
50  AudioProcessor& processor;
51 
52  //==============================================================================
53  void updateGraph(int updatePeriodMs);
54 
55  std::unique_ptr<std::thread> graphThread;
56  std::atomic<bool> stopGraphThread = false;
57 
58  //==============================================================================
59  void notifyToUpdate();
60 
61  std::condition_variable mustUpdate;
62 
63  //==============================================================================
64  static constexpr float GRAPH_TOTAL_TIME_S = 6.0f;
65  static constexpr float GRAPH_TIME_STEP_S = 1.0f / 500.0f;
66  static constexpr float GRAPH_AVG_SAMPLING_STEP = 10;
67 
68  static constexpr float GRAPH_MAX_IR_VALUE = 10.0f;
69 
70  std::vector<juce::Path> irChannelPlots;
71 
72  private:
73  //==============================================================================
75  };
76 
77 }
float getParam(const juce::AudioProcessorValueTreeState &params, const juce::String &blockId) const
Internal method used to get (and check) a parameter&#39;s value.
Definition: Task.h:111
~UIGraphBlock()
Destroys a UIGraphBlock object.
void notifyToUpdate()
Signals thread to update graph.
void resized() override
Manages the layout of UIGraphBlock when the block is resized.
UIGraphBlock(AudioProcessor &processor)
Constructs a UIGraphBlock object.
void updateGraph(int updatePeriodMs)
Updates IR graph.