summaryrefslogtreecommitdiff
path: root/klangfarbrs/src/osc.rs
diff options
context:
space:
mode:
authorGrant Shangreaux <grant@unabridgedsoftware.com>2021-11-13 18:35:14 -0600
committerGrant Shangreaux <grant@unabridgedsoftware.com>2021-11-13 18:35:14 -0600
commit31e34297ed073927a63d0d9fccafc868998b8f46 (patch)
tree0246cc3ccc193b779cdf7f5697e32f694767b6a3 /klangfarbrs/src/osc.rs
parentd3776887db90ac1ea15fd55d833ff6b3042e7caf (diff)
Clean: a bit of junk moved around, Add: Osc::sample method
Diffstat (limited to 'klangfarbrs/src/osc.rs')
-rw-r--r--klangfarbrs/src/osc.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/klangfarbrs/src/osc.rs b/klangfarbrs/src/osc.rs
index 8225eb1..c609286 100644
--- a/klangfarbrs/src/osc.rs
+++ b/klangfarbrs/src/osc.rs
@@ -1,7 +1,7 @@
use std::f32::consts::TAU;
use rand::Rng;
use super::{Hz, Sample};
-use super::phasor::{Phasor};
+use super::phasor::Phasor;
/// The various waveforms the `MonoSynth` can generate.
pub enum Waveform {
@@ -35,6 +35,13 @@ impl Osc {
pub fn set_frequency(&mut self, frequency: Hz) {
self.phasor.frequency = frequency;
}
+
+ pub fn sample(&mut self) -> Sample {
+ match self.next() {
+ Some(s) => { s },
+ None => 0.0
+ }
+ }
}
impl Iterator for Osc {