kopia lustrzana https://github.com/jameshball/osci-render
Fix issues with enabling blocked rendering
rodzic
e40356e71a
commit
40423b400c
|
@ -54,7 +54,7 @@ public:
|
||||||
|
|
||||||
VisualiserSettings visualiserSettings = VisualiserSettings(audioProcessor.visualiserParameters);
|
VisualiserSettings visualiserSettings = VisualiserSettings(audioProcessor.visualiserParameters);
|
||||||
SettingsWindow visualiserSettingsWindow = SettingsWindow("Visualiser Settings");
|
SettingsWindow visualiserSettingsWindow = SettingsWindow("Visualiser Settings");
|
||||||
VisualiserComponent visualiser{audioProcessor.threadManager, visualiserSettings, nullptr};
|
VisualiserComponent visualiser{audioProcessor.haltRecording, audioProcessor.threadManager, visualiserSettings, nullptr};
|
||||||
|
|
||||||
SettingsComponent settings{audioProcessor, *this};
|
SettingsComponent settings{audioProcessor, *this};
|
||||||
|
|
||||||
|
|
|
@ -776,6 +776,14 @@ juce::AudioProcessorEditor* OscirenderAudioProcessor::createEditor() {
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
void OscirenderAudioProcessor::getStateInformation(juce::MemoryBlock& destData) {
|
void OscirenderAudioProcessor::getStateInformation(juce::MemoryBlock& destData) {
|
||||||
|
// we need to stop recording the visualiser when saving the state, otherwise
|
||||||
|
// there are issues. This is the only place we can do this because there is
|
||||||
|
// no callback when closing the standalone app except for this.
|
||||||
|
|
||||||
|
if (haltRecording != nullptr && juce::JUCEApplicationBase::isStandaloneApp()) {
|
||||||
|
haltRecording();
|
||||||
|
}
|
||||||
|
|
||||||
juce::SpinLock::ScopedLockType lock1(parsersLock);
|
juce::SpinLock::ScopedLockType lock1(parsersLock);
|
||||||
juce::SpinLock::ScopedLockType lock2(effectsLock);
|
juce::SpinLock::ScopedLockType lock2(effectsLock);
|
||||||
|
|
||||||
|
|
|
@ -240,6 +240,8 @@ public:
|
||||||
|
|
||||||
ShapeSound::Ptr objectServerSound = new ShapeSound();
|
ShapeSound::Ptr objectServerSound = new ShapeSound();
|
||||||
|
|
||||||
|
std::function<void()> haltRecording;
|
||||||
|
|
||||||
void addLuaSlider();
|
void addLuaSlider();
|
||||||
void updateEffectPrecedence();
|
void updateEffectPrecedence();
|
||||||
void updateFileBlock(int index, std::shared_ptr<juce::MemoryBlock> block);
|
void updateFileBlock(int index, std::shared_ptr<juce::MemoryBlock> block);
|
||||||
|
|
|
@ -14,22 +14,23 @@ class StopwatchComponent : public juce::Component, public juce::Timer {
|
||||||
}
|
}
|
||||||
|
|
||||||
void start() {
|
void start() {
|
||||||
startTime = juce::Time::getCurrentTime();
|
|
||||||
startTimerHz(60);
|
startTimerHz(60);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void addTime(juce::RelativeTime time) {
|
||||||
|
elapsedTime += time;
|
||||||
|
}
|
||||||
|
|
||||||
void stop() {
|
void stop() {
|
||||||
stopTimer();
|
stopTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
startTime = juce::Time::getCurrentTime();
|
elapsedTime = juce::RelativeTime();
|
||||||
timerCallback();
|
timerCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
void timerCallback() override {
|
void timerCallback() override {
|
||||||
juce::Time currentTime = juce::Time::getCurrentTime();
|
|
||||||
juce::RelativeTime elapsedTime = currentTime - startTime;
|
|
||||||
int hours = elapsedTime.inHours();
|
int hours = elapsedTime.inHours();
|
||||||
int minutes = (int) elapsedTime.inMinutes() % 60;
|
int minutes = (int) elapsedTime.inMinutes() % 60;
|
||||||
int seconds = (int) elapsedTime.inSeconds() % 60;
|
int seconds = (int) elapsedTime.inSeconds() % 60;
|
||||||
|
@ -45,7 +46,7 @@ class StopwatchComponent : public juce::Component, public juce::Timer {
|
||||||
private:
|
private:
|
||||||
|
|
||||||
juce::Label label;
|
juce::Label label;
|
||||||
juce::Time startTime;
|
juce::RelativeTime elapsedTime;
|
||||||
|
|
||||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(StopwatchComponent)
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(StopwatchComponent)
|
||||||
};
|
};
|
||||||
|
|
|
@ -111,7 +111,12 @@ public:
|
||||||
sema.release();
|
sema.release();
|
||||||
} else {
|
} else {
|
||||||
OsciPoint item;
|
OsciPoint item;
|
||||||
|
// We dequeue an item so that the audio thread is unblocked
|
||||||
|
// if it's trying to wait until the queue is no longer full.
|
||||||
queue->try_dequeue(item);
|
queue->try_dequeue(item);
|
||||||
|
// We enqueue an item so that the consumer is unblocked
|
||||||
|
// if it's trying to wait until the queue is no longer empty.
|
||||||
|
queue->try_enqueue(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,12 +11,16 @@
|
||||||
#include "TexturedFragmentShader.glsl"
|
#include "TexturedFragmentShader.glsl"
|
||||||
#include "TexturedVertexShader.glsl"
|
#include "TexturedVertexShader.glsl"
|
||||||
|
|
||||||
VisualiserComponent::VisualiserComponent(AudioBackgroundThreadManager& threadManager, VisualiserSettings& settings, VisualiserComponent* parent, bool visualiserOnly) : settings(settings), threadManager(threadManager), visualiserOnly(visualiserOnly), AudioBackgroundThread("VisualiserComponent", threadManager), parent(parent) {
|
VisualiserComponent::VisualiserComponent(std::function<void()>& haltRecording, AudioBackgroundThreadManager& threadManager, VisualiserSettings& settings, VisualiserComponent* parent, bool visualiserOnly) : haltRecording(haltRecording), settings(settings), threadManager(threadManager), visualiserOnly(visualiserOnly), AudioBackgroundThread("VisualiserComponent" + juce::String(parent != nullptr ? " Child" : ""), threadManager), parent(parent) {
|
||||||
|
|
||||||
|
haltRecording = [this] {
|
||||||
|
setRecording(false);
|
||||||
|
};
|
||||||
|
|
||||||
addAndMakeVisible(record);
|
addAndMakeVisible(record);
|
||||||
record.setPulseAnimation(true);
|
record.setPulseAnimation(true);
|
||||||
record.onClick = [this] {
|
record.onClick = [this] {
|
||||||
toggleRecording();
|
setRecording(record.getToggleState());
|
||||||
stopwatch.stop();
|
stopwatch.stop();
|
||||||
stopwatch.reset();
|
stopwatch.reset();
|
||||||
|
|
||||||
|
@ -61,6 +65,10 @@ VisualiserComponent::VisualiserComponent(AudioBackgroundThreadManager& threadMan
|
||||||
}
|
}
|
||||||
|
|
||||||
VisualiserComponent::~VisualiserComponent() {
|
VisualiserComponent::~VisualiserComponent() {
|
||||||
|
setRecording(false);
|
||||||
|
if (parent == nullptr) {
|
||||||
|
haltRecording = nullptr;
|
||||||
|
}
|
||||||
openGLContext.detach();
|
openGLContext.detach();
|
||||||
setShouldBeRunning(false, [this] {
|
setShouldBeRunning(false, [this] {
|
||||||
renderingSemaphore.release();
|
renderingSemaphore.release();
|
||||||
|
@ -137,7 +145,7 @@ void VisualiserComponent::setPaused(bool paused) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualiserComponent::mouseDown(const juce::MouseEvent& event) {
|
void VisualiserComponent::mouseDown(const juce::MouseEvent& event) {
|
||||||
if (event.mods.isLeftButtonDown() && child == nullptr) {
|
if (event.mods.isLeftButtonDown() && child == nullptr && !record.getToggleState()) {
|
||||||
setPaused(active);
|
setPaused(active);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -155,12 +163,12 @@ bool VisualiserComponent::keyPressed(const juce::KeyPress& key) {
|
||||||
|
|
||||||
void VisualiserComponent::setFullScreen(bool fullScreen) {}
|
void VisualiserComponent::setFullScreen(bool fullScreen) {}
|
||||||
|
|
||||||
void VisualiserComponent::toggleRecording() {
|
void VisualiserComponent::setRecording(bool recording) {
|
||||||
setBlockOnAudioThread(record.getToggleState());
|
record.setToggleState(recording, juce::NotificationType::dontSendNotification);
|
||||||
}
|
if (recording) {
|
||||||
|
setPaused(false);
|
||||||
void VisualiserComponent::haltRecording() {
|
}
|
||||||
record.setToggleState(false, juce::NotificationType::dontSendNotification);
|
setBlockOnAudioThread(recording);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualiserComponent::resized() {
|
void VisualiserComponent::resized() {
|
||||||
|
@ -185,12 +193,12 @@ void VisualiserComponent::resized() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualiserComponent::popoutWindow() {
|
void VisualiserComponent::popoutWindow() {
|
||||||
haltRecording();
|
setRecording(false);
|
||||||
auto visualiser = new VisualiserComponent(threadManager, settings, this);
|
record.setEnabled(false);
|
||||||
|
auto visualiser = new VisualiserComponent(haltRecording, threadManager, settings, this);
|
||||||
visualiser->settings.setLookAndFeel(&getLookAndFeel());
|
visualiser->settings.setLookAndFeel(&getLookAndFeel());
|
||||||
visualiser->openSettings = openSettings;
|
visualiser->openSettings = openSettings;
|
||||||
visualiser->closeSettings = closeSettings;
|
visualiser->closeSettings = closeSettings;
|
||||||
visualiser->recordingHalted = recordingHalted;
|
|
||||||
child = visualiser;
|
child = visualiser;
|
||||||
childUpdated();
|
childUpdated();
|
||||||
visualiser->setSize(300, 325);
|
visualiser->setSize(300, 325);
|
||||||
|
@ -206,6 +214,17 @@ void VisualiserComponent::popoutWindow() {
|
||||||
|
|
||||||
void VisualiserComponent::childUpdated() {
|
void VisualiserComponent::childUpdated() {
|
||||||
popOutButton.setVisible(child == nullptr);
|
popOutButton.setVisible(child == nullptr);
|
||||||
|
record.setEnabled(child == nullptr);
|
||||||
|
if (child != nullptr) {
|
||||||
|
haltRecording = [this] {
|
||||||
|
setRecording(false);
|
||||||
|
child->setRecording(false);
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
haltRecording = [this] {
|
||||||
|
setRecording(false);
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualiserComponent::newOpenGLContextCreated() {
|
void VisualiserComponent::newOpenGLContextCreated() {
|
||||||
|
@ -295,6 +314,7 @@ void VisualiserComponent::renderOpenGL() {
|
||||||
renderScope(xSamples, ySamples, zSamples);
|
renderScope(xSamples, ySamples, zSamples);
|
||||||
}
|
}
|
||||||
renderingSemaphore.release();
|
renderingSemaphore.release();
|
||||||
|
stopwatch.addTime(juce::RelativeTime::seconds(1.0 / FRAME_RATE));
|
||||||
}
|
}
|
||||||
|
|
||||||
// render texture to screen
|
// render texture to screen
|
||||||
|
|
|
@ -28,7 +28,7 @@ struct Texture {
|
||||||
class VisualiserWindow;
|
class VisualiserWindow;
|
||||||
class VisualiserComponent : public juce::Component, public AudioBackgroundThread, public juce::MouseListener, public juce::OpenGLRenderer, public juce::AsyncUpdater {
|
class VisualiserComponent : public juce::Component, public AudioBackgroundThread, public juce::MouseListener, public juce::OpenGLRenderer, public juce::AsyncUpdater {
|
||||||
public:
|
public:
|
||||||
VisualiserComponent(AudioBackgroundThreadManager& threadManager, VisualiserSettings& settings, VisualiserComponent* parent = nullptr, bool visualiserOnly = false);
|
VisualiserComponent(std::function<void()>& haltRecording, AudioBackgroundThreadManager& threadManager, VisualiserSettings& settings, VisualiserComponent* parent = nullptr, bool visualiserOnly = false);
|
||||||
~VisualiserComponent() override;
|
~VisualiserComponent() override;
|
||||||
|
|
||||||
std::function<void()> openSettings;
|
std::function<void()> openSettings;
|
||||||
|
@ -49,8 +49,7 @@ public:
|
||||||
void renderOpenGL() override;
|
void renderOpenGL() override;
|
||||||
void openGLContextClosing() override;
|
void openGLContextClosing() override;
|
||||||
void setFullScreen(bool fullScreen);
|
void setFullScreen(bool fullScreen);
|
||||||
void toggleRecording();
|
void setRecording(bool recording);
|
||||||
void haltRecording();
|
|
||||||
void childUpdated();
|
void childUpdated();
|
||||||
|
|
||||||
VisualiserComponent* parent = nullptr;
|
VisualiserComponent* parent = nullptr;
|
||||||
|
@ -59,13 +58,12 @@ public:
|
||||||
|
|
||||||
std::atomic<bool> active = true;
|
std::atomic<bool> active = true;
|
||||||
|
|
||||||
std::function<void()> recordingHalted;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float intensity;
|
float intensity;
|
||||||
const double FRAME_RATE = 60.0;
|
const double FRAME_RATE = 60.0;
|
||||||
|
|
||||||
bool visualiserOnly;
|
bool visualiserOnly;
|
||||||
|
std::function<void()>& haltRecording;
|
||||||
|
|
||||||
AudioBackgroundThreadManager& threadManager;
|
AudioBackgroundThreadManager& threadManager;
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue