Skip to content

like u8.unchecked_sub() but w/o nightly experimental API #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/envelope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl EnvelopeGenerator {
self.rate_counter = 0;
// The first envelope step in the attack state also resets the exponential
// counter. This has been verified by sampling ENV3.
self.exponential_counter += 1; // TODO check w/ ref impl
self.exponential_counter += 1;
if self.state == State::Attack
|| self.exponential_counter == self.exponential_counter_period
{
Expand Down Expand Up @@ -234,7 +234,13 @@ impl EnvelopeGenerator {
// counting down in the release state.
// This has been verified by sampling ENV3.
// NB! The operation below requires two's complement integer.
self.envelope_counter -= 1;
if self.envelope_counter != 0 {
self.envelope_counter -= 1;
} else {
self.exponential_counter_period = 1;
self.hold_zero = true;
}

}
}
// Check for change of exponential counter period.
Expand Down