Skip to content

Commit 9121927

Browse files
committed
fix cpu
1 parent ba7f8b6 commit 9121927

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ watch:
99

1010
lint:
1111
cargo fmt -- --check --color always
12-
cargo clippy --all-targets --all-features -- -D warnings
12+
cargo clippy --all-targets -- -D warnings
1313

1414
build-wasm:
1515
cargo build --release --target wasm32-unknown-unknown

src/sound.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,17 @@ impl VolumeEnvelope {
6666
}
6767

6868
fn step(&mut self) {
69-
if self.delay > 1 {
70-
self.delay -= 1;
71-
} else if self.delay == 1 {
72-
self.delay = self.period;
73-
if self.goes_up && self.volume < 15 {
74-
self.volume += 1;
75-
} else if !self.goes_up && self.volume > 0 {
76-
self.volume -= 1;
69+
match self.delay {
70+
2.. => self.delay -= 1,
71+
1 => {
72+
self.delay = self.period;
73+
if self.goes_up && self.volume < 15 {
74+
self.volume += 1;
75+
} else if !self.goes_up && self.volume > 0 {
76+
self.volume -= 1;
77+
}
7778
}
79+
_ => {}
7880
}
7981
}
8082
}
@@ -463,6 +465,12 @@ pub struct Sound {
463465
output_period: u32,
464466
}
465467

468+
impl Default for Sound {
469+
fn default() -> Self {
470+
Self::new()
471+
}
472+
}
473+
466474
impl Sound {
467475
pub fn new() -> Sound {
468476
let mut ch1_blip = BlipBuf::new(OUTPUT_SAMPLE_COUNT_U32 * 2);

0 commit comments

Comments
 (0)