From c35cc57d55081da6415295d13f0c56fe699efe2b Mon Sep 17 00:00:00 2001 From: David Huss <dh@atoav.com> Date: Sun, 5 Sep 2021 11:27:27 +0200 Subject: [PATCH] Support Buffersizes other than 1024, read more This adds support for buffersizes <= 1024. It comes with a few gotchas: - To keep the arrays on the stack there is always a size of 1024 allocated on the stack, but only the parts for the buffer are used - Sizes bigger than 1024 are not currently supported --- src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 893d060..23ee874 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,7 +19,7 @@ TODO: - [ ] f32.mul_add() or f32.to_bits() / f32.from_bits() - [ ] only calculate connected ports https://docs.rs/jack/0.7.1/jack/struct.Port.html#method.connected_count - [ ] Flag volume modulations as dirty -- [ ] Support other Buffers than 1024 +- [x] Support other Buffers than 1024 - [ ] Features: - [ ] Flags to control printing (--quiet etc) - [ ] Option to set initial values @@ -125,6 +125,8 @@ fn main() { jack::AudioOut::default()) .unwrap(); 16]; + + let buffersize = client.buffer_size() as usize; // Is called asynchronously. Moves/mixes the actual audio samples from A to be let process_callback = move |_: &jack::Client, ps: &jack::ProcessScope| -> jack::Control { @@ -141,9 +143,11 @@ fn main() { // Sum each input to output buffer output_buffers.iter_mut() + .take(buffersize) .enumerate() .for_each(|(output_index, b)| { b.iter_mut() + .take(buffersize) .enumerate() .for_each(|(sample_index, sample)| { // For each input get the corrsponding atomic value for the volume control -- GitLab