mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-28 03:10:24 -04:00
parent
569958547e
commit
d46605c638
@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
### Fixed
|
### Fixed
|
||||||
|
- Assign new IDs to loaded instruments, and fix ID collisions in case they
|
||||||
|
somehow still appear ([#146][i146])
|
||||||
- In x86 templates, do not optimize away phase modulations when unisons are used
|
- In x86 templates, do not optimize away phase modulations when unisons are used
|
||||||
even if all phase inputs are zeros, as unisons use the phase modulation
|
even if all phase inputs are zeros, as unisons use the phase modulation
|
||||||
mechanism to offset the different oscillators
|
mechanism to offset the different oscillators
|
||||||
@ -176,3 +178,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
[i129]: https://github.com/vsariola/sointu/issues/129
|
[i129]: https://github.com/vsariola/sointu/issues/129
|
||||||
[i130]: https://github.com/vsariola/sointu/issues/130
|
[i130]: https://github.com/vsariola/sointu/issues/130
|
||||||
[i139]: https://github.com/vsariola/sointu/issues/139
|
[i139]: https://github.com/vsariola/sointu/issues/139
|
||||||
|
[i146]: https://github.com/vsariola/sointu/issues/146
|
||||||
|
@ -171,6 +171,7 @@ success:
|
|||||||
for len(m.d.Song.Patch) <= m.d.InstrIndex {
|
for len(m.d.Song.Patch) <= m.d.InstrIndex {
|
||||||
m.d.Song.Patch = append(m.d.Song.Patch, defaultInstrument.Copy())
|
m.d.Song.Patch = append(m.d.Song.Patch, defaultInstrument.Copy())
|
||||||
}
|
}
|
||||||
|
m.assignUnitIDs(instrument.Units)
|
||||||
m.d.Song.Patch[m.d.InstrIndex] = instrument
|
m.d.Song.Patch[m.d.InstrIndex] = instrument
|
||||||
if m.d.Song.Patch[m.d.InstrIndex].Comment != "" {
|
if m.d.Song.Patch[m.d.InstrIndex].Comment != "" {
|
||||||
m.commentExpanded = true
|
m.commentExpanded = true
|
||||||
|
@ -225,6 +225,7 @@ func (m *Model) change(kind string, t ChangeType, severity ChangeSeverity) func(
|
|||||||
m.send(m.d.Song.Score.Copy())
|
m.send(m.d.Song.Score.Copy())
|
||||||
}
|
}
|
||||||
if m.changeType&PatchChange != 0 {
|
if m.changeType&PatchChange != 0 {
|
||||||
|
m.fixIDCollisions()
|
||||||
m.d.InstrIndex = clamp(m.d.InstrIndex, 0, len(m.d.Song.Patch)-1)
|
m.d.InstrIndex = clamp(m.d.InstrIndex, 0, len(m.d.Song.Patch)-1)
|
||||||
m.d.InstrIndex2 = clamp(m.d.InstrIndex2, 0, len(m.d.Song.Patch)-1)
|
m.d.InstrIndex2 = clamp(m.d.InstrIndex2, 0, len(m.d.Song.Patch)-1)
|
||||||
unitCount := 0
|
unitCount := 0
|
||||||
@ -441,6 +442,37 @@ func (m *Model) assignUnitIDs(units []sointu.Unit) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Model) fixIDCollisions() {
|
||||||
|
// loop over all instruments and units and check if two units have the same
|
||||||
|
// ID. If so, give the later units new IDs.
|
||||||
|
usedIDs := map[int]bool{}
|
||||||
|
needsFix := false
|
||||||
|
maxID := 0
|
||||||
|
for i, instr := range m.d.Song.Patch {
|
||||||
|
for j, unit := range instr.Units {
|
||||||
|
if usedIDs[unit.ID] {
|
||||||
|
m.d.Song.Patch[i].Units[j].ID = 0
|
||||||
|
needsFix = true
|
||||||
|
}
|
||||||
|
if unit.ID > maxID {
|
||||||
|
maxID = unit.ID
|
||||||
|
}
|
||||||
|
usedIDs[unit.ID] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if needsFix {
|
||||||
|
m.Alerts().Add("Some units had duplicate IDs, they were fixed", Error)
|
||||||
|
for i, instr := range m.d.Song.Patch {
|
||||||
|
for j, unit := range instr.Units {
|
||||||
|
if unit.ID == 0 {
|
||||||
|
maxID++
|
||||||
|
m.d.Song.Patch[i].Units[j].ID = maxID
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (m *Model) updatePatternUseCount() {
|
func (m *Model) updatePatternUseCount() {
|
||||||
for i, track := range m.d.Song.Score.Tracks {
|
for i, track := range m.d.Song.Score.Tracks {
|
||||||
for len(m.cachePatternUseCount) <= i {
|
for len(m.cachePatternUseCount) <= i {
|
||||||
|
Loading…
Reference in New Issue
Block a user