fix(bridge): respect the hard limit of 64 delay lines to avoid crashes.

This commit is contained in:
vsariola 2021-05-08 16:51:45 +03:00
parent e649b9ec54
commit e9834110ec

View File

@ -23,6 +23,9 @@ func (s BridgeService) Compile(patch sointu.Patch) (sointu.Synth, error) {
func Synth(patch sointu.Patch) (*C.Synth, error) {
s := new(C.Synth)
if n := patch.NumDelayLines(); n > 64 {
return nil, fmt.Errorf("native bridge has currently a hard limit of 64 delaylines; patch uses %v", n)
}
comPatch, err := vm.Encode(patch, vm.AllFeatures{})
if err != nil {
return nil, fmt.Errorf("error compiling patch: %v", err)
@ -103,6 +106,9 @@ func (s *C.Synth) Release(voice int) {
// Update
func (s *C.Synth) Update(patch sointu.Patch) error {
if n := patch.NumDelayLines(); n > 64 {
return fmt.Errorf("native bridge has currently a hard limit of 64 delaylines; patch uses %v", n)
}
comPatch, err := vm.Encode(patch, vm.AllFeatures{})
if err != nil {
return fmt.Errorf("error compiling patch: %v", err)