last_row_idx is not out of f32 range anymore and we need to fill all rows because of the gate encoding with 0xF000

This commit is contained in:
Weird Constructor 2021-07-17 06:22:21 +02:00
parent 4bcf1c7531
commit f17e695410
2 changed files with 12 additions and 7 deletions

View file

@ -145,7 +145,7 @@ impl PatternData {
let mut start_idx = 0; let mut start_idx = 0;
let mut end_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 mut break_after_write = false;
let cur_value = let cur_value =
if end_idx == self.rows { if end_idx == self.rows {
@ -191,7 +191,7 @@ impl PatternData {
PatternColType::Note => { PatternColType::Note => {
let mut cur_value = (0.0, 0); 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] { if let Some(new_value) = self.data[row][col] {
cur_value = ( cur_value = (
((new_value as i32 - 69) as f32 * 0.1) / 12.0, ((new_value as i32 - 69) as f32 * 0.1) / 12.0,
@ -208,7 +208,7 @@ impl PatternData {
PatternColType::Step => { PatternColType::Step => {
let mut cur_value = (0.0, 0); 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] { if let Some(new_value) = self.data[row][col] {
cur_value = ( cur_value = (
((new_value & 0xFFF) as f32) / (0xFFF as f32), ((new_value & 0xFFF) as f32) / (0xFFF as f32),
@ -222,7 +222,12 @@ impl PatternData {
} }
}, },
PatternColType::Gate => { 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] = out_col[row] =
if let Some(new_value) = self.data[row][col] { if let Some(new_value) = self.data[row][col] {
(f32::from_bits(new_value as u32), 1) (f32::from_bits(new_value as u32), 1)

View file

@ -80,7 +80,7 @@ impl PatternSequencer {
{ {
let col = &self.data[col][..]; 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; let rows = self.rows;
for ((phase, out), out_gate) in for ((phase, out), out_gate) in
@ -112,7 +112,7 @@ impl PatternSequencer {
{ {
let col = &self.data[col][..]; 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; let rows = self.rows;
for ((phase, out), out_gate) in for ((phase, out), out_gate) in
@ -134,7 +134,7 @@ impl PatternSequencer {
{ {
let col = &self.data[col_idx][..]; 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; let rows = self.rows;
for ((phase, out), out_gate) in for ((phase, out), out_gate) in