Repository navigation
Initialize oscillator history and AD envelope trigger state - #220
Open
dajiaohuang wants to merge 1 commit into
Open
dajiaohuang wants to merge 1 commit into
dajiaohuang wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Initialize the processing history that
Oscillator::InitandAdEnv::Initcurrently leave untouched.Oscillator::Processreadslast_out_forWAVE_POLYBLEP_TRI, butInitnever assigns it. Automatic-storage oscillators can therefore read indeterminate history. Reinitializing an oscillator that has already processed a triangle also retains its previous integrator output, despite resetting its phase. Initialize that history to zero; phase-onlyResetbehavior is unchanged.AdEnv::Processreadstrigger_andprev_segment_before assigning them. Initialize both so that the documented idle initial state does not depend on prior storage or a pending trigger. Fixes AdEnv does not initialize the "trigger_" data member, causing the envelope to trigger on the first call to Process () #212.Only the missing state assignments change; parameters, waveform algorithms, and public interfaces are unchanged.
Testing
tests/initialization. It uses ordinary public calls and static initial storage, without depending on arbitrary uninitialized-memory contents. At 44.1, 48, and 96 kHz it processes a triangle, callsInitagain, and checks that the first sample is zero, as follows from the phase-zero polyBLEP input and zero integrator history. It also callsTrigger, reinitializes the AD envelope, and verifies idle output without another trigger.2c72eaf, the regression fails both cases at all three rates: the oscillator retains nonzero output, and the envelope enters attack with output0.0001. With this change it passes. The fixed regression also passes AddressSanitizer and UndefinedBehaviorSanitizer.util/fix_style.sh; retained only relevant changes. Local formatter is the Visual Studio bundled version, not CI's pinned clang-format 10.No audio devices, playback, firmware flashing, or benchmarks were used. ARM cross-build and physical Daisy hardware acceptance were not run locally; these host checks do not substitute for them. No native Windows default-build fix is included (tracked separately in #197).
Demos / Example Code
tests/initialization/tst_initialization.cppis an offline public-API example and regression; it does not require libDaisy.Suggested label: bug (I do not have repository label-assignment permissions).