reorganize things into different packages

This commit is contained in:
vsariola
2021-03-02 17:19:45 +02:00
parent e46ece3648
commit a035845b81
19 changed files with 43 additions and 38 deletions

View File

@ -0,0 +1,39 @@
package compiler
import (
"fmt"
"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
}
func (p *SongMacros) NumDelayLines() string {
total := 0
for _, instr := range p.Song.Patch {
for _, unit := range instr.Units {
if unit.Type == "delay" {
total += unit.Parameters["count"] * (1 + unit.Parameters["stereo"])
}
}
}
return fmt.Sprintf("%v", total)
}