mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-28 03:10:24 -04:00
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
36 lines
751 B
Go
36 lines
751 B
Go
package sointu
|
|
|
|
import (
|
|
"errors"
|
|
)
|
|
|
|
type Song struct {
|
|
BPM int
|
|
RowsPerBeat int
|
|
Score Score
|
|
Patch Patch
|
|
}
|
|
|
|
func (s *Song) Copy() Song {
|
|
return Song{BPM: s.BPM, RowsPerBeat: s.RowsPerBeat, Score: s.Score.Copy(), Patch: s.Patch.Copy()}
|
|
}
|
|
|
|
func (s *Song) SamplesPerRow() int {
|
|
return 44100 * 60 / (s.BPM * s.RowsPerBeat)
|
|
}
|
|
|
|
// TBD: Where shall we put methods that work on pure domain types and have no dependencies
|
|
// e.g. Validate here
|
|
func (s *Song) Validate() error {
|
|
if s.BPM < 1 {
|
|
return errors.New("BPM should be > 0")
|
|
}
|
|
if len(s.Score.Tracks) == 0 {
|
|
return errors.New("song contains no tracks")
|
|
}
|
|
if s.Score.NumVoices() > s.Patch.NumVoices() {
|
|
return errors.New("Tracks use too many voices")
|
|
}
|
|
return nil
|
|
}
|