feat: add ability to disable units temporarily

Quite often the user wants to experiment what particular unit(s) add
to the sound. This commit adds ability to disable any set of units
temporarily, without actually deleting them. Ctrl-D disables and
re-enables the units. Disabled units are considered non-existent in
the patch.

Closes #116.
This commit is contained in:
5684185+vsariola@users.noreply.github.com
2024-02-19 21:36:14 +02:00
parent 2b3f6d8200
commit 17312bbe4e
9 changed files with 95 additions and 23 deletions

View File

@ -78,7 +78,7 @@ func NewBytecode(patch sointu.Patch, featureSet FeatureSet, bpm int) (*Bytecode,
return nil, errors.New("Each instrument must have at least 1 voice")
}
for unitIndex, unit := range instr.Units {
if unit.Type == "" { // empty units are just ignored & skipped
if unit.Type == "" || unit.Disabled { // empty units are just ignored & skipped
continue
}
opcode, ok := featureSet.Opcode(unit.Type)

View File

@ -118,7 +118,7 @@ func NecessaryFeaturesFor(patch sointu.Patch) NecessaryFeatures {
features := NecessaryFeatures{opcodes: map[string]int{}, supportsParamValue: map[paramKey](map[int]bool){}, supportsModulation: map[paramKey]bool{}}
for instrIndex, instrument := range patch {
for _, unit := range instrument.Units {
if unit.Type == "" {
if unit.Type == "" || unit.Disabled {
continue
}
if _, ok := features.opcodes[unit.Type]; !ok {