mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-28 03:10:24 -04:00
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:
parent
7675121a78
commit
960bddfae0
@ -93,7 +93,7 @@ success:
|
|||||||
f.Read(su_sample_table[:])
|
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)
|
bytecode, err := NewBytecode(patch, AllFeatures{}, bpm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error compiling %v", err)
|
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
|
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) {
|
func (s *GoSynth) Trigger(voiceIndex int, note byte) {
|
||||||
s.state.voices[voiceIndex] = voice{}
|
s.state.voices[voiceIndex] = voice{}
|
||||||
s.state.voices[voiceIndex].note = note
|
s.state.voices[voiceIndex].note = note
|
||||||
|
@ -78,7 +78,7 @@ func TestStackUnderflow(t *testing.T) {
|
|||||||
patch := sointu.Patch{sointu.Instrument{NumVoices: 1, Units: []sointu.Unit{
|
patch := sointu.Patch{sointu.Instrument{NumVoices: 1, Units: []sointu.Unit{
|
||||||
sointu.Unit{Type: "pop", Parameters: map[string]int{}},
|
sointu.Unit{Type: "pop", Parameters: map[string]int{}},
|
||||||
}}}
|
}}}
|
||||||
synth, err := vm.Synth(patch, 120)
|
synth, err := vm.GoSynther{}.Synth(patch, 120)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("bridge compile error: %v", err)
|
t.Fatalf("bridge compile error: %v", err)
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ func TestStackBalancing(t *testing.T) {
|
|||||||
sointu.Instrument{NumVoices: 1, Units: []sointu.Unit{
|
sointu.Instrument{NumVoices: 1, Units: []sointu.Unit{
|
||||||
sointu.Unit{Type: "push", Parameters: map[string]int{}},
|
sointu.Unit{Type: "push", Parameters: map[string]int{}},
|
||||||
}}}
|
}}}
|
||||||
synth, err := vm.Synth(patch, 120)
|
synth, err := vm.GoSynther{}.Synth(patch, 120)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("bridge compile error: %v", err)
|
t.Fatalf("bridge compile error: %v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user