Skip to content

Commit

Permalink
make poly realtime-safe (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
russellmcc authored Feb 11, 2025
1 parent f6f219e commit 3f3077c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rust/poly/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ workspace = true

[dependencies]
conformal_component = { version = "0.0.0", path = "../component" }
arrayvec = "0.7.6"
8 changes: 5 additions & 3 deletions rust/poly/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ pub struct Voice {
expression: NoteExpressionState,
}

const MAX_VOICES: usize = 32;

#[derive(Clone, Debug, PartialEq)]
pub struct State {
voices: Vec<Voice>,
voices: arrayvec::ArrayVec<Voice, MAX_VOICES>,

voices_compress_order_scratch: Vec<(usize, usize)>,
voices_compress_order_scratch: arrayvec::ArrayVec<(usize, usize), MAX_VOICES>,
}

struct EventStreamStep {
Expand Down Expand Up @@ -172,7 +174,7 @@ impl State {
expression: NoteExpressionState::default(),
})
.collect(),
voices_compress_order_scratch: Vec::with_capacity(max_voices),
voices_compress_order_scratch: Default::default(),
}
}

Expand Down

0 comments on commit 3f3077c

Please sign in to comment.