#pragma once #define NOMINMAX #include #include #include "../concurrency/BufferConsumer.h" #include "../PluginProcessor.h" #include "LabelledTextBox.h" enum class FullScreenMode { TOGGLE, FULL_SCREEN, MAIN_COMPONENT, }; class VisualiserComponent : public juce::Component, public juce::Timer, public juce::Thread, public juce::MouseListener, public juce::SettableTooltipClient { public: VisualiserComponent(int numChannels, OscirenderAudioProcessor& p); ~VisualiserComponent() override; void setFullScreenCallback(std::function callback); void mouseDoubleClick(const juce::MouseEvent& event) override; void setBuffer(std::vector& buffer); void setColours(juce::Colour backgroundColour, juce::Colour waveformColour); void paintChannel(juce::Graphics&, juce::Rectangle bounds, int channel); void paintXY(juce::Graphics&, juce::Rectangle bounds); void paint(juce::Graphics&) override; void timerCallback() override; void run() override; void mouseDown(const juce::MouseEvent& event) override; bool keyPressed(const juce::KeyPress& key) override; void setFullScreen(bool fullScreen); private: const double BUFFER_LENGTH_SECS = 0.02; const double DEFAULT_SAMPLE_RATE = 192000.0; juce::CriticalSection lock; std::vector buffer; std::vector> prevLines; int numChannels = 2; juce::Colour backgroundColour, waveformColour; OscirenderAudioProcessor& audioProcessor; int sampleRate = DEFAULT_SAMPLE_RATE; LabelledTextBox roughness{"Roughness", 1, 8, 1}; LabelledTextBox intensity{"Intensity", 0, 1, 0.01}; std::vector tempBuffer; int precision = 4; std::atomic active = true; std::shared_ptr consumer; std::function fullScreenCallback; void resetBuffer(); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(VisualiserComponent) };