mirror of
https://codeberg.org/armin/trommelkiste.git
synced 2026-09-01 04:10:46 +02:00
Fix track signal indicator sometimes not showing for short samples
Use a latch pattern for trackActive: the audio thread sets it true whenever a voice is active, and the UI timer atomically reads and clears it via exchange(false). This eliminates the race where the flag was cleared at the start of every processBlock, causing the 30Hz timer to miss brief activations from short samples.
This commit is contained in:
parent
e1f36c8569
commit
2cded52eef
3 changed files with 3 additions and 5 deletions
|
|
@ -433,7 +433,7 @@ void TrommelkisteEditor::timerCallback()
|
||||||
const double now = juce::Time::getMillisecondCounterHiRes() / 1000.0;
|
const double now = juce::Time::getMillisecondCounterHiRes() / 1000.0;
|
||||||
for (int i = 0; i < NUM_TRACKS; ++i)
|
for (int i = 0; i < NUM_TRACKS; ++i)
|
||||||
{
|
{
|
||||||
if (proc.trackActive[i])
|
if (proc.trackActive[i].exchange(false))
|
||||||
trackActivatedTime[i] = now;
|
trackActivatedTime[i] = now;
|
||||||
}
|
}
|
||||||
repaint();
|
repaint();
|
||||||
|
|
|
||||||
|
|
@ -57,9 +57,6 @@ void TrommelkisteProcessor::processBlock(juce::AudioBuffer<float>& buffer, juce:
|
||||||
const int numSamples = buffer.getNumSamples();
|
const int numSamples = buffer.getNumSamples();
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
|
|
||||||
for (int i = 0; i < NUM_TRACKS; ++i)
|
|
||||||
trackActive[i] = false;
|
|
||||||
|
|
||||||
// Shuffle: add ghost notes (bar-quantized)
|
// Shuffle: add ghost notes (bar-quantized)
|
||||||
const float globalShuffleAmt = apvts.getRawParameterValue("global_shuffleAmount")->load();
|
const float globalShuffleAmt = apvts.getRawParameterValue("global_shuffleAmount")->load();
|
||||||
const float globalGroove = apvts.getRawParameterValue("global_groove")->load();
|
const float globalGroove = apvts.getRawParameterValue("global_groove")->load();
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#include <juce_audio_processors/juce_audio_processors.h>
|
#include <juce_audio_processors/juce_audio_processors.h>
|
||||||
#include <juce_audio_formats/juce_audio_formats.h>
|
#include <juce_audio_formats/juce_audio_formats.h>
|
||||||
#include <juce_dsp/juce_dsp.h>
|
#include <juce_dsp/juce_dsp.h>
|
||||||
|
#include <atomic>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
static constexpr int NUM_TRACKS = 10;
|
static constexpr int NUM_TRACKS = 10;
|
||||||
|
|
@ -50,7 +51,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
Track tracks[NUM_TRACKS];
|
Track tracks[NUM_TRACKS];
|
||||||
bool trackActive[NUM_TRACKS] = {};
|
std::atomic<bool> trackActive[NUM_TRACKS] = {};
|
||||||
juce::AudioProcessorValueTreeState apvts;
|
juce::AudioProcessorValueTreeState apvts;
|
||||||
|
|
||||||
// Sample library
|
// Sample library
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue