mirror of
https://github.com/vsariola/sointu.git
synced 2026-02-17 21:53:28 -05:00
fix(tracker): keep instrument properties when loading a preset
Also when loading an instrument from the disk. We only load units, instrument name and comment. MIDI and the number of voices are kept.
This commit is contained in:
parent
942da94982
commit
cd4b85a66b
@ -12,7 +12,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/vsariola/sointu"
|
||||
"github.com/vsariola/sointu/vm"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
@ -165,10 +164,10 @@ func (m *presetResultList) SetSelected(i int) {
|
||||
m.d.Song.Patch = append(m.d.Song.Patch, defaultInstrument.Copy())
|
||||
}
|
||||
newInstr := m.presetData.cache.results[i].instr.Copy()
|
||||
newInstr.NumVoices = clamp(m.d.Song.Patch[m.d.InstrIndex].NumVoices, 1, vm.MAX_VOICES)
|
||||
(*Model)(m).assignUnitIDs(newInstr.Units)
|
||||
newInstr.MIDI = m.d.Song.Patch[m.d.InstrIndex].MIDI // keep the MIDI config of the current instrument
|
||||
m.d.Song.Patch[m.d.InstrIndex] = newInstr
|
||||
m.d.Song.Patch[m.d.InstrIndex].Name = newInstr.Name // only copy the relevant fields to preserve the user defined values e.g. NumVoices and MIDI configuration
|
||||
m.d.Song.Patch[m.d.InstrIndex].Comment = newInstr.Comment
|
||||
m.d.Song.Patch[m.d.InstrIndex].Units = newInstr.Units
|
||||
}
|
||||
|
||||
// SearchResult returns the search result at the given index in the search
|
||||
|
||||
Reference in New Issue
Block a user