Skip to content
Snippets Groups Projects
Commit e7c4658f authored by David Huss's avatar David Huss :speech_balloon:
Browse files

Parallel iteration on output buffers

parent 3302efc3
No related branches found
No related tags found
No related merge requests found
...@@ -89,6 +89,56 @@ dependencies = [ ...@@ -89,6 +89,56 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "crossbeam-channel"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4"
dependencies = [
"cfg-if",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-deque"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e"
dependencies = [
"cfg-if",
"crossbeam-epoch",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-epoch"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd"
dependencies = [
"cfg-if",
"crossbeam-utils",
"lazy_static",
"memoffset",
"scopeguard",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db"
dependencies = [
"cfg-if",
"lazy_static",
]
[[package]]
name = "either"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.11.2" version = "0.11.2"
...@@ -121,6 +171,7 @@ dependencies = [ ...@@ -121,6 +171,7 @@ dependencies = [
"clap", "clap",
"jack", "jack",
"libc", "libc",
"rayon",
"rosc", "rosc",
] ]
...@@ -179,6 +230,25 @@ dependencies = [ ...@@ -179,6 +230,25 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "memoffset"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9"
dependencies = [
"autocfg",
]
[[package]]
name = "num_cpus"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3"
dependencies = [
"hermit-abi",
"libc",
]
[[package]] [[package]]
name = "os_str_bytes" name = "os_str_bytes"
version = "3.1.0" version = "3.1.0"
...@@ -233,6 +303,31 @@ dependencies = [ ...@@ -233,6 +303,31 @@ dependencies = [
"proc-macro2", "proc-macro2",
] ]
[[package]]
name = "rayon"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90"
dependencies = [
"autocfg",
"crossbeam-deque",
"either",
"rayon-core",
]
[[package]]
name = "rayon-core"
version = "1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e"
dependencies = [
"crossbeam-channel",
"crossbeam-deque",
"crossbeam-utils",
"lazy_static",
"num_cpus",
]
[[package]] [[package]]
name = "rosc" name = "rosc"
version = "0.5.2" version = "0.5.2"
...@@ -242,6 +337,12 @@ dependencies = [ ...@@ -242,6 +337,12 @@ dependencies = [
"byteorder", "byteorder",
] ]
[[package]]
name = "scopeguard"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]] [[package]]
name = "strsim" name = "strsim"
version = "0.10.0" version = "0.10.0"
......
...@@ -11,5 +11,6 @@ description = "A 16×16 channel matrix mixer for Jack, controllable via OSC" ...@@ -11,5 +11,6 @@ description = "A 16×16 channel matrix mixer for Jack, controllable via OSC"
jack = "0.7" jack = "0.7"
libc = "0.2" libc = "0.2"
rosc = "~0.5" rosc = "~0.5"
rayon ="1.5"
arr_macro = "0.1.3" arr_macro = "0.1.3"
clap = { version = "3.0.0-beta.2", features = ["color", "suggestions"] } clap = { version = "3.0.0-beta.2", features = ["color", "suggestions"] }
...@@ -10,6 +10,7 @@ use std::str::FromStr; ...@@ -10,6 +10,7 @@ use std::str::FromStr;
use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::atomic::{AtomicUsize, Ordering};
use arr_macro::arr; use arr_macro::arr;
use clap::{Arg, App}; use clap::{Arg, App};
use rayon::prelude::*;
/* /*
TODO: TODO:
...@@ -148,8 +149,7 @@ fn main() { ...@@ -148,8 +149,7 @@ fn main() {
let input_samples = inport.as_slice(ps); let input_samples = inport.as_slice(ps);
// Sum each input to output buffer // Sum each input to output buffer
output_buffers.iter_mut() output_buffers.par_iter_mut()
.take(buffersize)
.enumerate() .enumerate()
.filter(|(output_index, _buffer)| { .filter(|(output_index, _buffer)| {
match outputs[*output_index].connected_count() { match outputs[*output_index].connected_count() {
...@@ -158,7 +158,7 @@ fn main() { ...@@ -158,7 +158,7 @@ fn main() {
} }
}) })
.for_each(|(output_index, b)| { .for_each(|(output_index, b)| {
b.iter_mut() b.par_iter_mut()
.take(buffersize) .take(buffersize)
.enumerate() .enumerate()
.for_each(|(sample_index, sample)| { .for_each(|(sample_index, sample)| {
...@@ -199,7 +199,7 @@ fn main() { ...@@ -199,7 +199,7 @@ fn main() {
outputs.iter_mut() outputs.iter_mut()
.enumerate() .enumerate()
.for_each(|(output_index, outport)| { .for_each(|(output_index, outport)| {
outport.as_mut_slice(ps).clone_from_slice(&output_buffers[output_index]); outport.as_mut_slice(ps).clone_from_slice(&output_buffers[output_index][..buffersize]);
}); });
jack::Control::Continue jack::Control::Continue
}; };
...@@ -337,8 +337,8 @@ impl jack::NotificationHandler for Notifications { ...@@ -337,8 +337,8 @@ impl jack::NotificationHandler for Notifications {
// ); // );
} }
fn sample_rate(&mut self, _: &jack::Client, srate: jack::Frames) -> jack::Control { fn sample_rate(&mut self, _: &jack::Client, _srate: jack::Frames) -> jack::Control {
println!("JACK: sample rate changed to {}", srate); // println!("JACK: sample rate changed to {}", srate);
jack::Control::Continue jack::Control::Continue
} }
...@@ -401,13 +401,13 @@ impl jack::NotificationHandler for Notifications { ...@@ -401,13 +401,13 @@ impl jack::NotificationHandler for Notifications {
jack::Control::Continue jack::Control::Continue
} }
fn latency(&mut self, _: &jack::Client, mode: jack::LatencyType) { fn latency(&mut self, _: &jack::Client, _mode: jack::LatencyType) {
println!( // println!(
"JACK: {} latency has changed", // "JACK: {} latency has changed",
match mode { // match mode {
jack::LatencyType::Capture => "capture", // jack::LatencyType::Capture => "capture",
jack::LatencyType::Playback => "playback", // jack::LatencyType::Playback => "playback",
} // }
); // );
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment