mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-18 21:14:31 -04:00
feat(sointu, tracker,...): restructure domain & tracker models
send targets are now by ID and Song has "Score" part, which is the notes for it. also, moved the model part separate of the actual gioui dependend stuff. sorry to my future self about the code bomb; ended up too far and did not find an easy way to rewrite the history to make the steps smaller, so in the end, just squashed everything.
This commit is contained in:
@ -17,36 +17,56 @@ type SongRect struct {
|
||||
Corner2 SongPoint
|
||||
}
|
||||
|
||||
func (r *SongRow) Wrap(song sointu.Song) {
|
||||
totalRow := r.Pattern*song.RowsPerPattern + r.Row
|
||||
r.Row = mod(totalRow, song.RowsPerPattern)
|
||||
r.Pattern = mod((totalRow-r.Row)/song.RowsPerPattern, song.SequenceLength())
|
||||
func (r SongRow) AddRows(rows int) SongRow {
|
||||
return SongRow{Row: r.Row + rows, Pattern: r.Pattern}
|
||||
}
|
||||
|
||||
func (r *SongRow) Clamp(song sointu.Song) {
|
||||
totalRow := r.Pattern*song.RowsPerPattern + r.Row
|
||||
func (r SongRow) AddPatterns(patterns int) SongRow {
|
||||
return SongRow{Row: r.Row, Pattern: r.Pattern + patterns}
|
||||
}
|
||||
|
||||
func (r SongRow) Wrap(score sointu.Score) SongRow {
|
||||
totalRow := r.Pattern*score.RowsPerPattern + r.Row
|
||||
r.Row = mod(totalRow, score.RowsPerPattern)
|
||||
r.Pattern = mod((totalRow-r.Row)/score.RowsPerPattern, score.Length)
|
||||
return r
|
||||
}
|
||||
|
||||
func (r SongRow) Clamp(score sointu.Score) SongRow {
|
||||
totalRow := r.Pattern*score.RowsPerPattern + r.Row
|
||||
if totalRow < 0 {
|
||||
totalRow = 0
|
||||
}
|
||||
if totalRow >= song.TotalRows() {
|
||||
totalRow = song.TotalRows() - 1
|
||||
if totalRow >= score.LengthInRows() {
|
||||
totalRow = score.LengthInRows() - 1
|
||||
}
|
||||
r.Row = totalRow % song.RowsPerPattern
|
||||
r.Pattern = ((totalRow - r.Row) / song.RowsPerPattern) % song.SequenceLength()
|
||||
r.Row = totalRow % score.RowsPerPattern
|
||||
r.Pattern = ((totalRow - r.Row) / score.RowsPerPattern) % score.Length
|
||||
return r
|
||||
}
|
||||
|
||||
func (p *SongPoint) Wrap(song sointu.Song) {
|
||||
p.Track = mod(p.Track, len(song.Tracks))
|
||||
p.SongRow.Wrap(song)
|
||||
func (r SongPoint) AddRows(rows int) SongPoint {
|
||||
return SongPoint{Track: r.Track, SongRow: r.SongRow.AddRows(rows)}
|
||||
}
|
||||
|
||||
func (p *SongPoint) Clamp(song sointu.Song) {
|
||||
func (r SongPoint) AddPatterns(patterns int) SongPoint {
|
||||
return SongPoint{Track: r.Track, SongRow: r.SongRow.AddPatterns(patterns)}
|
||||
}
|
||||
|
||||
func (p SongPoint) Wrap(score sointu.Score) SongPoint {
|
||||
p.Track = mod(p.Track, len(score.Tracks))
|
||||
p.SongRow = p.SongRow.Wrap(score)
|
||||
return p
|
||||
}
|
||||
|
||||
func (p SongPoint) Clamp(score sointu.Score) SongPoint {
|
||||
if p.Track < 0 {
|
||||
p.Track = 0
|
||||
} else if l := len(song.Tracks); p.Track >= l {
|
||||
} else if l := len(score.Tracks); p.Track >= l {
|
||||
p.Track = l - 1
|
||||
}
|
||||
p.SongRow.Clamp(song)
|
||||
p.SongRow = p.SongRow.Clamp(score)
|
||||
return p
|
||||
}
|
||||
|
||||
func (r *SongRect) Contains(p SongPoint) bool {
|
||||
|
Reference in New Issue
Block a user