From d5886c0920017d0cc4565258f523e6c098adf08d Mon Sep 17 00:00:00 2001 From: Veikko Sariola Date: Sun, 8 Nov 2020 10:17:43 +0200 Subject: [PATCH] Change unison to be in the range of 0 - 3. With this change, forgetting to initialize unison results in the default behaviour: 0 means one oscillator, 3 means four oscillators in unison. --- go4k/asmformat.go | 8 ++++---- go4k/bridge/bridge.go | 2 +- go4k/song_test.go | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/go4k/asmformat.go b/go4k/asmformat.go index 3944f30..ebbb886 100644 --- a/go4k/asmformat.go +++ b/go4k/asmformat.go @@ -184,13 +184,13 @@ func ParseAsm(reader io.Reader) (*Song, error) { return nil, errors.New("Invalid oscillator type") } if flags["UNISON4"] { - parameters["unison"] = 4 - } else if flags["UNISON3"] { parameters["unison"] = 3 - } else if flags["UNISON2"] { + } else if flags["UNISON3"] { parameters["unison"] = 2 - } else { + } else if flags["UNISON2"] { parameters["unison"] = 1 + } else { + parameters["unison"] = 0 } if flags["LFO"] { parameters["lfo"] = 1 diff --git a/go4k/bridge/bridge.go b/go4k/bridge/bridge.go index 9d5dcb7..93b5bfc 100644 --- a/go4k/bridge/bridge.go +++ b/go4k/bridge/bridge.go @@ -128,7 +128,7 @@ func Synth(patch go4k.Patch) (*C.Synth, error) { if unit.Parameters["lfo"] == 1 { flags += 0x08 } - flags += unit.Parameters["unison"] - 1 + flags += unit.Parameters["unison"] values = append(values, byte(flags)) } else if unit.Type == "filter" { flags := 0 diff --git a/go4k/song_test.go b/go4k/song_test.go index 4f42575..b59c7f3 100644 --- a/go4k/song_test.go +++ b/go4k/song_test.go @@ -25,10 +25,10 @@ const su_max_samples = SAMPLES_PER_ROW * TOTAL_ROWS func TestPlayer(t *testing.T) { patch := go4k.Patch{go4k.Instrument{1, []go4k.Unit{ go4k.Unit{"envelope", false, map[string]int{"attack": 32, "decay": 32, "sustain": 64, "release": 64, "gain": 128}}, - go4k.Unit{"oscillator", false, map[string]int{"transpose": 64, "detune": 64, "phase": 0, "color": 96, "shape": 64, "gain": 128, "type": go4k.Sine, "lfo": 0, "unison": 1}}, + go4k.Unit{"oscillator", false, map[string]int{"transpose": 64, "detune": 64, "phase": 0, "color": 96, "shape": 64, "gain": 128, "type": go4k.Sine, "lfo": 0, "unison": 0}}, go4k.Unit{"mulp", false, map[string]int{}}, go4k.Unit{"envelope", false, map[string]int{"attack": 32, "decay": 32, "sustain": 64, "release": 64, "gain": 128}}, - go4k.Unit{"oscillator", false, map[string]int{"transpose": 72, "detune": 64, "phase": 64, "color": 64, "shape": 96, "gain": 128, "type": go4k.Sine, "lfo": 0, "unison": 1}}, + go4k.Unit{"oscillator", false, map[string]int{"transpose": 72, "detune": 64, "phase": 64, "color": 64, "shape": 96, "gain": 128, "type": go4k.Sine, "lfo": 0, "unison": 0}}, go4k.Unit{"mulp", false, map[string]int{}}, go4k.Unit{"out", true, map[string]int{"gain": 128}}, }}}