Skip to content

Commit

Permalink
worm
Browse files Browse the repository at this point in the history
  • Loading branch information
tomara-x committed Aug 16, 2024
1 parent 4a93972 commit 16ed66e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,8 @@ for more info about osc: https://opensoundcontrol.stanford.edu/spec-1_0.html
- `num_push`
- inputs: `n -> 1`
- output this circle's num (open all white holes reading it) when the input num in non-zero
- `worm[string]`
- multiple circles with the same op string (starting with `worm`) will mirror the same number value. when one's num changes, the others follow. their order matters, as value flows from lower to higher order
- `sum`
- inputs: `n -> 1` (any number of those)
- convenience op for adding numbers together
Expand Down
2 changes: 2 additions & 0 deletions src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,8 @@ pub fn str_to_op_num(op: &str) -> u16 {
51
} else if x.starts_with("swap") {
91
} else if x.starts_with("worm") {
96
} else {
0
}
Expand Down
14 changes: 14 additions & 0 deletions src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ pub fn process(
),
) {
let key_event = key_event.read().collect::<Vec<_>>();
let mut worm: Vec<(String, f32)> = Vec::new();
'entity: for id in queue.0.iter().flatten().chain(loopq.0.iter()) {
let holes = &holes_query.get(*id).unwrap().0;
for hole in holes {
Expand Down Expand Up @@ -1354,6 +1355,19 @@ pub fn process(
}
}
}
// worm
96 => {
let n = num_query.get_mut(*id).unwrap();
if n.is_changed() {
worm.push((op.to_string(), n.0));
}
for (address, n) in &worm {
if *address == op {
num_query.get_mut(*id).unwrap().0 = *n;
lt_to_open = Some(-1);
}
}
}
// -------------------- audio nodes --------------------
// var()
61 => {
Expand Down

0 comments on commit 16ed66e

Please sign in to comment.