mirror of
https://github.com/vsariola/sointu.git
synced 2025-11-02 07:55:08 -05:00
fix(tracker): clamp CurrentInstrument and CurrentUnit when song is loaded
This commit is contained in:
@ -82,6 +82,12 @@ func (t *Tracker) LoadSong(song sointu.Song) error {
|
|||||||
defer t.songPlayMutex.Unlock()
|
defer t.songPlayMutex.Unlock()
|
||||||
t.song = song
|
t.song = song
|
||||||
t.ClampPositions()
|
t.ClampPositions()
|
||||||
|
if l := len(t.song.Patch.Instruments); t.CurrentInstrument >= len(t.song.Patch.Instruments) {
|
||||||
|
t.CurrentInstrument = l - 1
|
||||||
|
}
|
||||||
|
if l := len(t.song.Patch.Instruments[t.CurrentInstrument].Units); t.CurrentUnit >= l {
|
||||||
|
t.CurrentUnit = l - 1
|
||||||
|
}
|
||||||
if t.sequencer != nil {
|
if t.sequencer != nil {
|
||||||
t.sequencer.SetPatch(song.Patch)
|
t.sequencer.SetPatch(song.Patch)
|
||||||
t.sequencer.SetRowLength(song.SamplesPerRow())
|
t.sequencer.SetRowLength(song.SamplesPerRow())
|
||||||
|
|||||||
Reference in New Issue
Block a user