diff --git a/tracker/instrument.go b/tracker/instrument.go index 334ef9c..769fd43 100644 --- a/tracker/instrument.go +++ b/tracker/instrument.go @@ -470,18 +470,9 @@ success: for len(m.d.Song.Patch) <= m.d.InstrIndex { m.d.Song.Patch = append(m.d.Song.Patch, defaultInstrument.Copy()) } - m.d.Song.Patch[m.d.InstrIndex] = sointu.Instrument{} - numVoices := m.d.Song.Patch.NumVoices() - if numVoices >= vm.MAX_VOICES { - // this really shouldn't happen, as we have already cleared the - // instrument and assuming each instrument has at least 1 voice, it - // should have freed up some voices - (*Model)(m).Alerts().Add(fmt.Sprintf("The patch has already %d voices", vm.MAX_VOICES), Error) - return false - } - instrument.NumVoices = clamp(instrument.NumVoices, 1, 32-numVoices) (*Model)(m).assignUnitIDs(instrument.Units) - instrument.MIDI = m.d.Song.Patch[m.d.InstrIndex].MIDI // keep the MIDI config of the current instrument - m.d.Song.Patch[m.d.InstrIndex] = instrument + m.d.Song.Patch[m.d.InstrIndex].Name = instrument.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 = instrument.Comment + m.d.Song.Patch[m.d.InstrIndex].Units = instrument.Units return true } diff --git a/tracker/presets.go b/tracker/presets.go index 845181c..500f8ef 100644 --- a/tracker/presets.go +++ b/tracker/presets.go @@ -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