mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-28 03:10:24 -04:00
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.
40 lines
854 B
Go
40 lines
854 B
Go
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)
|
|
}
|