Skip to content

Commit 14bc29e

Browse files
Merge pull request #88 from niclashoyer/sample_count
Add sample_count to Plugin run method
2 parents 5a52c23 + 7f5867c commit 14bc29e

File tree

15 files changed

+23
-18
lines changed

15 files changed

+23
-18
lines changed

atom/tests/atom_integration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl Plugin for AtomPlugin {
4242
})
4343
}
4444

45-
fn run(&mut self, ports: &mut Ports, _: &mut ()) {
45+
fn run(&mut self, ports: &mut Ports, _: &mut (), _: u32) {
4646
let sequence_reader = ports
4747
.input
4848
.read::<Sequence>(self.urids.atom.sequence, self.urids.units.beat)

core/src/extension.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
//! Some(Self { internal: 0 })
8080
//! }
8181
//!
82-
//! fn run(&mut self, _: &mut (), _: &mut ()) {
82+
//! fn run(&mut self, _: &mut (), _: &mut (), _: u32) {
8383
//! self.internal += 1;
8484
//! }
8585
//!

core/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
//!
4444
//! // Process a chunk of audio. The audio ports are dereferenced to slices, which the plugin
4545
//! // iterates over.
46-
//! fn run(&mut self, ports: &mut Ports, _features: &mut ()) {
46+
//! fn run(&mut self, ports: &mut Ports, _features: &mut (), _: u32) {
4747
//! let coef = if *(ports.gain) > -90.0 {
4848
//! 10.0_f32.powf(*(ports.gain) * 0.05)
4949
//! } else {

core/src/plugin/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ pub trait Plugin: UriBound + Sized + Send + Sync + 'static {
4545
/// Run a processing step.
4646
///
4747
/// The host will always call this method after `active` has been called and before `deactivate` has been called.
48-
fn run(&mut self, ports: &mut Self::Ports, features: &mut Self::AudioFeatures);
48+
fn run(
49+
&mut self,
50+
ports: &mut Self::Ports,
51+
features: &mut Self::AudioFeatures,
52+
sample_count: u32,
53+
);
4954

5055
/// Reset and initialize the complete internal state of the plugin.
5156
///
@@ -228,7 +233,7 @@ impl<T: Plugin> PluginInstance<T> {
228233
if let Some(mut ports) = instance.ports(sample_count) {
229234
instance
230235
.instance
231-
.run(&mut ports, &mut instance.audio_features);
236+
.run(&mut ports, &mut instance.audio_features, sample_count);
232237
}
233238
}
234239

core/tests/amp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl Plugin for Amp {
5353
}
5454

5555
#[inline]
56-
fn run(&mut self, ports: &mut AmpPorts, _: &mut ()) {
56+
fn run(&mut self, ports: &mut AmpPorts, _: &mut (), _: u32) {
5757
assert!(self.activated);
5858

5959
let coef = *(ports.gain);

docs/amp/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl Plugin for Amp {
2323
Some(Self)
2424
}
2525
// The `run()` method is the main process function of the plugin. It processes a block of audio in the audio context. Since this plugin is `lv2:hardRTCapable`, `run()` must be real-time safe, so blocking (e.g. with a mutex) or memory allocation are not allowed.
26-
fn run(&mut self, ports: &mut Ports, _features: &mut ()) {
26+
fn run(&mut self, ports: &mut Ports, _features: &mut (), _: u32) {
2727
let coef = if *(ports.gain) > -90.0 {
2828
10.0_f32.powf(*(ports.gain) * 0.05)
2929
} else {

docs/fifths/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl Plugin for Fifths {
3838
}
3939

4040
// This plugin works similar to the previous one: It iterates over the events in the input port. However, it only needs to write one or two messages instead of blocks of audio.
41-
fn run(&mut self, ports: &mut Ports, _: &mut ()) {
41+
fn run(&mut self, ports: &mut Ports, _: &mut (), _: u32) {
4242
// Get the reading handle of the input sequence.
4343
let input_sequence = ports
4444
.input

docs/metro/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl Plugin for Metro {
7474
self.sampler.reset();
7575
}
7676

77-
fn run(&mut self, ports: &mut Ports, _: &mut ()) {
77+
fn run(&mut self, ports: &mut Ports, _: &mut (), _: u32) {
7878
if let Some(control) = ports
7979
.control
8080
.read(self.urids.atom.sequence, self.urids.unit.beat)

docs/midigate/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl Plugin for Midigate {
7777
// This pattern of iterating over input events and writing output along the way is a common idiom for writing sample accurate output based on event input.
7878
//
7979
// Note that this simple example simply writes input or zero for each sample based on the gate. A serious implementation would need to envelope the transition to avoid aliasing.
80-
fn run(&mut self, ports: &mut Ports, _: &mut ()) {
80+
fn run(&mut self, ports: &mut Ports, _: &mut (), _: u32) {
8181
let mut offset: usize = 0;
8282

8383
let control_sequence = ports

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
//!
6969
//! // Process a chunk of audio. The audio ports are dereferenced to slices, which the plugin
7070
//! // iterates over.
71-
//! fn run(&mut self, ports: &mut Ports, _features: &mut ()) {
71+
//! fn run(&mut self, ports: &mut Ports, _features: &mut (), _: u32) {
7272
//! let coef = if *(ports.gain) > -90.0 {
7373
//! 10.0_f32.powf(*(ports.gain) * 0.05)
7474
//! } else {

0 commit comments

Comments
 (0)