Minor fixes when trying other tracks

This commit is contained in:
Gwilym Inzani 2023-08-05 01:33:48 +01:00
parent ff5d324356
commit db75d8b048
2 changed files with 9 additions and 7 deletions

View file

@ -375,12 +375,14 @@ impl TrackerChannel {
PatternEffect::TonePortamento(amount, target) => { PatternEffect::TonePortamento(amount, target) => {
channel.volume(self.volume.try_change_base().unwrap()); channel.volume(self.volume.try_change_base().unwrap());
if *amount < 1.into() { if tick != 0 {
self.base_speed = if *amount < 1.into() {
(self.base_speed * amount.change_base()).max(target.change_base()); self.base_speed =
} else { (self.base_speed * amount.change_base()).max(target.change_base());
self.base_speed = } else {
(self.base_speed * amount.change_base()).min(target.change_base()); self.base_speed =
(self.base_speed * amount.change_base()).min(target.change_base());
}
} }
channel.playback(self.base_speed.change_base()); channel.playback(self.base_speed.change_base());

View file

@ -469,7 +469,7 @@ fn note_to_frequency_amega(note: Note, fine_tune: f64, relative_note: i8) -> f64
let note = (note as usize) let note = (note as usize)
.checked_add_signed(relative_note as isize) .checked_add_signed(relative_note as isize)
.expect("Note gone negative"); .expect("Note gone negative");
let pos = (note % 12) * 8 + (fine_tune / 16.0) as usize; let pos = ((note % 12) * 8 + (fine_tune / 16.0) as usize).min(AMEGA_FREQUENCIES.len() - 2);
let frac = (fine_tune / 16.0) - (fine_tune / 16.0).floor(); let frac = (fine_tune / 16.0) - (fine_tune / 16.0).floor();
let period = ((AMEGA_FREQUENCIES[pos] as f64 * (1.0 - frac)) let period = ((AMEGA_FREQUENCIES[pos] as f64 * (1.0 - frac))