From f17e695410f0d292a3138df7024ccb425230a094 Mon Sep 17 00:00:00 2001 From: Weird Constructor Date: Sat, 17 Jul 2021 06:22:21 +0200 Subject: [PATCH] last_row_idx is not out of f32 range anymore and we need to fill all rows because of the gate encoding with 0xF000 --- src/dsp/tracker/pattern.rs | 13 +++++++++---- src/dsp/tracker/sequencer.rs | 6 +++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/dsp/tracker/pattern.rs b/src/dsp/tracker/pattern.rs index b98c246..09de2ba 100644 --- a/src/dsp/tracker/pattern.rs +++ b/src/dsp/tracker/pattern.rs @@ -145,7 +145,7 @@ impl PatternData { let mut start_idx = 0; let mut end_idx = 0; - while end_idx <= self.rows { + while end_idx <= out_col.len() { let mut break_after_write = false; let cur_value = if end_idx == self.rows { @@ -191,7 +191,7 @@ impl PatternData { PatternColType::Note => { let mut cur_value = (0.0, 0); - for row in 0..self.rows { + for row in 0..out_col.len() { if let Some(new_value) = self.data[row][col] { cur_value = ( ((new_value as i32 - 69) as f32 * 0.1) / 12.0, @@ -208,7 +208,7 @@ impl PatternData { PatternColType::Step => { let mut cur_value = (0.0, 0); - for row in 0..self.rows { + for row in 0..out_col.len() { if let Some(new_value) = self.data[row][col] { cur_value = ( ((new_value & 0xFFF) as f32) / (0xFFF as f32), @@ -222,7 +222,12 @@ impl PatternData { } }, PatternColType::Gate => { - for row in 0..self.rows { + // XXX: We need to iterate over all rows, even if + // self.rows < out_col.len(), because empty cells + // are not equal to float 0.0. Maybe we should change + // this internal format!? But in either case we transmit + // a full row to the backend anyways. + for row in 0..out_col.len() { out_col[row] = if let Some(new_value) = self.data[row][col] { (f32::from_bits(new_value as u32), 1) diff --git a/src/dsp/tracker/sequencer.rs b/src/dsp/tracker/sequencer.rs index 4e4065c..f404983 100644 --- a/src/dsp/tracker/sequencer.rs +++ b/src/dsp/tracker/sequencer.rs @@ -80,7 +80,7 @@ impl PatternSequencer { { let col = &self.data[col][..]; - let last_row_idx : f32 = (self.rows as f32) - 0.000001; + let last_row_idx : f32 = (self.rows as f32) - 0.00001; let rows = self.rows; for ((phase, out), out_gate) in @@ -112,7 +112,7 @@ impl PatternSequencer { { let col = &self.data[col][..]; - let last_row_idx : f32 = (self.rows as f32) - 0.000001; + let last_row_idx : f32 = (self.rows as f32) - 0.00001; let rows = self.rows; for ((phase, out), out_gate) in @@ -134,7 +134,7 @@ impl PatternSequencer { { let col = &self.data[col_idx][..]; - let last_row_idx : f32 = (self.rows as f32) - 0.000001; + let last_row_idx : f32 = (self.rows as f32) - 0.00001; let rows = self.rows; for ((phase, out), out_gate) in