Skip to content

Commit

Permalink
Display the OSC output *post* HalfRateFilter (#7158)
Browse files Browse the repository at this point in the history
that HalfRateFilter covers a few sins that our averaging
technique didn't. With this change in place, the noisy
curves from the edges of extrreme feedback render just like
they do in a scop.

Remember to port this to rack also.

Closes #7154
  • Loading branch information
baconpaul authored Aug 9, 2023
1 parent 380ffbf commit f097ca0
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/surge-xt/gui/widgets/OscillatorWaveformDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void OscillatorWaveformDisplay::paint(juce::Graphics &g)
return;
}

int totalSamples = (1 << 4) * (int)getWidth();
int totalSamples = (1 << 3) * (int)getWidth();
int averagingWindow = 4; // < and Mult of BlockSizeOS
float disp_pitch_rs = disp_pitch + 12.0 * log2(storage->dsamplerate / 44100.0);

Expand Down Expand Up @@ -209,16 +209,24 @@ void OscillatorWaveformDisplay::paint(juce::Graphics &g)
osc->init(disp_pitch_rs, true, true);
}

int block_pos = BLOCK_SIZE_OS;
int block_pos = BLOCK_SIZE;
juce::Path wavePath;

float oscTmp alignas(16)[2][BLOCK_SIZE_OS];
sst::filters::HalfRate::HalfRateFilter hr(6, true);
hr.load_coefficients();
hr.reset();

for (int i = 0; i < totalSamples; i += averagingWindow)
{
if (use_display && block_pos >= BLOCK_SIZE_OS)
if (use_display && block_pos >= BLOCK_SIZE)
{
// Lock it even if we aren't wavetable. It's fine.
storage->waveTableDataMutex.lock();
osc->process_block(disp_pitch_rs);
memcpy(oscTmp[0], osc->output, sizeof(oscTmp[0]));
memcpy(oscTmp[1], osc->output, sizeof(oscTmp[1]));
hr.process_block_D2(oscTmp[0], oscTmp[1], BLOCK_SIZE_OS);
block_pos = 0;
storage->waveTableDataMutex.unlock();
}
Expand All @@ -229,7 +237,7 @@ void OscillatorWaveformDisplay::paint(juce::Graphics &g)
{
for (int j = 0; j < averagingWindow; ++j)
{
val += osc->output[block_pos];
val += oscTmp[0][block_pos];
block_pos++;
}

Expand Down

0 comments on commit f097ca0

Please sign in to comment.