mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-19 05:24:48 -04:00
Implement a song struct to hold all the information of a single song (corresponding one .asm file) and Render function for it.
This commit is contained in:
@ -28,6 +28,16 @@ type Instrument struct {
|
||||
Units []Unit
|
||||
}
|
||||
|
||||
type Patch []Instrument
|
||||
|
||||
func (p Patch) TotalVoices() int {
|
||||
ret := 0
|
||||
for _, i := range p {
|
||||
ret += i.NumVoices
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
var ( // cannot be const as the rhs are not known at compile-time
|
||||
Add = Opcode(C.su_add_id)
|
||||
Addp = Opcode(C.su_addp_id)
|
||||
@ -100,7 +110,7 @@ func (s *SynthState) Render(buffer []float32, maxRows int, callback func()) (int
|
||||
return maxSamples - remaining, nil
|
||||
}
|
||||
|
||||
func (s *SynthState) SetPatch(patch []Instrument) error {
|
||||
func (s *SynthState) SetPatch(patch Patch) error {
|
||||
totalVoices := 0
|
||||
commands := make([]Opcode, 0)
|
||||
values := make([]byte, 0)
|
||||
@ -138,7 +148,7 @@ func (s *SynthState) SetPatch(patch []Instrument) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SynthState) Trigger(voice int, note int) {
|
||||
func (s *SynthState) Trigger(voice int, note byte) {
|
||||
cs := (*C.SynthState)(s)
|
||||
cs.Synth.Voices[voice] = C.Voice{}
|
||||
cs.Synth.Voices[voice].Note = C.int(note)
|
||||
@ -149,6 +159,10 @@ func (s *SynthState) Release(voice int) {
|
||||
cs.Synth.Voices[voice].Release = 1
|
||||
}
|
||||
|
||||
func (s *SynthState) SetSamplesPerRow(spr int) {
|
||||
s.SamplesPerRow = C.uint(spr)
|
||||
}
|
||||
|
||||
func NewSynthState() *SynthState {
|
||||
s := new(SynthState)
|
||||
s.RandSeed = 1
|
||||
|
Reference in New Issue
Block a user