Skip to content

Commit

Permalink
Add a test demonstrating surge-synthesizer#7570
Browse files Browse the repository at this point in the history
This regtest shows exactly the problem with BLIT oscillators
with non-retrigger behavior missing the first part of the cycle.

Addresses surge-synthesizer#7570 and will be key to finding the fix.
  • Loading branch information
baconpaul committed Mar 13, 2024
1 parent 73bd2a7 commit 8b19be9
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/surge-testrunner/UnitTestsDSP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,4 +769,53 @@ TEST_CASE("Reverb1 White Noise Blast", "[dsp]")
}
since++;
}
}

TEST_CASE("Oscillator Onset", "[dsp]") // See issue 7570
{
for (const auto &rt : {true, false})
{
for (const auto &ot :
{ot_classic, ot_wavetable, ot_window, ot_sine, ot_twist, ot_shnoise, ot_FM2, ot_FM3})
{
auto surge = Surge::Headless::createSurge(44100, ot == ot_wavetable || ot == ot_window);
auto storage = &surge->storage;

auto oscstorage = &(storage->getPatch().scene[0].osc[0]);

unsigned char oscbuffer alignas(16)[oscillator_buffer_size];

oscstorage->retrigger.val.b = rt;

auto o =
spawn_osc(ot, storage, oscstorage, storage->getPatch().scenedata[0], oscbuffer);
o->init_ctrltypes();
o->init_default_values();
o->init_extra_config();

o->init(60);

int itUntilBigger{0};
bool continueChecking{true};

for (int j = 0; j < 10 && continueChecking; ++j)
{
o->process_block(60, 0, true, false, 0);
for (int i = 0; i < BLOCK_SIZE_OS && continueChecking; ++i)
{
itUntilBigger++;
if (std::fabs(o->output[i]) > 1e-6)
{
continueChecking = false;
break;
}
}
}
o->~Oscillator();
/*std::cout << "Onset Delay for " << osc_type_names[ot] << " with retrig=" << rt << " is
"
<< (continueChecking ? "Unknown" : std::to_string(itUntilBigger))
<< std::endl;*/
}
}
}

0 comments on commit 8b19be9

Please sign in to comment.