VolumeComponent now visualises the correct audio

pre-release-3
James H Ball 2025-01-07 12:27:39 +00:00
rodzic c31f15afb4
commit 1687a330d8
4 zmienionych plików z 16 dodań i 3 usunięć

Wyświetl plik

@ -54,13 +54,16 @@ void SosciAudioProcessor::processBlock(juce::AudioBuffer<float>& 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;

Wyświetl plik

@ -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;

Wyświetl plik

@ -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) {

Wyświetl plik

@ -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;