sointu/vm/compiler/song_macros.go
vsariola 6d2b63a5e9 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
2021-03-03 23:55:58 +02:00

26 lines
564 B
Go

package compiler
import (
"github.com/vsariola/sointu"
)
type SongMacros struct {
Song *sointu.Song
VoiceTrackBitmask int
MaxSamples int
}
func NewSongMacros(s *sointu.Song) *SongMacros {
maxSamples := s.SamplesPerRow() * s.Score.LengthInRows()
p := SongMacros{Song: s, MaxSamples: maxSamples}
trackVoiceNumber := 0
for _, t := range s.Score.Tracks {
for b := 0; b < t.NumVoices-1; b++ {
p.VoiceTrackBitmask += 1 << trackVoiceNumber
trackVoiceNumber++
}
trackVoiceNumber++ // set all bits except last one
}
return &p
}