| Crates.io | rx_core_operator_adsr |
| lib.rs | rx_core_operator_adsr |
| version | 0.2.0 |
| created_at | 2026-01-19 12:03:47.813799+00 |
| updated_at | 2026-01-24 15:04:41.206924+00 |
| description | adsr operator for rx_core |
| homepage | https://github.com/AlexAegis/rx_bevy |
| repository | https://github.com/AlexAegis/rx_bevy |
| max_upload_size | |
| id | 2054435 |
| size | 70,113 |
Convert trigger signals into an ADSR envelope driven by the scheduler.
cargo run -p rx_core --example operator_adsr_example
use std::time::Duration;
use rx_core::prelude::*;
use rx_core_testing::MockExecutor;
fn main() {
let mut executor = MockExecutor::default();
let scheduler = executor.get_scheduler_handle();
let envelope = AdsrEnvelope {
attack_time: Duration::from_millis(10),
decay_time: Duration::from_millis(10),
sustain_volume: 0.5,
release_time: Duration::from_millis(15),
..Default::default()
};
let mut source = PublishSubject::<AdsrTrigger>::default();
let mut subscription = source
.clone()
.adsr(
AdsrOperatorOptions {
envelope,
..Default::default()
},
scheduler.clone(),
)
.subscribe(PrintObserver::new("adsr"));
source.next(true.into());
executor.tick(Duration::from_millis(10));
executor.tick(Duration::from_millis(10));
source.next(false.into());
executor.tick(Duration::from_millis(15));
subscription.unsubscribe();
}
adsr - next: AdsrSignal { adsr_envelope_phase: Attack, phase_transition: AdsrEnvelopePhaseTransition(1), t: 0ns, value: 0.0 }
adsr - next: AdsrSignal { adsr_envelope_phase: Decay, phase_transition: AdsrEnvelopePhaseTransition(2), t: 10ms, value: 1.0 }
adsr - next: AdsrSignal { adsr_envelope_phase: None, phase_transition: AdsrEnvelopePhaseTransition(16), t: 0ns, value: 0.0 }
adsr - unsubscribed