]> git.huck.website - cellseq.git/commitdiff
edited: tick counting function now uses modulo
authorHuck Boles <huck@huck.website>
Sun, 16 Jul 2023 00:44:42 +0000 (19:44 -0500)
committerHuck Boles <huck@huck.website>
Sun, 16 Jul 2023 00:44:42 +0000 (19:44 -0500)
src/lib.rs
src/mask.rs

index 8e5137b217e174dc2dd1fdae16eabe0e10f7876d..b0e853026ebfa7d3aee193ed3e308fd14d8eb5b8 100644 (file)
@@ -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 {
index 11e9f245b21fb45333fda807d46a418c3e118d97..5c5523e165ceb4eb9036e7e84322d322b99edbe0 100644 (file)
@@ -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) {