summaryrefslogtreecommitdiff
path: root/klangfarbrs
diff options
context:
space:
mode:
Diffstat (limited to 'klangfarbrs')
-rw-r--r--klangfarbrs/src/instrument.rs5
-rw-r--r--klangfarbrs/src/lib.rs6
2 files changed, 2 insertions, 9 deletions
diff --git a/klangfarbrs/src/instrument.rs b/klangfarbrs/src/instrument.rs
index 6fc797b..bf08fe4 100644
--- a/klangfarbrs/src/instrument.rs
+++ b/klangfarbrs/src/instrument.rs
@@ -2,7 +2,6 @@ use super::{ Partial, Sample, Hz, SamplesPerSecond };
pub struct Instrument {
pub partials: Vec<Partial>,
- pub complete: bool,
}
impl Instrument {
@@ -10,8 +9,7 @@ impl Instrument {
Self {
partials: partial_multipliers.iter()
.map(|&p| Partial::new(1.0, 1.0, p, 0.0, sample_rate, 2000, base_freq))
- .collect(),
- complete: false,
+ .collect()
}
}
@@ -34,7 +32,6 @@ impl Iterator for Instrument {
.map(|i| i.unwrap()).collect();
if filtered.is_empty() {
- self.complete = true;
None
} else {
Some(filtered.iter().sum())
diff --git a/klangfarbrs/src/lib.rs b/klangfarbrs/src/lib.rs
index e60e7b3..de3322a 100644
--- a/klangfarbrs/src/lib.rs
+++ b/klangfarbrs/src/lib.rs
@@ -215,6 +215,7 @@ impl MonoSynth {
#[export]
fn trigger(&mut self, _owner: &Node,
) {
+ self.instrument = Instrument::new(self.frequency, vec![0.56, 0.92, 1.19, 1.7, 2.0, 2.74, 3.0, 3.76, 4.07], self.sample_rate);
self.envelope = Envelope::new(self.attack, self.decay, self.sustain, self.release, self.sample_rate);
}
@@ -250,11 +251,6 @@ impl MonoSynth {
}
}
- // TODO: For now this enables the instrument to be played multiple times. Would like to find a cleaner way to do this.
- if self.instrument.complete {
- self.instrument = Instrument::new(self.frequency, vec![0.56, 0.92, 1.19, 1.7, 2.0, 2.74, 3.0, 3.76, 4.07], self.sample_rate)
- }
-
frames.push(Vector2::new(sample, sample));
}