mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-27 19:00:25 -04:00
fix(sointu): use proper modulo in SongPos
The previous implementations used remained, not modulo, which could cause issues with negative values.
This commit is contained in:
parent
4e1fdf57d9
commit
5e65410d27
6
song.go
6
song.go
@ -81,8 +81,8 @@ func (s *Score) SongPos(songRow int) SongPos {
|
||||
if s.RowsPerPattern == 0 {
|
||||
return SongPos{OrderRow: 0, PatternRow: 0}
|
||||
}
|
||||
orderRow := songRow / s.RowsPerPattern
|
||||
patternRow := songRow % s.RowsPerPattern
|
||||
patternRow := (songRow%s.RowsPerPattern + s.RowsPerPattern) % s.RowsPerPattern
|
||||
orderRow := ((songRow - patternRow) / s.RowsPerPattern)
|
||||
return SongPos{OrderRow: orderRow, PatternRow: patternRow}
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ func (s *Score) SongRow(songPos SongPos) int {
|
||||
|
||||
func (s *Score) Wrap(songPos SongPos) SongPos {
|
||||
ret := s.SongPos(s.SongRow(songPos))
|
||||
ret.OrderRow %= s.Length
|
||||
ret.OrderRow = (ret.OrderRow%s.Length + s.Length) % s.Length
|
||||
return ret
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user