mirror of
https://github.com/vsariola/sointu.git
synced 2026-02-12 11:13:03 -05:00
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:
parent
55f9c36bd5
commit
7459437822
@ -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
|
||||
|
||||
Reference in New Issue
Block a user