fix: changes after review (see PR #176)

This commit is contained in:
qm210
2024-11-09 18:58:42 +01:00
committed by Veikko Sariola
parent d517576a65
commit b255a68ebc
10 changed files with 252 additions and 207 deletions

View File

@ -465,21 +465,19 @@ func (p Patch) FindUnit(id int) (instrIndex int, unitIndex int, err error) {
return 0, 0, fmt.Errorf("could not find a unit with id %v", id)
}
func FindParamForModulationPort(unitName string, index int) *UnitParameter {
// qm210: couldn't see a function yet that matches the parameter index to the modulateable param.
// Not sure whether *UnitParameters is good here, would this make them mutable?
func FindParamForModulationPort(unitName string, index int) (UnitParameter, bool) {
unitType, ok := UnitTypes[unitName]
if !ok {
return nil
return UnitParameter{}, false
}
for _, param := range unitType {
if !param.CanModulate {
continue
}
if index == 0 {
return &param
}
if param.CanModulate {
index--
return param, true
}
index--
}
// index outside range
return nil
return UnitParameter{}, false
}