summaryrefslogtreecommitdiff
path: root/klangfarbrs
diff options
context:
space:
mode:
authorJacob Lee <jacob@unabridgedsoftware.com>2021-11-05 23:56:09 -0400
committerJacob Lee <jacob@unabridgedsoftware.com>2021-11-05 23:56:09 -0400
commit715f8440e68fea6a7cfcedd409053d0579523e14 (patch)
tree995ff6f18b07475c7d9bd8c6634e54ed03742b86 /klangfarbrs
parentddb670fc5d69784842bf8570306a91d0ec1ff5ed (diff)
Refactor complete
Diffstat (limited to 'klangfarbrs')
-rw-r--r--klangfarbrs/src/lib.rs19
1 files changed, 17 insertions, 2 deletions
diff --git a/klangfarbrs/src/lib.rs b/klangfarbrs/src/lib.rs
index 715d781..479885c 100644
--- a/klangfarbrs/src/lib.rs
+++ b/klangfarbrs/src/lib.rs
@@ -189,19 +189,34 @@ impl MonoSynth {
}
#[export]
+ fn frequency(&mut self, _owner: &Node, frequency: Hz) {
+ self.frequency = frequency
+ }
+
+ #[export]
+ fn phasor_bend(&mut self, _owner: &Node, phasor_bend: Vector2) {
+ self.phasor_bend = phasor_bend
+ }
+
+ #[export]
+ fn apply_bend(&mut self, _owner: &Node, apply_bend: bool) {
+ self.apply_bend = apply_bend
+ }
+
+ #[export]
pub fn set_sample_rate(&mut self, _owner: &Node, sample_rate: f32) {
self.sample_rate = sample_rate;
}
#[export]
- pub fn frames(&mut self, _owner: &Node, frequency: f32, samples: i32) -> TypedArray<Vector2> {
+ pub fn frames(&mut self, _owner: &Node, samples: i32) -> TypedArray<Vector2> {
let mut frames = TypedArray::new();
for _i in 0..samples {
let sample = Osc::generate_sample(&self.waveform, self.phasor.phase);
frames.push(Vector2::new(sample, sample));
- let next_phase = self.phasor.next_phase(frequency, self.sample_rate);
+ let next_phase = self.phasor.next_phase(self.frequency, self.sample_rate);
if self.apply_bend {
self.phasor.phase = Bender::bend(next_phase, self.phasor_bend);
} else {