use super::Instrument;
use crate::synthesis::effects::{Delay, Distortion, Reverb};
use crate::synthesis::envelope::Envelope;
use crate::synthesis::filter::Filter;
use crate::synthesis::lfo::{LFO, ModRoute, ModTarget};
use crate::synthesis::waveform::Waveform;
impl Instrument {
pub fn vibraphone() -> Self {
let tremolo = LFO::new(Waveform::Sine, 5.8, 0.3); Self {
name: "Vibraphone".to_string(),
waveform: Waveform::Triangle,
envelope: Envelope::new(0.002, 0.8, 0.4, 1.2), filter: Filter::low_pass(5500.0, 0.2), modulation: vec![ModRoute::new(tremolo, ModTarget::Volume, 0.25)],
delay: Some(Delay::new(0.3, 0.25, 0.2)),
reverb: Some(Reverb::new(0.6, 0.65, 0.5)), distortion: None,
volume: 1.0,
pan: 0.0,
}
}
pub fn glockenspiel() -> Self {
Self {
name: "Glockenspiel".to_string(),
waveform: Waveform::Sine,
envelope: Envelope::new(0.001, 0.5, 0.15, 0.8), filter: Filter::low_pass(8000.0, 0.15), modulation: Vec::new(),
delay: Some(Delay::new(0.25, 0.2, 0.15)),
reverb: Some(Reverb::new(0.5, 0.55, 0.4)), distortion: None,
volume: 1.0,
pan: 0.0,
}
}
pub fn tubular_bells() -> Self {
let shimmer = LFO::new(Waveform::Sine, 0.25, 0.2); Self {
name: "Tubular Bells".to_string(),
waveform: Waveform::Triangle,
envelope: Envelope::new(0.002, 1.5, 0.3, 2.0), filter: Filter::low_pass(4000.0, 0.25), modulation: vec![ModRoute::new(shimmer, ModTarget::FilterCutoff, 0.08)],
delay: Some(Delay::new(0.4, 0.3, 0.25)),
reverb: Some(Reverb::new(0.8, 0.75, 0.65)), distortion: None,
volume: 1.0,
pan: 0.0,
}
}
pub fn steel_drums() -> Self {
let shimmer = LFO::new(Waveform::Sine, 0.5, 0.4); Self {
name: "Steel Drums".to_string(),
waveform: Waveform::Triangle,
envelope: Envelope::new(0.001, 0.6, 0.25, 0.9), filter: Filter::low_pass(6000.0, 0.35), modulation: vec![ModRoute::new(shimmer, ModTarget::FilterCutoff, 0.2)],
delay: Some(Delay::new(0.2, 0.25, 0.18)),
reverb: Some(Reverb::new(0.45, 0.5, 0.35)), distortion: None,
volume: 1.0,
pan: 0.0,
}
}
pub fn music_box() -> Self {
Self {
name: "Music Box".to_string(),
waveform: Waveform::Sine,
envelope: Envelope::new(0.001, 0.3, 0.1, 0.6), filter: Filter::low_pass(7000.0, 0.15), modulation: Vec::new(),
delay: Some(Delay::new(0.2, 0.25, 0.18)),
reverb: Some(Reverb::new(0.35, 0.42, 0.3)),
distortion: None,
volume: 1.0,
pan: 0.0,
}
}
pub fn celesta() -> Self {
Self {
name: "Celesta".to_string(),
waveform: Waveform::Sine,
envelope: Envelope::new(0.001, 0.6, 0.2, 0.9), filter: Filter::low_pass(7500.0, 0.18), modulation: Vec::new(),
delay: Some(Delay::new(0.28, 0.25, 0.2)),
reverb: Some(Reverb::new(0.55, 0.6, 0.45)), distortion: None,
volume: 1.0,
pan: 0.0,
}
}
pub fn xylophone() -> Self {
Self {
name: "Xylophone".to_string(),
waveform: Waveform::Triangle,
envelope: Envelope::new(0.001, 0.3, 0.1, 0.5), filter: Filter::low_pass(6500.0, 0.25), modulation: Vec::new(),
delay: None,
reverb: Some(Reverb::new(0.35, 0.42, 0.28)),
distortion: None,
volume: 1.0,
pan: 0.0,
}
}
pub fn marimba() -> Self {
Self {
name: "Marimba".to_string(),
waveform: Waveform::Triangle,
envelope: Envelope::new(0.002, 0.5, 0.2, 0.8), filter: Filter::low_pass(4500.0, 0.22), modulation: Vec::new(),
delay: Some(Delay::new(0.25, 0.22, 0.18)),
reverb: Some(Reverb::new(0.45, 0.52, 0.38)),
distortion: None,
volume: 1.0,
pan: 0.0,
}
}
pub fn bells() -> Self {
let shimmer = LFO::new(Waveform::Sine, 0.18, 0.25); Self {
name: "Bells".to_string(),
waveform: Waveform::Triangle,
envelope: Envelope::new(0.002, 1.8, 0.25, 2.5), filter: Filter::low_pass(5500.0, 0.28), modulation: vec![ModRoute::new(shimmer, ModTarget::FilterCutoff, 0.1)],
delay: Some(Delay::new(0.4, 0.35, 0.28)),
reverb: Some(Reverb::new(0.75, 0.72, 0.62)), distortion: None,
volume: 1.0,
pan: 0.0,
}
}
pub fn cowbell() -> Self {
Self {
name: "Cowbell".to_string(),
waveform: Waveform::Square,
envelope: Envelope::new(0.001, 0.1, 0.08, 0.2), filter: Filter::low_pass(4000.0, 0.55), modulation: Vec::new(),
delay: None,
reverb: Some(Reverb::new(0.25, 0.32, 0.22)),
distortion: Some(Distortion::new(1.5, 0.3)), volume: 1.0,
pan: 0.0,
}
}
pub fn timpani() -> Self {
Self {
name: "Timpani".to_string(),
waveform: Waveform::Triangle,
envelope: Envelope::new(0.002, 0.8, 0.15, 1.2), filter: Filter::low_pass(800.0, 0.45), modulation: Vec::new(),
delay: None,
reverb: Some(Reverb::new(0.6, 0.62, 0.48)), distortion: None,
volume: 1.0,
pan: 0.0,
}
}
pub fn taiko_drum() -> Self {
Self {
name: "Taiko Drum".to_string(),
waveform: Waveform::Triangle,
envelope: Envelope::new(0.001, 0.4, 0.1, 0.8), filter: Filter::low_pass(1200.0, 0.5), modulation: Vec::new(),
delay: None,
reverb: Some(Reverb::new(0.5, 0.55, 0.42)),
distortion: Some(Distortion::new(1.3, 0.25)), volume: 1.0,
pan: 0.0,
}
}
}