mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-18 13:04:25 -04:00
fix(vm/compiler/bridge): empty patch should not crash native synth
Fixes #148.
This commit is contained in:
parent
2b38e11643
commit
7d6daba3d2
@ -38,6 +38,13 @@ func Synth(patch sointu.Patch, bpm int) (*NativeSynth, error) {
|
||||
if len(comPatch.Operands) > 16384 { // TODO: 16384 could probably be pulled automatically from cgo
|
||||
return nil, errors.New("bridge supports at most 16384 operands; the compiled patch has more")
|
||||
}
|
||||
// if the patch is empty, we still need to initialize the synth with a single opcode
|
||||
if len(comPatch.Opcodes) == 0 {
|
||||
s.Opcodes[0] = 0
|
||||
s.NumVoices = 1
|
||||
s.Polyphony = 0
|
||||
return (*NativeSynth)(s), nil
|
||||
}
|
||||
for i, v := range comPatch.Opcodes {
|
||||
s.Opcodes[i] = (C.uchar)(v)
|
||||
}
|
||||
@ -130,6 +137,13 @@ func (bridgesynth *NativeSynth) Update(patch sointu.Patch, bpm int) error {
|
||||
if len(comPatch.Operands) > 16384 { // TODO: 16384 could probably be pulled automatically from cgo
|
||||
return errors.New("bridge supports at most 16384 operands; the compiled patch has more")
|
||||
}
|
||||
// if the patch is empty, we still need to initialize the synth with a single opcode
|
||||
if len(comPatch.Opcodes) == 0 {
|
||||
s.Opcodes[0] = 0
|
||||
s.NumVoices = 1
|
||||
s.Polyphony = 0
|
||||
return nil
|
||||
}
|
||||
needsRefresh := false
|
||||
for i, v := range comPatch.Opcodes {
|
||||
if cmdChar := (C.uchar)(v); s.Opcodes[i] != cmdChar {
|
||||
|
Reference in New Issue
Block a user