significantly improved and more accurate vectorscope

This commit is contained in:
Boof2015
2026-08-16 20:52:50 -04:00
parent 3e95cbfc28
commit 04f254512c
21 changed files with 682 additions and 335 deletions
+3 -26
View File
@@ -22,23 +22,11 @@ Vectorscope::Vectorscope()
highRightBuffer_.resize(VECTORSCOPE_BUFFER_SIZE, 0.0f);
points_.reserve(1024);
// Cascaded lowpass at 8kHz, Butterworth (Q=0.707)
// Two stages per channel = 4th order = 24 dB/oct rolloff
// Removes HF noise that causes erratic Lissajous motion
leftLowpass1_.setLowpass(8000.0f, sampleRate_, 0.707f);
leftLowpass2_.setLowpass(8000.0f, sampleRate_, 0.707f);
rightLowpass1_.setLowpass(8000.0f, sampleRate_, 0.707f);
rightLowpass2_.setLowpass(8000.0f, sampleRate_, 0.707f);
multibandSplitter_.configure(sampleRate_);
}
void Vectorscope::setSampleRate(float sampleRate) {
sampleRate_ = sampleRate;
// Redesign all filters with new sample rate
leftLowpass1_.setLowpass(8000.0f, sampleRate_, 0.707f);
leftLowpass2_.setLowpass(8000.0f, sampleRate_, 0.707f);
rightLowpass1_.setLowpass(8000.0f, sampleRate_, 0.707f);
rightLowpass2_.setLowpass(8000.0f, sampleRate_, 0.707f);
multibandSplitter_.configure(sampleRate_);
}
@@ -53,15 +41,8 @@ void Vectorscope::pushSamples(
size_t length
) {
for (size_t i = 0; i < length; i++) {
// Apply cascaded lowpass filtering
float filteredL = leftLowpass1_.process(leftChannel[i]);
filteredL = leftLowpass2_.process(filteredL);
float filteredR = rightLowpass1_.process(rightChannel[i]);
filteredR = rightLowpass2_.process(filteredR);
leftBuffer_[writePos_] = filteredL;
rightBuffer_[writePos_] = filteredR;
leftBuffer_[writePos_] = leftChannel[i];
rightBuffer_[writePos_] = rightChannel[i];
writePos_ = (writePos_ + 1) % VECTORSCOPE_BUFFER_SIZE;
if (validSamples_ < VECTORSCOPE_BUFFER_SIZE) {
@@ -128,7 +109,7 @@ const std::vector<VectorscopePoint>& Vectorscope::process(
const float* rightChannel,
size_t length
) {
// Push through the filtering pipeline
// Push through the full-band point pipeline
pushSamples(leftChannel, rightChannel, length);
// Build legacy output from buffer
@@ -157,10 +138,6 @@ void Vectorscope::reset() {
std::fill(midRightBuffer_.begin(), midRightBuffer_.end(), 0.0f);
std::fill(highLeftBuffer_.begin(), highLeftBuffer_.end(), 0.0f);
std::fill(highRightBuffer_.begin(), highRightBuffer_.end(), 0.0f);
leftLowpass1_.reset();
leftLowpass2_.reset();
rightLowpass1_.reset();
rightLowpass2_.reset();
multibandSplitter_.reset();
points_.clear();
}
+1 -7
View File
@@ -1,6 +1,5 @@
#pragma once
#include "dsp_utils.h"
#include "multiband.h"
#include <vector>
#include <cstddef>
@@ -52,7 +51,7 @@ private:
size_t writePos_;
size_t validSamples_;
// Circular buffers for filtered L/R
// Circular buffers for full-band L/R
std::vector<float> leftBuffer_;
std::vector<float> rightBuffer_;
std::vector<float> lowLeftBuffer_;
@@ -62,11 +61,6 @@ private:
std::vector<float> highLeftBuffer_;
std::vector<float> highRightBuffer_;
// Cascaded lowpass filters (4th order Butterworth at 8kHz per channel)
DSP::BiquadFilter leftLowpass1_;
DSP::BiquadFilter leftLowpass2_;
DSP::BiquadFilter rightLowpass1_;
DSP::BiquadFilter rightLowpass2_;
MultibandSplitter multibandSplitter_;
size_t multibandWritePos_;
size_t multibandValidSamples_;