refactor(asm&go4k): Remove special treatment from stereo parameters; it's now just one parameter in the Unit map.

This commit is contained in:
Veikko Sariola
2020-11-10 20:45:41 +02:00
parent 01c39ffc15
commit f7017892a5
101 changed files with 787 additions and 802 deletions

View File

@ -130,35 +130,30 @@ func DeserializeAsm(asmcode string) (*Song, error) {
}
if inInstrument && strings.HasPrefix(word, "SU_") {
unittype := strings.ToLower(word[3:])
instrMatch := wordReg.FindStringSubmatch(rest)
if instrMatch != nil {
stereoMono, instrRest := instrMatch[1], instrMatch[2]
stereo := stereoMono == "STEREO"
parameters, err := parseParams(instrRest)
if err != nil {
return nil, fmt.Errorf("Error parsing parameters: %v", err)
}
if unittype == "oscillator" {
match := typeReg.FindStringSubmatch(instrRest)
if match == nil {
return nil, errors.New("Oscillator should define a type")
}
switch match[1] {
case "SINE":
parameters["type"] = Sine
case "TRISAW":
parameters["type"] = Trisaw
case "PULSE":
parameters["type"] = Pulse
case "GATE":
parameters["type"] = Gate
case "SAMPLE":
parameters["type"] = Sample
}
}
unit := Unit{Type: unittype, Stereo: stereo, Parameters: parameters}
instr.Units = append(instr.Units, unit)
parameters, err := parseParams(rest)
if err != nil {
return nil, fmt.Errorf("Error parsing parameters: %v", err)
}
if unittype == "oscillator" {
match := typeReg.FindStringSubmatch(rest)
if match == nil {
return nil, errors.New("Oscillator should define a type")
}
switch match[1] {
case "SINE":
parameters["type"] = Sine
case "TRISAW":
parameters["type"] = Trisaw
case "PULSE":
parameters["type"] = Pulse
case "GATE":
parameters["type"] = Gate
case "SAMPLE":
parameters["type"] = Sample
}
}
unit := Unit{Type: unittype, Parameters: parameters}
instr.Units = append(instr.Units, unit)
}
}
}
@ -167,7 +162,7 @@ func DeserializeAsm(asmcode string) (*Song, error) {
if patch[i].Units[u].Type == "delay" {
s := patch[i].Units[u].Parameters["delay"]
e := patch[i].Units[u].Parameters["count"]
if patch[i].Units[u].Stereo {
if patch[i].Units[u].Parameters["stereo"] == 1 {
e *= 2 // stereo delays use 'count' number of delaytimes, but for both channels
}
patch[i].Units[u].DelayTimes = append(patch[i].Units[u].DelayTimes, delayTimes[s:e]...)
@ -188,35 +183,35 @@ func DeserializeAsm(asmcode string) (*Song, error) {
func SerializeAsm(song *Song) (string, error) {
paramorder := map[string][]string{
"add": []string{},
"addp": []string{},
"pop": []string{},
"loadnote": []string{},
"mul": []string{},
"mulp": []string{},
"push": []string{},
"xch": []string{},
"distort": []string{"drive"},
"hold": []string{"holdfreq"},
"crush": []string{"resolution"},
"gain": []string{"gain"},
"invgain": []string{"invgain"},
"filter": []string{"frequency", "resonance", "lowpass", "bandpass", "highpass", "negbandpass", "neghighpass"},
"clip": []string{},
"pan": []string{"panning"},
"delay": []string{"pregain", "dry", "feedback", "damp", "delay", "count", "notetracking"},
"compressor": []string{"attack", "release", "invgain", "threshold", "ratio"},
"add": []string{"stereo"},
"addp": []string{"stereo"},
"pop": []string{"stereo"},
"loadnote": []string{"stereo"},
"mul": []string{"stereo"},
"mulp": []string{"stereo"},
"push": []string{"stereo"},
"xch": []string{"stereo"},
"distort": []string{"stereo", "drive"},
"hold": []string{"stereo", "holdfreq"},
"crush": []string{"stereo", "resolution"},
"gain": []string{"stereo", "gain"},
"invgain": []string{"stereo", "invgain"},
"filter": []string{"stereo", "frequency", "resonance", "lowpass", "bandpass", "highpass", "negbandpass", "neghighpass"},
"clip": []string{"stereo"},
"pan": []string{"stereo", "panning"},
"delay": []string{"stereo", "pregain", "dry", "feedback", "damp", "delay", "count", "notetracking"},
"compressor": []string{"stereo", "attack", "release", "invgain", "threshold", "ratio"},
"speed": []string{},
"out": []string{"gain"},
"outaux": []string{"outgain", "auxgain"},
"aux": []string{"gain", "channel"},
"send": []string{"amount", "voice", "unit", "port", "sendpop"},
"envelope": []string{"attack", "decay", "sustain", "release", "gain"},
"noise": []string{"shape", "gain"},
"oscillator": []string{"transpose", "detune", "phase", "color", "shape", "gain", "type", "lfo", "unison"},
"loadval": []string{"value"},
"receive": []string{},
"in": []string{"channel"},
"out": []string{"stereo", "gain"},
"outaux": []string{"stereo", "outgain", "auxgain"},
"aux": []string{"stereo", "gain", "channel"},
"send": []string{"stereo", "amount", "voice", "unit", "port", "sendpop"},
"envelope": []string{"stereo", "attack", "decay", "sustain", "release", "gain"},
"noise": []string{"stereo", "shape", "gain"},
"oscillator": []string{"stereo", "transpose", "detune", "phase", "color", "shape", "gain", "type", "lfo", "unison"},
"loadval": []string{"stereo", "value"},
"receive": []string{"stereo"},
"in": []string{"stereo", "channel"},
}
indentation := 0
indent := func() string {
@ -338,17 +333,13 @@ func SerializeAsm(song *Song) (string, error) {
for i, instrument := range song.Patch {
var instrTable [][]string
for j, unit := range instrument.Units {
stereomono := "MONO"
if unit.Stereo {
stereomono = "STEREO"
}
row := []string{fmt.Sprintf("SU_%v", strings.ToUpper(unit.Type)), stereomono}
row := []string{fmt.Sprintf("SU_%v", strings.ToUpper(unit.Type))}
for _, parname := range paramorder[unit.Type] {
if unit.Type == "oscillator" && unit.Parameters["type"] == Sample && parname == "color" {
row = append(row, fmt.Sprintf("COLOR(%v)", strconv.Itoa(sampleIndices[i][j])))
} else if unit.Type == "delay" && parname == "count" {
count := len(unit.DelayTimes)
if unit.Stereo {
if unit.Parameters["stereo"] == 1 {
count /= 2
}
row = append(row, fmt.Sprintf("COUNT(%v)", strconv.Itoa(count)))

View File

@ -100,18 +100,18 @@ func Synth(patch go4k.Patch) (*C.Synth, error) {
for unitid, unit := range instr.Units {
if val, ok := opcodeTable[unit.Type]; ok {
opCode := val.opcode
if unit.Stereo {
if unit.Parameters["stereo"] == 1 {
opCode++
}
commands = append(commands, byte(opCode))
for _, paramname := range val.parameterList {
if unit.Type == "delay" && paramname == "delaycount" {
if unit.Stereo && len(unit.DelayTimes)%2 != 0 {
if unit.Parameters["stereo"] == 1 && len(unit.DelayTimes)%2 != 0 {
return nil, errors.New("Stereo delays should have even number of delaytimes")
}
values = append(values, byte(delayIndices[insid][unitid]))
count := len(unit.DelayTimes)
if unit.Stereo {
if unit.Parameters["stereo"] == 1 {
count /= 2
}
count = count*2 - 1

View File

@ -24,9 +24,9 @@ const su_max_samples = SAMPLES_PER_ROW * TOTAL_ROWS
func TestBridge(t *testing.T) {
patch := []go4k.Instrument{
go4k.Instrument{1, []go4k.Unit{
go4k.Unit{"envelope", false, map[string]int{"attack": 64, "decay": 64, "sustain": 64, "release": 80, "gain": 128}, []int{}},
go4k.Unit{"envelope", false, map[string]int{"attack": 95, "decay": 64, "sustain": 64, "release": 80, "gain": 128}, []int{}},
go4k.Unit{"out", true, map[string]int{"gain": 128}, []int{}},
go4k.Unit{"envelope", map[string]int{"stereo": 0, "attack": 64, "decay": 64, "sustain": 64, "release": 80, "gain": 128}, []int{}},
go4k.Unit{"envelope", map[string]int{"stereo": 0, "attack": 95, "decay": 64, "sustain": 64, "release": 80, "gain": 128}, []int{}},
go4k.Unit{"out", map[string]int{"stereo": 1, "gain": 128}, []int{}},
}}}
synth, err := bridge.Synth(patch)
if err != nil {

View File

@ -8,7 +8,6 @@ import (
// Unit is e.g. a filter, oscillator, envelope and its parameters
type Unit struct {
Type string
Stereo bool
Parameters map[string]int
DelayTimes []int
}
@ -88,70 +87,66 @@ type UnitParameter struct {
// UnitType documents the supported behaviour of one type of unit (oscillator, envelope etc.)
type UnitType struct {
Name string
SupportsStereo bool
Parameters []UnitParameter
Name string
Parameters []UnitParameter
}
// UnitTypes documents all the available unit types and if they support stereo variant
// and what parameters they take.
var UnitTypes = []UnitType{
{
Name: "add",
SupportsStereo: true,
Parameters: []UnitParameter{}},
Name: "add",
Parameters: []UnitParameter{{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}}},
{
Name: "addp",
SupportsStereo: true,
Parameters: []UnitParameter{}},
Name: "addp",
Parameters: []UnitParameter{{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}}},
{
Name: "pop",
SupportsStereo: true,
Parameters: []UnitParameter{}},
Name: "pop",
Parameters: []UnitParameter{{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}}},
{
Name: "loadnote",
SupportsStereo: true,
Parameters: []UnitParameter{}},
Name: "loadnote",
Parameters: []UnitParameter{{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}}},
{
Name: "mul",
SupportsStereo: true,
Parameters: []UnitParameter{}},
Name: "mul",
Parameters: []UnitParameter{{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}}},
{
Name: "mulp",
SupportsStereo: true,
Parameters: []UnitParameter{}},
Name: "mulp",
Parameters: []UnitParameter{{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}}},
{
Name: "push",
SupportsStereo: true,
Parameters: []UnitParameter{}},
Name: "push",
Parameters: []UnitParameter{{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}}},
{
Name: "xch",
SupportsStereo: true,
Parameters: []UnitParameter{}},
Name: "xch",
Parameters: []UnitParameter{{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}}},
{
Name: "distort",
SupportsStereo: true,
Parameters: []UnitParameter{{Name: "drive", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true}}},
{
Name: "hold",
SupportsStereo: true,
Parameters: []UnitParameter{{Name: "holdfreq", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true}}},
{
Name: "crush",
SupportsStereo: true,
Parameters: []UnitParameter{{Name: "resolution", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true}}},
{
Name: "gain",
SupportsStereo: true,
Parameters: []UnitParameter{{Name: "gain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true}}},
{
Name: "invgain",
SupportsStereo: true,
Parameters: []UnitParameter{{Name: "invgain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true}}},
{
Name: "filter",
SupportsStereo: true,
Name: "distort",
Parameters: []UnitParameter{
{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false},
{Name: "drive", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true}}},
{
Name: "hold",
Parameters: []UnitParameter{
{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false},
{Name: "holdfreq", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true}}},
{
Name: "crush",
Parameters: []UnitParameter{
{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false},
{Name: "resolution", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true}}},
{
Name: "gain",
Parameters: []UnitParameter{
{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false},
{Name: "gain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true}}},
{
Name: "invgain",
Parameters: []UnitParameter{
{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false},
{Name: "invgain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true}}},
{
Name: "filter",
Parameters: []UnitParameter{
{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false},
{Name: "frequency", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true},
{Name: "resonance", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true},
{Name: "lowpass", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false},
@ -160,17 +155,17 @@ var UnitTypes = []UnitType{
{Name: "negbandpass", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false},
{Name: "neghighpass", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}}},
{
Name: "clip",
SupportsStereo: true,
Parameters: []UnitParameter{}},
Name: "clip",
Parameters: []UnitParameter{{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}}},
{
Name: "pan",
SupportsStereo: true,
Parameters: []UnitParameter{{Name: "panning", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true}}},
{
Name: "delay",
SupportsStereo: true,
Name: "pan",
Parameters: []UnitParameter{
{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false},
{Name: "panning", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true}}},
{
Name: "delay",
Parameters: []UnitParameter{
{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false},
{Name: "pregain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true},
{Name: "dry", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true},
{Name: "feedback", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true},
@ -179,9 +174,9 @@ var UnitTypes = []UnitType{
{Name: "delay", MinValue: 0, MaxValue: -1, CanSet: false, CanModulate: true},
}},
{
Name: "compressor",
SupportsStereo: true,
Name: "compressor",
Parameters: []UnitParameter{
{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false},
{Name: "attack", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true},
{Name: "release", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true},
{Name: "invgain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true},
@ -189,31 +184,31 @@ var UnitTypes = []UnitType{
{Name: "ratio", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true},
}},
{
Name: "speed",
SupportsStereo: false,
Parameters: []UnitParameter{}},
Name: "speed",
Parameters: []UnitParameter{}},
{
Name: "out",
SupportsStereo: true,
Parameters: []UnitParameter{{Name: "gain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true}}},
{
Name: "outaux",
SupportsStereo: true,
Name: "out",
Parameters: []UnitParameter{
{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false},
{Name: "gain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true}}},
{
Name: "outaux",
Parameters: []UnitParameter{
{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false},
{Name: "outgain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true},
{Name: "auxgain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true},
}},
{
Name: "aux",
SupportsStereo: true,
Name: "aux",
Parameters: []UnitParameter{
{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false},
{Name: "gain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true},
{Name: "channel", MinValue: 0, MaxValue: 6, CanSet: true, CanModulate: false},
}},
{
Name: "send",
SupportsStereo: true,
Name: "send",
Parameters: []UnitParameter{
{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false},
{Name: "amount", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true},
{Name: "voice", MinValue: 0, MaxValue: 32, CanSet: true, CanModulate: false},
{Name: "unit", MinValue: 0, MaxValue: 63, CanSet: true, CanModulate: false},
@ -221,9 +216,9 @@ var UnitTypes = []UnitType{
{Name: "sendpop", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false},
}},
{
Name: "envelope",
SupportsStereo: true,
Name: "envelope",
Parameters: []UnitParameter{
{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false},
{Name: "attack", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true},
{Name: "decay", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true},
{Name: "sustain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true},
@ -231,16 +226,16 @@ var UnitTypes = []UnitType{
{Name: "gain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true},
}},
{
Name: "noise",
SupportsStereo: true,
Name: "noise",
Parameters: []UnitParameter{
{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false},
{Name: "shape", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true},
{Name: "gain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true},
}},
{
Name: "oscillator",
SupportsStereo: true,
Name: "oscillator",
Parameters: []UnitParameter{
{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false},
{Name: "transpose", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true},
{Name: "detune", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true},
{Name: "phase", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true},
@ -255,22 +250,22 @@ var UnitTypes = []UnitType{
{Name: "looplength", MinValue: 0, MaxValue: 65535, CanSet: true, CanModulate: false}, // if type is "sample", then the loop length is this i.e. loop ends at "start" + "loopstart" + "looplength"
}},
{
Name: "loadval",
SupportsStereo: true,
Name: "loadval",
Parameters: []UnitParameter{
{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false},
{Name: "value", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true},
}},
{
Name: "receive",
SupportsStereo: true,
Name: "receive",
Parameters: []UnitParameter{
{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false},
{Name: "left", MinValue: 0, MaxValue: -1, CanSet: false, CanModulate: true},
{Name: "right", MinValue: 0, MaxValue: -1, CanSet: false, CanModulate: true},
}},
{
Name: "in",
SupportsStereo: true,
Name: "in",
Parameters: []UnitParameter{
{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false},
{Name: "channel", MinValue: 0, MaxValue: 6, CanSet: true, CanModulate: false},
}},
}

View File

@ -8,7 +8,7 @@ import (
"github.com/vsariola/sointu/go4k"
)
const expectedMarshaled = "{\"BPM\":100,\"Patterns\":[\"QABEACAAAABLAE4AAAAAAA==\"],\"Tracks\":[{\"NumVoices\":1,\"Sequence\":\"AA==\"}],\"SongLength\":0,\"Patch\":[{\"NumVoices\":1,\"Units\":[{\"Type\":\"envelope\",\"Stereo\":false,\"Parameters\":{\"attack\":32,\"decay\":32,\"gain\":128,\"release\":64,\"sustain\":64},\"DelayTimes\":[]},{\"Type\":\"oscillator\",\"Stereo\":false,\"Parameters\":{\"color\":96,\"detune\":64,\"flags\":64,\"gain\":128,\"phase\":0,\"shape\":64,\"transpose\":64},\"DelayTimes\":[]},{\"Type\":\"mulp\",\"Stereo\":false,\"Parameters\":{},\"DelayTimes\":[]},{\"Type\":\"envelope\",\"Stereo\":false,\"Parameters\":{\"attack\":32,\"decay\":32,\"gain\":128,\"release\":64,\"sustain\":64},\"DelayTimes\":[]},{\"Type\":\"oscillator\",\"Stereo\":false,\"Parameters\":{\"color\":64,\"detune\":64,\"flags\":64,\"gain\":128,\"phase\":64,\"shape\":96,\"transpose\":72},\"DelayTimes\":[]},{\"Type\":\"mulp\",\"Stereo\":false,\"Parameters\":{},\"DelayTimes\":[]},{\"Type\":\"out\",\"Stereo\":true,\"Parameters\":{\"gain\":128},\"DelayTimes\":[]}]}]}"
const expectedMarshaled = `{"BPM":100,"Patterns":["QABEACAAAABLAE4AAAAAAA=="],"Tracks":[{"NumVoices":1,"Sequence":"AA=="}],"SongLength":0,"Patch":[{"NumVoices":1,"Units":[{"Type":"envelope","Parameters":{"attack":32,"decay":32,"gain":128,"release":64,"stereo":0,"sustain":64},"DelayTimes":[]},{"Type":"oscillator","Parameters":{"color":96,"detune":64,"flags":64,"gain":128,"phase":0,"shape":64,"stereo":0,"transpose":64},"DelayTimes":[]},{"Type":"mulp","Parameters":{"stereo":0},"DelayTimes":[]},{"Type":"envelope","Parameters":{"attack":32,"decay":32,"gain":128,"release":64,"stereo":0,"sustain":64},"DelayTimes":[]},{"Type":"oscillator","Parameters":{"color":64,"detune":64,"flags":64,"gain":128,"phase":64,"shape":96,"stereo":0,"transpose":72},"DelayTimes":[]},{"Type":"mulp","Parameters":{"stereo":0},"DelayTimes":[]},{"Type":"out","Parameters":{"gain":128,"stereo":1},"DelayTimes":[]}]}]}`
var testSong = go4k.Song{
BPM: 100,
@ -19,13 +19,13 @@ var testSong = go4k.Song{
SongLength: 0,
Patch: go4k.Patch{
go4k.Instrument{NumVoices: 1, Units: []go4k.Unit{
{"envelope", false, map[string]int{"attack": 32, "decay": 32, "sustain": 64, "release": 64, "gain": 128}, []int{}},
{"oscillator", false, map[string]int{"transpose": 64, "detune": 64, "phase": 0, "color": 96, "shape": 64, "gain": 128, "flags": 0x40}, []int{}},
{"mulp", false, map[string]int{}, []int{}},
{"envelope", false, map[string]int{"attack": 32, "decay": 32, "sustain": 64, "release": 64, "gain": 128}, []int{}},
{"oscillator", false, map[string]int{"transpose": 72, "detune": 64, "phase": 64, "color": 64, "shape": 96, "gain": 128, "flags": 0x40}, []int{}},
{"mulp", false, map[string]int{}, []int{}},
{"out", true, map[string]int{"gain": 128}, []int{}},
{"envelope", map[string]int{"stereo": 0, "attack": 32, "decay": 32, "sustain": 64, "release": 64, "gain": 128}, []int{}},
{"oscillator", map[string]int{"stereo": 0, "transpose": 64, "detune": 64, "phase": 0, "color": 96, "shape": 64, "gain": 128, "flags": 0x40}, []int{}},
{"mulp", map[string]int{"stereo": 0}, []int{}},
{"envelope", map[string]int{"stereo": 0, "attack": 32, "decay": 32, "sustain": 64, "release": 64, "gain": 128}, []int{}},
{"oscillator", map[string]int{"stereo": 0, "transpose": 72, "detune": 64, "phase": 64, "color": 64, "shape": 96, "gain": 128, "flags": 0x40}, []int{}},
{"mulp", map[string]int{"stereo": 0}, []int{}},
{"out", map[string]int{"stereo": 1, "gain": 128}, []int{}},
}},
},
}

View File

@ -24,13 +24,13 @@ const su_max_samples = SAMPLES_PER_ROW * TOTAL_ROWS
func TestPlayer(t *testing.T) {
patch := []go4k.Instrument{go4k.Instrument{1, []go4k.Unit{
go4k.Unit{"envelope", false, map[string]int{"attack": 32, "decay": 32, "sustain": 64, "release": 64, "gain": 128}, []int{}},
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}, []int{}},
go4k.Unit{"mulp", false, map[string]int{}, []int{}},
go4k.Unit{"envelope", false, map[string]int{"attack": 32, "decay": 32, "sustain": 64, "release": 64, "gain": 128}, []int{}},
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}, []int{}},
go4k.Unit{"mulp", false, map[string]int{}, []int{}},
go4k.Unit{"out", true, map[string]int{"gain": 128}, []int{}},
go4k.Unit{"envelope", map[string]int{"stereo": 0, "attack": 32, "decay": 32, "sustain": 64, "release": 64, "gain": 128}, []int{}},
go4k.Unit{"oscillator", map[string]int{"stereo": 0, "transpose": 64, "detune": 64, "phase": 0, "color": 96, "shape": 64, "gain": 128, "type": go4k.Sine, "lfo": 0, "unison": 0}, []int{}},
go4k.Unit{"mulp", map[string]int{"stereo": 0}, []int{}},
go4k.Unit{"envelope", map[string]int{"stereo": 0, "attack": 32, "decay": 32, "sustain": 64, "release": 64, "gain": 128}, []int{}},
go4k.Unit{"oscillator", map[string]int{"stereo": 0, "transpose": 72, "detune": 64, "phase": 64, "color": 64, "shape": 96, "gain": 128, "type": go4k.Sine, "lfo": 0, "unison": 0}, []int{}},
go4k.Unit{"mulp", map[string]int{"stereo": 0}, []int{}},
go4k.Unit{"out", map[string]int{"stereo": 1, "gain": 128}, []int{}},
}}}
patterns := [][]byte{{64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0}}
tracks := []go4k.Track{go4k.Track{1, []byte{0}}}

View File

@ -15,13 +15,13 @@ var defaultSong = go4k.Song{
SongLength: 0,
Patch: go4k.Patch{
go4k.Instrument{NumVoices: 2, Units: []go4k.Unit{
{"envelope", false, map[string]int{"attack": 32, "decay": 32, "sustain": 64, "release": 64, "gain": 128}, []int{}},
{"oscillator", false, map[string]int{"transpose": 64, "detune": 64, "phase": 0, "color": 96, "shape": 64, "gain": 128, "type": go4k.Sine}, []int{}},
{"mulp", false, map[string]int{}, []int{}},
{"envelope", false, map[string]int{"attack": 32, "decay": 32, "sustain": 64, "release": 64, "gain": 128}, []int{}},
{"oscillator", false, map[string]int{"transpose": 72, "detune": 64, "phase": 64, "color": 64, "shape": 96, "gain": 128, "type": go4k.Sine}, []int{}},
{"mulp", false, map[string]int{}, []int{}},
{"out", true, map[string]int{"gain": 128}, []int{}},
{"envelope", map[string]int{"stereo": 0, "attack": 32, "decay": 32, "sustain": 64, "release": 64, "gain": 128}, []int{}},
{"oscillator", map[string]int{"stereo": 0, "transpose": 64, "detune": 64, "phase": 0, "color": 96, "shape": 64, "gain": 128, "type": go4k.Sine}, []int{}},
{"mulp", map[string]int{"stereo": 0}, []int{}},
{"envelope", map[string]int{"stereo": 0, "attack": 32, "decay": 32, "sustain": 64, "release": 64, "gain": 128}, []int{}},
{"oscillator", map[string]int{"stereo": 0, "transpose": 72, "detune": 64, "phase": 64, "color": 64, "shape": 96, "gain": 128, "type": go4k.Sine}, []int{}},
{"mulp", map[string]int{"stereo": 0}, []int{}},
{"out", map[string]int{"stereo": 1, "gain": 128}, []int{}},
}},
},
}