mirror of
https://github.com/vsariola/sointu.git
synced 2026-02-18 14:13:17 -05:00
feat(tracker): add numeric updown to choose number of voices for instrument
This commit is contained in:
@ -31,6 +31,7 @@ type Tracker struct {
|
||||
BPM *NumberInput
|
||||
RowsPerPattern *NumberInput
|
||||
RowsPerBeat *NumberInput
|
||||
InstrumentVoices *NumberInput
|
||||
NewTrackBtn *widget.Clickable
|
||||
NewInstrumentBtn *widget.Clickable
|
||||
DeleteInstrumentBtn *widget.Clickable
|
||||
@ -166,6 +167,26 @@ func (t *Tracker) ChangeOctave(delta int) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (t *Tracker) SetInstrumentVoices(value int) bool {
|
||||
if value < 1 {
|
||||
value = 1
|
||||
}
|
||||
maxRemain := 32 - t.song.Patch.TotalVoices() + t.song.Patch.Instruments[t.CurrentInstrument].NumVoices
|
||||
if maxRemain < 1 {
|
||||
maxRemain = 1
|
||||
}
|
||||
if value > maxRemain {
|
||||
value = maxRemain
|
||||
}
|
||||
if value != int(t.song.Patch.Instruments[t.CurrentInstrument].NumVoices) {
|
||||
t.SaveUndo()
|
||||
t.song.Patch.Instruments[t.CurrentInstrument].NumVoices = value
|
||||
t.sequencer.SetPatch(t.song.Patch)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (t *Tracker) SetBPM(value int) bool {
|
||||
if value < 1 {
|
||||
value = 1
|
||||
@ -383,6 +404,7 @@ func New(audioContext sointu.AudioContext) *Tracker {
|
||||
SongLength: new(NumberInput),
|
||||
RowsPerPattern: new(NumberInput),
|
||||
RowsPerBeat: new(NumberInput),
|
||||
InstrumentVoices: new(NumberInput),
|
||||
NewTrackBtn: new(widget.Clickable),
|
||||
NewInstrumentBtn: new(widget.Clickable),
|
||||
DeleteInstrumentBtn: new(widget.Clickable),
|
||||
|
||||
Reference in New Issue
Block a user