From c55b27b23b8942142694c8c295e8217d1d38ea4b Mon Sep 17 00:00:00 2001 From: "5684185+vsariola@users.noreply.github.com" <5684185+vsariola@users.noreply.github.com> Date: Sun, 10 Mar 2024 20:01:13 +0200 Subject: [PATCH] fix(tracker): recording creates empty track when no notes triggered --- CHANGELOG.md | 2 ++ tracker/recording.go | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72ccddd..01c9555 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ([#65][i65]) ### Fixed +- When recording notes from VSTI, no track was created for instruments that had + no notes triggered, resulting in misalignment of the tracks from instruments. - 32-bit su_load_gmdls clobbered ebx, even though __stdcall demands it to be not touched ([#130][i130]) - Spaces are allowed in instrument names ([#120][i120]) diff --git a/tracker/recording.go b/tracker/recording.go index 2b088c1..8f4b1ba 100644 --- a/tracker/recording.go +++ b/tracker/recording.go @@ -77,6 +77,12 @@ func (recording *Recording) Score(patch sointu.Patch, rowsPerBeat, rowsPerPatter tracks[i][oldestIndex] = append(tracks[i][oldestIndex], n) } } + // if there was tracks that had no notes, create empty tracks for them + for i := range channelNotes { + if l := len(tracks[i]); l == 0 && l < patch[i].NumVoices { + tracks[i] = append(tracks[i], []recordingNote{}) + } + } songLengthPatterns := (frameToRow(recording.BPM, rowsPerBeat, recording.TotalFrames) + rowsPerPattern - 1) / rowsPerPattern songLengthRows := songLengthPatterns * rowsPerPattern songTracks := make([]sointu.Track, 0)