diff --git a/CHANGELOG.md b/CHANGELOG.md index 37aa205..67e651d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). disabled ([#139][i139]) ### Changed +- Do not automatically wrap around the song when playing as it was usually + unwanted behaviour. There is already the looping mechanism if the user really + wants to loop the song forever. - Moved the error and warning popups slightly up so they don't block the unit control buttons ([#142][i142]) diff --git a/tracker/model.go b/tracker/model.go index 337f934..44a58aa 100644 --- a/tracker/model.go +++ b/tracker/model.go @@ -220,8 +220,8 @@ func (m *Model) change(kind string, t ChangeType, severity ChangeSeverity) func( m.d.ChangedSinceRecovery = true if m.changeType&ScoreChange != 0 { m.updatePatternUseCount() - m.d.Cursor.SongPos = m.d.Song.Score.Wrap(m.d.Cursor.SongPos) - m.d.Cursor2.SongPos = m.d.Song.Score.Wrap(m.d.Cursor2.SongPos) + m.d.Cursor.SongPos = m.d.Song.Score.Clamp(m.d.Cursor.SongPos) + m.d.Cursor2.SongPos = m.d.Song.Score.Clamp(m.d.Cursor2.SongPos) m.send(m.d.Song.Score.Copy()) } if m.changeType&PatchChange != 0 { @@ -353,6 +353,8 @@ func (m *Model) ProcessPlayerMessage(msg PlayerMsg) { m.instrEnlarged = false case Alert: m.Alerts().AddAlert(e) + case IsPlayingMsg: + m.playing = e.bool default: } } diff --git a/tracker/player.go b/tracker/player.go index f3a347e..52b31da 100644 --- a/tracker/player.go +++ b/tracker/player.go @@ -192,12 +192,21 @@ func (p *Player) advanceRow() { if p.song.Score.Length == 0 || p.song.Score.RowsPerPattern == 0 { return } + origPos := p.songPos p.songPos.PatternRow++ // advance row (this is why we subtracted one in Play()) if p.loop.Length > 0 && p.songPos.PatternRow >= p.song.Score.RowsPerPattern && p.songPos.OrderRow == p.loop.Start+p.loop.Length-1 { p.songPos.PatternRow = 0 p.songPos.OrderRow = p.loop.Start } - p.songPos = p.song.Score.Wrap(p.songPos) + p.songPos = p.song.Score.Clamp(p.songPos) + if p.songPos == origPos { + p.send(IsPlayingMsg{bool: false}) + p.playing = false + for i := range p.song.Score.Tracks { + p.releaseTrack(i) + } + return + } p.send(nil) // just send volume and song row information lastVoice := 0 for i, t := range p.song.Score.Tracks { diff --git a/tracker/table.go b/tracker/table.go index e5bbd1b..118e119 100644 --- a/tracker/table.go +++ b/tracker/table.go @@ -410,7 +410,7 @@ func (m *Notes) Cursor2() Point { func (v *Notes) SetCursor(p Point) { v.d.Cursor.Track = intMax(intMin(p.X, len(v.d.Song.Score.Tracks)-1), 0) - newPos := v.d.Song.Score.Wrap(sointu.SongPos{PatternRow: p.Y}) + newPos := v.d.Song.Score.Clamp(sointu.SongPos{PatternRow: p.Y}) if newPos != v.d.Cursor.SongPos { v.noteTracking = false } @@ -419,7 +419,7 @@ func (v *Notes) SetCursor(p Point) { func (v *Notes) SetCursor2(p Point) { v.d.Cursor2.Track = intMax(intMin(p.X, len(v.d.Song.Score.Tracks)-1), 0) - v.d.Cursor2.SongPos = v.d.Song.Score.Wrap(sointu.SongPos{PatternRow: p.Y}) + v.d.Cursor2.SongPos = v.d.Song.Score.Clamp(sointu.SongPos{PatternRow: p.Y}) } func (v *Notes) Width() int {