kopia lustrzana https://github.com/jameshball/osci-render
Allow visualiser to be paused by clicking
rodzic
298b2eeb77
commit
eece1b1dae
|
@ -32,6 +32,7 @@ void VisualiserComponent::paint(juce::Graphics& g) {
|
||||||
auto r = getLocalBounds().toFloat();
|
auto r = getLocalBounds().toFloat();
|
||||||
auto minDim = juce::jmin(r.getWidth(), r.getHeight());
|
auto minDim = juce::jmin(r.getWidth(), r.getHeight());
|
||||||
|
|
||||||
|
{
|
||||||
juce::CriticalSection::ScopedLockType scope(lock);
|
juce::CriticalSection::ScopedLockType scope(lock);
|
||||||
if (buffer.size() > 0) {
|
if (buffer.size() > 0) {
|
||||||
g.setColour(waveformColour);
|
g.setColour(waveformColour);
|
||||||
|
@ -39,6 +40,18 @@ void VisualiserComponent::paint(juce::Graphics& g) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!active) {
|
||||||
|
// add translucent layer
|
||||||
|
g.setColour(juce::Colours::black.withAlpha(0.5f));
|
||||||
|
g.fillRect(getLocalBounds());
|
||||||
|
|
||||||
|
// add text
|
||||||
|
g.setColour(juce::Colours::white);
|
||||||
|
g.setFont(14.0f);
|
||||||
|
g.drawFittedText("Paused", getLocalBounds(), juce::Justification::centred, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void VisualiserComponent::timerCallback() {
|
void VisualiserComponent::timerCallback() {
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
@ -51,6 +64,19 @@ void VisualiserComponent::run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VisualiserComponent::mouseDown(const juce::MouseEvent& event) {
|
||||||
|
active = !active;
|
||||||
|
if (active) {
|
||||||
|
startTimerHz(60);
|
||||||
|
startThread();
|
||||||
|
} else {
|
||||||
|
audioProcessor.consumerStop(consumer);
|
||||||
|
stopTimer();
|
||||||
|
stopThread(1000);
|
||||||
|
}
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
void VisualiserComponent::paintChannel(juce::Graphics& g, juce::Rectangle<float> area, int channel) {
|
void VisualiserComponent::paintChannel(juce::Graphics& g, juce::Rectangle<float> area, int channel) {
|
||||||
juce::Path path;
|
juce::Path path;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "../concurrency/BufferConsumer.h"
|
#include "../concurrency/BufferConsumer.h"
|
||||||
#include "../PluginProcessor.h"
|
#include "../PluginProcessor.h"
|
||||||
|
|
||||||
class VisualiserComponent : public juce::Component, public juce::Timer, public juce::Thread {
|
class VisualiserComponent : public juce::Component, public juce::Timer, public juce::Thread, public juce::MouseListener {
|
||||||
public:
|
public:
|
||||||
VisualiserComponent(int numChannels, OscirenderAudioProcessor& p);
|
VisualiserComponent(int numChannels, OscirenderAudioProcessor& p);
|
||||||
~VisualiserComponent() override;
|
~VisualiserComponent() override;
|
||||||
|
@ -16,6 +16,7 @@ public:
|
||||||
void paint(juce::Graphics&) override;
|
void paint(juce::Graphics&) override;
|
||||||
void timerCallback() override;
|
void timerCallback() override;
|
||||||
void run() override;
|
void run() override;
|
||||||
|
void mouseDown(const juce::MouseEvent& event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
juce::CriticalSection lock;
|
juce::CriticalSection lock;
|
||||||
|
@ -26,6 +27,8 @@ private:
|
||||||
std::vector<float> tempBuffer = std::vector<float>(2 * 4096);
|
std::vector<float> tempBuffer = std::vector<float>(2 * 4096);
|
||||||
int precision = 4;
|
int precision = 4;
|
||||||
|
|
||||||
|
std::atomic<bool> active = true;
|
||||||
|
|
||||||
std::shared_ptr<BufferConsumer> consumer;
|
std::shared_ptr<BufferConsumer> consumer;
|
||||||
|
|
||||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(VisualiserComponent)
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(VisualiserComponent)
|
||||||
|
|
Ładowanie…
Reference in New Issue