Add audio nodes to the patch bay
Also make the patch bay responsive.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
//! ADSR envelope generator.
|
||||
|
||||
use crate::{AudioProcessor, config::SampleRate};
|
||||
use crate::descriptor::{ComponentDescriptor, Direction, JackDescriptor, ParamDescriptor, SignalKind};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
enum Stage { Idle, Attack, Decay, Sustain, Release }
|
||||
@@ -25,6 +26,21 @@ impl Adsr {
|
||||
}
|
||||
}
|
||||
|
||||
pub const DESCRIPTOR: ComponentDescriptor = ComponentDescriptor {
|
||||
kind: "adsr",
|
||||
label: "ADSR",
|
||||
jacks: &[
|
||||
JackDescriptor { id: "gate_in", label: "Gate", direction: Direction::Input, signal: SignalKind::Gate },
|
||||
JackDescriptor { id: "env_out", label: "Env", direction: Direction::Output, signal: SignalKind::Cv },
|
||||
],
|
||||
params: &[
|
||||
ParamDescriptor { id: "attack_s", label: "Attack", min: 0.001, max: 4.0, default: 0.01, unit: "s" },
|
||||
ParamDescriptor { id: "decay_s", label: "Decay", min: 0.001, max: 4.0, default: 0.1, unit: "s" },
|
||||
ParamDescriptor { id: "sustain", label: "Sustain", min: 0.0, max: 1.0, default: 0.7, unit: "" },
|
||||
ParamDescriptor { id: "release_s", label: "Release", min: 0.001, max: 8.0, default: 0.3, unit: "s" },
|
||||
],
|
||||
};
|
||||
|
||||
pub fn gate_on(&mut self) { self.stage = Stage::Attack; }
|
||||
pub fn gate_off(&mut self) { self.stage = Stage::Release; }
|
||||
pub fn is_idle(&self) -> bool { self.stage == Stage::Idle }
|
||||
|
||||
Reference in New Issue
Block a user