feat(sointu): add functions to figure out the stack use and need of a unit

This commit is contained in:
vsariola
2021-02-10 22:39:08 +02:00
parent 35d2ff6308
commit 8cfd915311
4 changed files with 63 additions and 5 deletions

View File

@ -452,6 +452,34 @@ func (s *Song) ParamHintString(instrIndex, unitIndex int, param string) string {
return ""
}
func (u *Unit) StackChange() int {
switch u.Type {
case "addp", "mulp", "pop", "out", "outaux", "aux":
return -1 - u.Parameters["stereo"]
case "envelope", "oscillator", "push", "noise", "receive", "loadnote", "loadval", "in", "compressor":
return 1 + u.Parameters["stereo"]
case "pan":
return 1 - u.Parameters["stereo"]
case "speed":
return -1
case "send":
return (-1 - u.Parameters["stereo"]) * u.Parameters["sendpop"]
}
return 0
}
func (u *Unit) StackNeed() int {
switch u.Type {
case "envelope", "oscillator", "noise", "receive", "loadnote", "loadval", "in":
return 0
case "mulp", "mul", "add", "addp", "xch":
return 2 * (1 + u.Parameters["stereo"])
case "speed":
return 1
}
return 1 + u.Parameters["stereo"]
}
func Play(synth Synth, song Song) ([]float32, error) {
err := song.Validate()
if err != nil {