From: Huck Boles Date: Sun, 16 Jul 2023 00:44:42 +0000 (-0500) Subject: edited: tick counting function now uses modulo X-Git-Url: https://git.huck.website/?a=commitdiff_plain;h=a48e7af5af70742072fbeadd710fe9d0fadff70e;p=cellseq.git edited: tick counting function now uses modulo --- diff --git a/src/lib.rs b/src/lib.rs index 8e5137b..b0e8530 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -159,7 +159,7 @@ impl Application for CellSeq { Message::HitCount(x) => self.midi.update(x, &self.info), Message::NewMap(m) => { self.map.update(map::Message::Ticked(m.clone())); - let hits = self.mask.tick(m); + let hits = self.mask.tick(m, self.info.voices); return Command::perform(async move { hits }, Message::HitCount); } Message::Tick(_) => { @@ -175,7 +175,7 @@ impl Application for CellSeq { let bytes = self.midi.tick(); let new_map = map.clone(); - let hits = self.mask.tick(map); + let hits = self.mask.tick(map, self.info.voices); let midi = tokio::spawn(async move { for byte in bytes { diff --git a/src/mask.rs b/src/mask.rs index 11e9f24..5c5523e 100644 --- a/src/mask.rs +++ b/src/mask.rs @@ -61,7 +61,7 @@ impl Mask { .into() } - pub fn tick(&mut self, life: CellMap) -> u8 { + pub fn tick(&mut self, life: CellMap, voices: u8) -> u8 { self.hits.clear(); for cell in self.cells.iter() { if life.contains(cell) { @@ -69,7 +69,7 @@ impl Mask { } } - self.hits.len().try_into().unwrap_or(127) + self.hits.len().try_into().unwrap_or(127) % voices } pub fn randomize(&mut self) {