mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-14 02:54:37 -04:00
feat(tracker): adding, setting, unsetting and deleting units
This commit is contained in:
@ -1,14 +1,65 @@
|
||||
package tracker
|
||||
|
||||
import "github.com/vsariola/sointu"
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"github.com/vsariola/sointu"
|
||||
)
|
||||
|
||||
var defaultUnits = map[string]sointu.Unit{
|
||||
"envelope": {Type: "envelope", Parameters: map[string]int{"stereo": 0, "attack": 64, "decay": 64, "sustain": 64, "release": 64, "gain": 64}},
|
||||
"oscillator": {Type: "oscillator", Parameters: map[string]int{"stereo": 0, "transpose": 64, "detune": 64, "phase": 0, "color": 64, "shape": 64, "gain": 64, "type": sointu.Sine}},
|
||||
"noise": {Type: "noise", Parameters: map[string]int{"stereo": 0, "shape": 64, "gain": 64}},
|
||||
"mulp": {Type: "mulp", Parameters: map[string]int{"stereo": 0}},
|
||||
"mul": {Type: "mul", Parameters: map[string]int{"stereo": 0}},
|
||||
"add": {Type: "add", Parameters: map[string]int{"stereo": 0}},
|
||||
"addp": {Type: "addp", Parameters: map[string]int{"stereo": 0}},
|
||||
"push": {Type: "push", Parameters: map[string]int{"stereo": 0}},
|
||||
"pop": {Type: "pop", Parameters: map[string]int{"stereo": 0}},
|
||||
"xch": {Type: "xch", Parameters: map[string]int{"stereo": 0}},
|
||||
"receive": {Type: "receive", Parameters: map[string]int{"stereo": 0}},
|
||||
"loadnote": {Type: "loadnote", Parameters: map[string]int{"stereo": 0}},
|
||||
"loadval": {Type: "loadval", Parameters: map[string]int{"stereo": 0, "value": 64}},
|
||||
"pan": {Type: "pan", Parameters: map[string]int{"stereo": 0, "panning": 64}},
|
||||
"gain": {Type: "gain", Parameters: map[string]int{"stereo": 0, "gain": 64}},
|
||||
"invgain": {Type: "invgain", Parameters: map[string]int{"stereo": 0, "invgain": 64}},
|
||||
"crush": {Type: "crush", Parameters: map[string]int{"stereo": 0, "resolution": 64}},
|
||||
"clip": {Type: "clip", Parameters: map[string]int{"stereo": 0}},
|
||||
"hold": {Type: "hold", Parameters: map[string]int{"stereo": 0, "holdfreq": 64}},
|
||||
"distort": {Type: "distort", Parameters: map[string]int{"stereo": 0, "drive": 64}},
|
||||
"filter": {Type: "filter", Parameters: map[string]int{"stereo": 0, "frequency": 64, "resonance": 64, "lowpass": 1, "bandpass": 0, "highpass": 0, "negbandpass": 0, "neghighpass": 0}},
|
||||
"out": {Type: "out", Parameters: map[string]int{"stereo": 1, "gain": 64}},
|
||||
"outaux": {Type: "outaux", Parameters: map[string]int{"stereo": 1, "outgain": 64, "auxgain": 64}},
|
||||
"aux": {Type: "aux", Parameters: map[string]int{"stereo": 1, "gain": 64, "channel": 2}},
|
||||
"delay": {Type: "delay",
|
||||
Parameters: map[string]int{"damp": 0, "dry": 128, "feedback": 96, "notetracking": 0, "pregain": 40, "stereo": 0},
|
||||
VarArgs: []int{1116, 1188, 1276, 1356, 1422, 1492, 1556, 1618,
|
||||
1140, 1212, 1300, 1380, 1446, 1516, 1580, 1642,
|
||||
}},
|
||||
"in": {Type: "in", Parameters: map[string]int{"stereo": 1, "channel": 2}},
|
||||
"speed": {Type: "speed", Parameters: map[string]int{}},
|
||||
"compressor": {Type: "compressor", Parameters: map[string]int{"stereo": 0, "attack": 64, "release": 64, "invgain": 64, "threshold": 64, "ratio": 64}},
|
||||
}
|
||||
|
||||
var allUnits []string
|
||||
|
||||
func init() {
|
||||
allUnits = make([]string, 0, len(sointu.UnitTypes))
|
||||
for k := range sointu.UnitTypes {
|
||||
allUnits = append(allUnits, k)
|
||||
}
|
||||
sort.Strings(allUnits)
|
||||
}
|
||||
|
||||
var defaultInstrument = sointu.Instrument{
|
||||
NumVoices: 1,
|
||||
Units: []sointu.Unit{
|
||||
{Type: "envelope", Parameters: map[string]int{"stereo": 1, "attack": 32, "decay": 32, "sustain": 64, "release": 64, "gain": 64}},
|
||||
{Type: "oscillator", Parameters: map[string]int{"stereo": 1, "transpose": 64, "detune": 64, "phase": 0, "color": 128, "shape": 64, "gain": 64, "type": sointu.Sine}},
|
||||
{Type: "mulp", Parameters: map[string]int{"stereo": 1}},
|
||||
{Type: "out", Parameters: map[string]int{"stereo": 1, "gain": 64}},
|
||||
defaultUnits["envelope"],
|
||||
defaultUnits["oscillator"],
|
||||
defaultUnits["mulp"],
|
||||
defaultUnits["delay"],
|
||||
defaultUnits["pan"],
|
||||
defaultUnits["out"],
|
||||
},
|
||||
}
|
||||
|
||||
@ -20,16 +71,5 @@ var defaultSong = sointu.Song{
|
||||
{NumVoices: 2, Sequence: []byte{0, 0, 0, 1}, Patterns: [][]byte{{64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0}, {64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 75, 0, 75, 0, 80, 0}}},
|
||||
{NumVoices: 2, Sequence: []byte{0, 0, 0, 1}, Patterns: [][]byte{{0, 0, 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0}, {32, 0, 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 68, 0, 68, 0}}},
|
||||
},
|
||||
Patch: sointu.Patch{
|
||||
Instruments: []sointu.Instrument{{NumVoices: 4, Units: []sointu.Unit{
|
||||
{Type: "envelope", Parameters: map[string]int{"stereo": 1, "attack": 32, "decay": 32, "sustain": 64, "release": 64, "gain": 64}},
|
||||
{Type: "oscillator", Parameters: map[string]int{"stereo": 1, "transpose": 64, "detune": 64, "phase": 0, "color": 128, "shape": 64, "gain": 64, "type": sointu.Sine}},
|
||||
{Type: "mulp", Parameters: map[string]int{"stereo": 1}},
|
||||
{Type: "delay",
|
||||
Parameters: map[string]int{"damp": 0, "dry": 128, "feedback": 96, "notetracking": 0, "pregain": 40, "stereo": 1},
|
||||
VarArgs: []int{1116, 1188, 1276, 1356, 1422, 1492, 1556, 1618,
|
||||
1140, 1212, 1300, 1380, 1446, 1516, 1580, 1642,
|
||||
}},
|
||||
{Type: "out", Parameters: map[string]int{"stereo": 1, "gain": 64}},
|
||||
}}}},
|
||||
Patch: sointu.Patch{Instruments: []sointu.Instrument{{NumVoices: 4, Units: defaultInstrument.Units}}},
|
||||
}
|
||||
|
Reference in New Issue
Block a user