settings, toggles, and more

This commit is contained in:
Boof2015
2026-08-14 19:02:26 -04:00
parent e712421bad
commit c45451476d
17 changed files with 2144 additions and 66 deletions
+7
View File
@@ -12,6 +12,7 @@ Oscilloscope::Oscilloscope()
, lastFilterPitch_(200.0f)
, lastTrigger_(0)
, smoothedPitch_(200.0f)
, latestDetectedPitch_(0.0f)
, pitchSamplesProcessed_(0) {
// Initialize circular buffers
@@ -144,6 +145,10 @@ OscilloscopeResult Oscilloscope::process() {
result.detectedPitch = smoothedPitch_;
if (!pitchLock_) {
const size_t samples = static_cast<size_t>(displaySamples_);
result.triggerIndex = static_cast<float>(
(writePos_ + OSCILLOSCOPE_BUFFER_SIZE - samples) %
OSCILLOSCOPE_BUFFER_SIZE);
return result;
}
@@ -172,6 +177,7 @@ OscilloscopeResult Oscilloscope::process() {
float newPitch = DSP::detectPitchFFT(recentSamples.data(), 2048, sampleRate_, 40.0f, 1000.0f);
if (newPitch > 0.0f) {
latestDetectedPitch_ = newPitch;
pitchSamplesProcessed_++;
// Adaptive smoothing: fast convergence initially, then conservative
@@ -307,6 +313,7 @@ void Oscilloscope::reset() {
writePos_ = 0;
lastTrigger_ = 0.0f;
smoothedPitch_ = 200.0f;
latestDetectedPitch_ = 0.0f;
lastFilterPitch_ = 200.0f;
pitchSamplesProcessed_ = 0; // Reset warmup counter for fast convergence on next use
+5
View File
@@ -36,6 +36,10 @@ public:
// Get current write position
size_t getWritePos() const { return writePos_; }
// Latest unsmoothed detector result. The stable detectedPitch returned by
// process() remains the value used for pitch-locked triggering.
float getLatestDetectedPitch() const { return latestDetectedPitch_; }
// Get samples from circular buffer (for rendering)
void getSamples(float* output, size_t startPos, size_t count) const;
@@ -75,6 +79,7 @@ private:
float lastTrigger_;
float smoothedPitch_;
float latestDetectedPitch_;
int pitchSamplesProcessed_; // Track samples for adaptive smoothing
// Internal helpers