summaryrefslogtreecommitdiff
path: root/klangfarbrs/src
diff options
context:
space:
mode:
Diffstat (limited to 'klangfarbrs/src')
-rw-r--r--klangfarbrs/src/adsr.rs2
-rw-r--r--klangfarbrs/src/lib.rs12
2 files changed, 11 insertions, 3 deletions
diff --git a/klangfarbrs/src/adsr.rs b/klangfarbrs/src/adsr.rs
index ca03735..682cc8a 100644
--- a/klangfarbrs/src/adsr.rs
+++ b/klangfarbrs/src/adsr.rs
@@ -7,7 +7,7 @@ pub struct Envelope {
}
impl Envelope {
- fn new(attack: Millisecond, decay: Millisecond, sustain: Amplitude, release: Millisecond) -> Self {
+ pub fn new(attack: Millisecond, decay: Millisecond, sustain: Amplitude, release: Millisecond) -> Self {
let attack = vec![sustain; attack as usize];
let decay = vec![sustain; decay as usize];
let release = vec![sustain; release as usize];
diff --git a/klangfarbrs/src/lib.rs b/klangfarbrs/src/lib.rs
index 087cbd7..0fc7936 100644
--- a/klangfarbrs/src/lib.rs
+++ b/klangfarbrs/src/lib.rs
@@ -13,9 +13,10 @@ use gdnative::prelude::*;
use gdnative::core_types::TypedArray;
mod osc;
-use osc::{Osc};
+use osc::Osc;
-mod adsr;
+pub mod adsr;
+use adsr::Envelope;
/// Aliasing some types to distinguish various audio properties.
type Sample = f32;
@@ -184,6 +185,13 @@ impl MonoSynth {
self.fm_depth = fm_depth
}
+ fn envelope(
+ &self, _owner: &Node,
+ attack: Millisecond, decay: Millisecond, sustain: Amplitude, release: Millisecond
+ ) -> Envelope {
+ Envelope::new(attack, decay, sustain, release)
+ }
+
#[export]
pub fn frames(&mut self, _owner: &Node, samples: i32) -> TypedArray<Vector2> {
let mut frames = TypedArray::new();