refactor(vm): use vm.GoSynther{}.Synth instead of vm.Synth

vm.Synth was used only in a few places, reduce the number of
exported functions. Also, if we ever add some global configuration
to GoSynther e.g. samplerate, we have a mechanism to do so, instead
of the Synth function.
This commit is contained in:
5684185+vsariola@users.noreply.github.com 2023-10-19 12:52:05 +03:00
parent 7675121a78
commit 960bddfae0
2 changed files with 3 additions and 8 deletions

View File

@ -93,7 +93,7 @@ success:
f.Read(su_sample_table[:])
}
func Synth(patch sointu.Patch, bpm int) (sointu.Synth, error) {
func (s GoSynther) Synth(patch sointu.Patch, bpm int) (sointu.Synth, error) {
bytecode, err := NewBytecode(patch, AllFeatures{}, bpm)
if err != nil {
return nil, fmt.Errorf("error compiling %v", err)
@ -103,11 +103,6 @@ func Synth(patch sointu.Patch, bpm int) (sointu.Synth, error) {
return ret, nil
}
func (s GoSynther) Synth(patch sointu.Patch, bpm int) (sointu.Synth, error) {
synth, err := Synth(patch, bpm)
return synth, err
}
func (s *GoSynth) Trigger(voiceIndex int, note byte) {
s.state.voices[voiceIndex] = voice{}
s.state.voices[voiceIndex].note = note

View File

@ -78,7 +78,7 @@ func TestStackUnderflow(t *testing.T) {
patch := sointu.Patch{sointu.Instrument{NumVoices: 1, Units: []sointu.Unit{
sointu.Unit{Type: "pop", Parameters: map[string]int{}},
}}}
synth, err := vm.Synth(patch, 120)
synth, err := vm.GoSynther{}.Synth(patch, 120)
if err != nil {
t.Fatalf("bridge compile error: %v", err)
}
@ -94,7 +94,7 @@ func TestStackBalancing(t *testing.T) {
sointu.Instrument{NumVoices: 1, Units: []sointu.Unit{
sointu.Unit{Type: "push", Parameters: map[string]int{}},
}}}
synth, err := vm.Synth(patch, 120)
synth, err := vm.GoSynther{}.Synth(patch, 120)
if err != nil {
t.Fatalf("bridge compile error: %v", err)
}