From 8fa595f7f7f5083ac7234fc9a99b03a5606f5210 Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Wed, 10 Jul 2024 14:51:15 +0100 Subject: [PATCH] Handle RampDown --- tracker/agb-tracker-interop/src/lib.rs | 2 +- tracker/agb-xm-core/src/lib.rs | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/tracker/agb-tracker-interop/src/lib.rs b/tracker/agb-tracker-interop/src/lib.rs index 8e958f5d..565c1d89 100644 --- a/tracker/agb-tracker-interop/src/lib.rs +++ b/tracker/agb-tracker-interop/src/lib.rs @@ -51,7 +51,7 @@ pub struct Envelope { pub loop_end: Option, pub vib_waveform: Waveform, - pub vib_amount: Num, + pub vib_amount: Num, pub vib_speed: u8, } diff --git a/tracker/agb-xm-core/src/lib.rs b/tracker/agb-xm-core/src/lib.rs index 53fb75c7..9298361d 100644 --- a/tracker/agb-xm-core/src/lib.rs +++ b/tracker/agb-xm-core/src/lib.rs @@ -553,7 +553,7 @@ struct EnvelopeData { vib_waveform: Waveform, vib_speed: u8, - vib_amount: Num, + vib_amount: Num, } impl EnvelopeData { @@ -616,8 +616,17 @@ impl EnvelopeData { let vib_depth = instrument.vibrato.depth * 16.0; let c4_speed = note_to_speed(Note::C4, 0.0, 0, frequency_type); - let vib_amount = - note_to_speed(Note::C4, vib_depth.into(), 0, frequency_type) / c4_speed - 1; + let mut vib_amount = + (note_to_speed(Note::C4, vib_depth.into(), 0, frequency_type) / c4_speed - 1) + .try_change_base() + .unwrap(); + + if matches!( + instrument.vibrato.waveform, + xmrs::instr_vibrato::Waveform::RampDown + ) { + vib_amount = -vib_amount; + } EnvelopeData { amounts,