feat!: implement vsti, along with various refactorings and api changes for it

The RPC and sync library mechanisms were removed for now; they never really worked and contained several obvious bugs. Need to consider if syncs are useful at all during the compose time, or just used during intro.
This commit is contained in:
5684185+vsariola@users.noreply.github.com
2023-05-09 11:24:49 +03:00
parent 70080c2b9d
commit cd700ed954
34 changed files with 1210 additions and 750 deletions

View File

@ -115,7 +115,7 @@ func (s *Interpreter) Update(patch sointu.Patch) error {
return nil
}
func (s *Interpreter) Render(buffer []float32, syncBuf []float32, maxtime int) (samples int, syncs int, time int, renderError error) {
func (s *Interpreter) Render(buffer []float32, maxtime int) (samples int, time int, renderError error) {
defer func() {
if err := recover(); err != nil {
renderError = fmt.Errorf("render panicced: %v", err)
@ -133,10 +133,6 @@ func (s *Interpreter) Render(buffer []float32, syncBuf []float32, maxtime int) (
voicesRemaining := s.bytePatch.NumVoices
voices := s.synth.voices[:]
units := voices[0].units[:]
if byte(s.synth.globalTime) == 0 { // every 256 samples
syncBuf[0], syncBuf = float32(time), syncBuf[1:]
syncs++
}
for voicesRemaining > 0 {
op := commands[0]
commands = commands[1:]
@ -156,7 +152,7 @@ func (s *Interpreter) Render(buffer []float32, syncBuf []float32, maxtime int) (
}
tcount := transformCounts[opNoStereo-1]
if len(values) < tcount {
return samples, syncs, time, errors.New("value stream ended prematurely")
return samples, time, errors.New("value stream ended prematurely")
}
voice := &voices[0]
unit := &units[0]
@ -527,19 +523,17 @@ func (s *Interpreter) Render(buffer []float32, syncBuf []float32, maxtime int) (
stack = append(stack, gain)
}
case opSync:
if byte(s.synth.globalTime) == 0 { // every 256 samples
syncBuf[0], syncBuf = float32(stack[l-1]), syncBuf[1:]
}
break
default:
return samples, syncs, time, errors.New("invalid / unimplemented opcode")
return samples, time, errors.New("invalid / unimplemented opcode")
}
units = units[1:]
}
if len(stack) < 4 {
return samples, syncs, time, errors.New("stack underflow")
return samples, time, errors.New("stack underflow")
}
if len(stack) > 4 {
return samples, syncs, time, errors.New("stack not empty")
return samples, time, errors.New("stack not empty")
}
buffer[0] = synth.outputs[0]
buffer[1] = synth.outputs[1]
@ -551,7 +545,7 @@ func (s *Interpreter) Render(buffer []float32, syncBuf []float32, maxtime int) (
s.synth.globalTime++
}
s.stack = stack[:0]
return samples, syncs, time, nil
return samples, time, nil
}
func (s *synth) rand() float32 {