From e09af5ab34616fde7d96444f82e7606449215e4a Mon Sep 17 00:00:00 2001 From: "5684185+vsariola@users.noreply.github.com" <5684185+vsariola@users.noreply.github.com> Date: Sat, 10 Aug 2024 15:14:54 +0300 Subject: [PATCH] fix(tracker): loading preset did not update the ids When a preset was loaded, its IDs were not updated, causing ID collisions in the song and send targets going wrong. --- CHANGELOG.md | 2 ++ tracker/presets.go | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f91a73..b40cfc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). x87 stack. ### Fixed +- Loading a preset did not update the IDs of the newly loaded instrument, + causing ID collisions and sends target wrong units. - The x87 native filter unit was denormalizing and eating up a lot of CPU ([#68][i68]) - Modulating delaytime in wasm could crash, because delay time was converted to int with i32.trunc_f32_u. Using i32.trunc_f32_s fixed this. diff --git a/tracker/presets.go b/tracker/presets.go index 8b97b87..565f86d 100644 --- a/tracker/presets.go +++ b/tracker/presets.go @@ -145,7 +145,9 @@ func (m *Model) LoadPreset(index int) Action { for m.d.InstrIndex >= len(m.d.Song.Patch) { m.d.Song.Patch = append(m.d.Song.Patch, defaultInstrument.Copy()) } - m.d.Song.Patch[m.d.InstrIndex] = instrumentPresets[index].Copy() + newInstr := instrumentPresets[index].Copy() + (*Model)(m).assignUnitIDs(newInstr.Units) + m.d.Song.Patch[m.d.InstrIndex] = newInstr }, allowed: func() bool { return true }}