summaryrefslogtreecommitdiff
path: root/klangfarbrs
diff options
context:
space:
mode:
authorGrant Shangreaux <grant@unabridgedsoftware.com>2021-11-01 20:00:34 -0500
committerGrant Shangreaux <grant@unabridgedsoftware.com>2021-11-01 20:00:34 -0500
commita8fd8a74ec114fbde563bca62180a160c3cb8a88 (patch)
tree7bdf1dea3c70e501c6e5030aec1313192309666f /klangfarbrs
parentc2ef13956710352267ae1583c11efbc745fecfd7 (diff)
Add: mouse control of frequency based on x coord mouse position
Diffstat (limited to 'klangfarbrs')
-rw-r--r--klangfarbrs/src/lib.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/klangfarbrs/src/lib.rs b/klangfarbrs/src/lib.rs
index 059d59f..8fb773d 100644
--- a/klangfarbrs/src/lib.rs
+++ b/klangfarbrs/src/lib.rs
@@ -39,6 +39,7 @@ fn generate_sample(osc: &Osc) -> f32 {
Waveform::Sine => {
(TAU * phase).sin()
},
+
Waveform::Square => {
if phase < 0.5 {
-1.0
@@ -46,6 +47,7 @@ fn generate_sample(osc: &Osc) -> f32 {
1.0
}
},
+
Waveform::Triangle => {
if phase < 0.5 {
4.0 * phase - 1.0
@@ -53,6 +55,7 @@ fn generate_sample(osc: &Osc) -> f32 {
4.0 * (1.0 - phase) - 1.0
}
},
+
Waveform::Sawtooth => {
2.0 * phase - 1.0
}