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:
vsariola
2021-03-02 20:47:17 +02:00
parent a035845b81
commit 6d2b63a5e9
13 changed files with 891 additions and 58 deletions

28
song.go
View File

@ -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