summaryrefslogtreecommitdiff
path: root/klangfarbrs
diff options
context:
space:
mode:
Diffstat (limited to 'klangfarbrs')
-rw-r--r--klangfarbrs/src/instrument.rs9
-rw-r--r--klangfarbrs/src/lib.rs5
2 files changed, 12 insertions, 2 deletions
diff --git a/klangfarbrs/src/instrument.rs b/klangfarbrs/src/instrument.rs
index 3a929af..65da6b6 100644
--- a/klangfarbrs/src/instrument.rs
+++ b/klangfarbrs/src/instrument.rs
@@ -5,6 +5,15 @@ struct Instrument {
envelope: Envelope,
}
+impl Instrument {
+ pub fn sample(&mut self) -> Sample {
+ match self.next() {
+ Some(s) => { s },
+ None => 0.0
+ }
+ }
+}
+
impl Iterator for Instrument {
type Item = Sample;
diff --git a/klangfarbrs/src/lib.rs b/klangfarbrs/src/lib.rs
index 51f0c91..753f211 100644
--- a/klangfarbrs/src/lib.rs
+++ b/klangfarbrs/src/lib.rs
@@ -23,6 +23,7 @@ pub mod envelope;
use envelope::Envelope;
mod instrument;
+use instrument::Instrument;
mod utils;
@@ -36,7 +37,7 @@ type Millisecond = u32;
#[derive(NativeClass)]
#[inherit(Node)]
pub struct MonoSynth {
- pub osc: Osc,
+ pub osc: Instrument,
pub sample_rate: SamplesPerSecond,
pub frequency: Hz,
pub apply_bend: bool,
@@ -199,7 +200,7 @@ impl MonoSynth {
}
#[export]
- fn trigger(&mut self, _owner: &Node,
+ fn trigger(&mut self, _owner: &Node,
) {
self.envelope = Envelope::new(self.attack, self.decay, self.sustain, self.release, self.sample_rate);
}