mirror of
https://github.com/vsariola/sointu.git
synced 2025-06-04 01:28:45 -04:00
fix(tracker): CurrenParam / CurrentUnit were incorrectly updated
Closes #21, #20
This commit is contained in:
parent
09a9f072cc
commit
2853509d1d
@ -454,6 +454,7 @@ func (t *Tracker) AddUnit() {
|
|||||||
copy(units[t.CurrentUnit+2:], t.song.Patch.Instruments[t.CurrentInstrument].Units[t.CurrentUnit+1:])
|
copy(units[t.CurrentUnit+2:], t.song.Patch.Instruments[t.CurrentInstrument].Units[t.CurrentUnit+1:])
|
||||||
t.song.Patch.Instruments[t.CurrentInstrument].Units = units
|
t.song.Patch.Instruments[t.CurrentInstrument].Units = units
|
||||||
t.CurrentUnit++
|
t.CurrentUnit++
|
||||||
|
t.CurrentParam = 0
|
||||||
t.ClampPositions()
|
t.ClampPositions()
|
||||||
t.sequencer.SetPatch(t.song.Patch)
|
t.sequencer.SetPatch(t.song.Patch)
|
||||||
}
|
}
|
||||||
@ -462,6 +463,7 @@ func (t *Tracker) ClearUnit() {
|
|||||||
t.SaveUndo()
|
t.SaveUndo()
|
||||||
t.song.Patch.Instruments[t.CurrentInstrument].Units[t.CurrentUnit].Type = ""
|
t.song.Patch.Instruments[t.CurrentInstrument].Units[t.CurrentUnit].Type = ""
|
||||||
t.song.Patch.Instruments[t.CurrentInstrument].Units[t.CurrentUnit].Parameters = make(map[string]int)
|
t.song.Patch.Instruments[t.CurrentInstrument].Units[t.CurrentUnit].Parameters = make(map[string]int)
|
||||||
|
t.CurrentParam = 0
|
||||||
t.ClampPositions()
|
t.ClampPositions()
|
||||||
t.sequencer.SetPatch(t.song.Patch)
|
t.sequencer.SetPatch(t.song.Patch)
|
||||||
}
|
}
|
||||||
@ -493,6 +495,7 @@ func (t *Tracker) DeleteUnit() {
|
|||||||
if t.CurrentUnit > 0 {
|
if t.CurrentUnit > 0 {
|
||||||
t.CurrentUnit--
|
t.CurrentUnit--
|
||||||
}
|
}
|
||||||
|
t.CurrentParam = 0
|
||||||
t.ClampPositions()
|
t.ClampPositions()
|
||||||
t.sequencer.SetPatch(t.song.Patch)
|
t.sequencer.SetPatch(t.song.Patch)
|
||||||
}
|
}
|
||||||
@ -581,6 +584,9 @@ func (t *Tracker) ClampPositions() {
|
|||||||
numSettableParams++
|
numSettableParams++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if numSettableParams == 0 {
|
||||||
|
numSettableParams = 1
|
||||||
|
}
|
||||||
if t.CurrentParam < 0 && t.CurrentUnit > 0 {
|
if t.CurrentParam < 0 && t.CurrentUnit > 0 {
|
||||||
t.CurrentUnit--
|
t.CurrentUnit--
|
||||||
numSettableParams = 0
|
numSettableParams = 0
|
||||||
@ -590,19 +596,13 @@ func (t *Tracker) ClampPositions() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
t.CurrentParam = numSettableParams - 1
|
t.CurrentParam = numSettableParams - 1
|
||||||
}
|
} else if t.CurrentParam >= numSettableParams && t.CurrentUnit < len(t.song.Patch.Instruments[t.CurrentInstrument].Units)-1 {
|
||||||
if t.CurrentParam >= numSettableParams && t.CurrentUnit < len(t.song.Patch.Instruments[t.CurrentInstrument].Units)-1 {
|
|
||||||
t.CurrentUnit++
|
t.CurrentUnit++
|
||||||
numSettableParams = 0
|
|
||||||
for _, t := range sointu.UnitTypes[t.song.Patch.Instruments[t.CurrentInstrument].Units[t.CurrentUnit].Type] {
|
|
||||||
if t.CanSet {
|
|
||||||
numSettableParams++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
t.CurrentParam = 0
|
t.CurrentParam = 0
|
||||||
}
|
} else {
|
||||||
t.CurrentParam = clamp(t.CurrentParam, 0, numSettableParams)
|
t.CurrentParam = clamp(t.CurrentParam, 0, numSettableParams)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (t *Tracker) getSelectionRange() (int, int, int, int) {
|
func (t *Tracker) getSelectionRange() (int, int, int, int) {
|
||||||
r1 := t.Cursor.Pattern*t.song.RowsPerPattern + t.Cursor.Row
|
r1 := t.Cursor.Pattern*t.song.RowsPerPattern + t.Cursor.Row
|
||||||
|
Loading…
x
Reference in New Issue
Block a user