Skip to content

Commit c2e6c38

Browse files
committed
Allow in-place processing
1 parent 02e7387 commit c2e6c38

File tree

4 files changed

+47
-24
lines changed

4 files changed

+47
-24
lines changed

lv2/Cargo.lock

Lines changed: 32 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lv2/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2021"
77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88

99
[dependencies]
10-
lv2 = { git = "https://github.com/davemollen/rust-lv2.git", features = [
10+
lv2 = { git = "https://github.com/davemollen/rust-lv2.git", branch = "master", features = [
1111
"minimal_plugin",
1212
] }
1313
reverse = { path = "../reverse" }

lv2/dm-Reverse.lv2/dm-Reverse.ttl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
foaf:name "Dave Mollen" ;
1717
foaf:homepage <https://github.com/davemollen/dm-Reverse> ;
1818
] ;
19-
lv2:requiredFeature lv2:inPlaceBroken ;
2019
lv2:optionalFeature lv2:hardRTCapable ;
2120
mod:brand "DM" ;
2221
mod:label "Reverse" ;

lv2/src/lib.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ use reverse::{Params, Reverse};
55

66
#[derive(PortCollection)]
77
struct Ports {
8-
time: InputPort<Control>,
9-
feedback: InputPort<Control>,
10-
mix: InputPort<Control>,
11-
input: InputPort<Audio>,
12-
output: OutputPort<Audio>,
8+
time: InputPort<InPlaceControl>,
9+
feedback: InputPort<InPlaceControl>,
10+
mix: InputPort<InPlaceControl>,
11+
input: InputPort<InPlaceAudio>,
12+
output: OutputPort<InPlaceAudio>,
1313
}
1414

1515
#[uri("https://github.com/davemollen/dm-Reverse")]
@@ -39,12 +39,15 @@ impl Plugin for DmReverse {
3939
// Process a chunk of audio. The audio ports are dereferenced to slices, which the plugin
4040
// iterates over.
4141
fn run(&mut self, ports: &mut Ports, _features: &mut (), _sample_count: u32) {
42-
self
43-
.params
44-
.set(*ports.time, *ports.feedback * 0.01, *ports.mix * 0.01);
45-
46-
for (in_frame, out_frame) in Iterator::zip(ports.input.iter(), ports.output.iter_mut()) {
47-
*out_frame = self.reverse.process(*in_frame, &mut self.params);
42+
self.params.set(
43+
ports.time.get(),
44+
ports.feedback.get() * 0.01,
45+
ports.mix.get() * 0.01,
46+
);
47+
48+
for (input, output) in ports.input.iter().zip(ports.output.iter()) {
49+
let reverse_output = self.reverse.process(input.get(), &mut self.params);
50+
output.set(reverse_output);
4851
}
4952
}
5053
}

0 commit comments

Comments
 (0)