mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-18 21:14:31 -04:00
feat(sointu, vm): implement pure-Go interpreter for bytecode
The old "native" compiler bridged version is now started with cmd/sointu-nativetrack, while the new pure-Go bytecode implemented bytecode interpreter is started with cmd/sointu-track Thus, you do not need any of the CMake / cgo stuff to run cmd/sointu-track
This commit is contained in:
28
song.go
28
song.go
@ -28,33 +28,7 @@ func (s *Song) Validate() error {
|
||||
if len(s.Score.Tracks) == 0 {
|
||||
return errors.New("song contains no tracks")
|
||||
}
|
||||
var patternLen int
|
||||
for i, t := range s.Score.Tracks {
|
||||
for j, pat := range t.Patterns {
|
||||
if i == 0 && j == 0 {
|
||||
patternLen = len(pat)
|
||||
} else {
|
||||
if len(pat) != patternLen {
|
||||
return errors.New("Every pattern should have the same length")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for i := range s.Score.Tracks[:len(s.Score.Tracks)-1] {
|
||||
if len(s.Score.Tracks[i].Order) != len(s.Score.Tracks[i+1].Order) {
|
||||
return errors.New("Every track should have the same sequence length")
|
||||
}
|
||||
}
|
||||
totalTrackVoices := 0
|
||||
for _, track := range s.Score.Tracks {
|
||||
totalTrackVoices += track.NumVoices
|
||||
for _, p := range track.Order {
|
||||
if p < 0 || int(p) >= len(track.Patterns) {
|
||||
return errors.New("Tracks use a non-existing pattern")
|
||||
}
|
||||
}
|
||||
}
|
||||
if totalTrackVoices > s.Patch.NumVoices() {
|
||||
if s.Score.NumVoices() > s.Patch.NumVoices() {
|
||||
return errors.New("Tracks use too many voices")
|
||||
}
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user