Crates.io | augmented-adsr-envelope |
lib.rs | augmented-adsr-envelope |
version | 0.5.0 |
source | src |
created_at | 2022-01-16 22:57:10.016988 |
updated_at | 2023-05-22 00:26:15.078527 |
description | ADSR envelope implementation |
homepage | https://github.com/yamadapc/augmented-audio |
repository | https://github.com/yamadapc/augmented-audio |
max_upload_size | |
id | 515181 |
size | 172,741 |
Implementation of an ADSR envelope.
use std::time::Duration;
use augmented_adsr_envelope::Envelope;
// Create an exponential envelope.
// The envelope configuration uses atomics, so it doesn't need
// to be an immutable reference.
let envelope = Envelope::exp();
// Set settings
envelope.set_sample_rate(1000.0);
envelope.set_attack(Duration::from_millis(200));
// Trigger the envelope
envelope.note_on();
for i in 0..10000 {
// Tick the envelope by 1 sample
envelope.tick();
// Get the current volume
let _volume = envelope.volume();
}
// Trigger the release stage
envelope.note_off();
Envelope::default();
Envelope::exp();
License: MIT