feat(tracker): don't save instrument name in instrument files

The filename is used as the instrument name when it is loaded.
This commit is contained in:
5684185+vsariola@users.noreply.github.com
2025-10-05 14:00:58 +03:00
parent 55f9c36bd5
commit 7459437822
6 changed files with 77 additions and 14 deletions

View File

@ -521,21 +521,29 @@ func (m *Model) fixUnitParams() {
// loop over all instruments and units and check that unit parameter table
// only has the parameters that are defined in the unit type
fixed := false
for i, instr := range m.d.Song.Patch {
for j, unit := range instr.Units {
for paramName := range unit.Parameters {
if !validParameters[unit.Type][paramName] {
delete(m.d.Song.Patch[i].Units[j].Parameters, paramName)
fixed = true
}
}
}
for i := range m.d.Song.Patch {
fixed = RemoveUnusedUnitParameters(&m.d.Song.Patch[i]) || fixed
}
if fixed {
m.Alerts().AddNamed("InvalidUnitParameters", "Some units had invalid parameters, they were removed", Error)
}
}
// RemoveUnusedUnitParameters removes any parameters from the instrument that are not valid for the unit type.
// It returns true if any parameters were removed.
func RemoveUnusedUnitParameters(instr *sointu.Instrument) bool {
fixed := false
for _, unit := range instr.Units {
for paramName := range unit.Parameters {
if !validParameters[unit.Type][paramName] {
delete(unit.Parameters, paramName)
fixed = true
}
}
}
return fixed
}
func clamp(a, min, max int) int {
if a > max {
return max