diff --git a/Source/SosciPluginProcessor.cpp b/Source/SosciPluginProcessor.cpp index 3173cf14..30b16b74 100644 --- a/Source/SosciPluginProcessor.cpp +++ b/Source/SosciPluginProcessor.cpp @@ -54,13 +54,16 @@ void SosciAudioProcessor::processBlock(juce::AudioBuffer& buffer, juce::M } // this is the point that the visualiser will draw - threadManager.write(point); + threadManager.write(point, "VisualiserComponent"); - point.scale(volume, volume, volume); + point.scale(volume, volume, 1.0); // clip point.x = juce::jmax(-threshold, juce::jmin(threshold.load(), point.x)); point.y = juce::jmax(-threshold, juce::jmin(threshold.load(), point.y)); + + // this is the point that the volume component will draw (i.e. post scale/clipping) + threadManager.write(point, "VolumeComponent"); if (output.getNumChannels() > 0) { outputArray[0][sample] = point.x; diff --git a/Source/concurrency/AudioBackgroundThread.h b/Source/concurrency/AudioBackgroundThread.h index 5c8e66af..07b6b437 100644 --- a/Source/concurrency/AudioBackgroundThread.h +++ b/Source/concurrency/AudioBackgroundThread.h @@ -5,7 +5,7 @@ #include "BufferConsumer.h" class AudioBackgroundThreadManager; -class AudioBackgroundThread : private juce::Thread { +class AudioBackgroundThread : public juce::Thread { public: AudioBackgroundThread(const juce::String& name, AudioBackgroundThreadManager& manager); ~AudioBackgroundThread() override; diff --git a/Source/concurrency/AudioBackgroundThreadManager.cpp b/Source/concurrency/AudioBackgroundThreadManager.cpp index ed59c1b9..80903d42 100644 --- a/Source/concurrency/AudioBackgroundThreadManager.cpp +++ b/Source/concurrency/AudioBackgroundThreadManager.cpp @@ -22,6 +22,15 @@ void AudioBackgroundThreadManager::write(const OsciPoint& point) { } } +void AudioBackgroundThreadManager::write(const OsciPoint& point, juce::String name) { + juce::SpinLock::ScopedLockType scope(lock); + for (auto& thread : threads) { + if (thread->getThreadName() == name) { + thread->write(point); + } + } +} + void AudioBackgroundThreadManager::prepare(double sampleRate, int samplesPerBlock) { juce::SpinLock::ScopedLockType scope(lock); for (auto& thread : threads) { diff --git a/Source/concurrency/AudioBackgroundThreadManager.h b/Source/concurrency/AudioBackgroundThreadManager.h index dca38082..1f1dd803 100644 --- a/Source/concurrency/AudioBackgroundThreadManager.h +++ b/Source/concurrency/AudioBackgroundThreadManager.h @@ -13,6 +13,7 @@ public: void registerThread(AudioBackgroundThread* thread); void unregisterThread(AudioBackgroundThread* thread); void write(const OsciPoint& point); + void write(const OsciPoint& point, juce::String name); void prepare(double sampleRate, int samplesPerBlock); double sampleRate = 44100.0;