mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-28 03:10:24 -04:00
fix(tracker): the scope length is in beats, not in rows
Already the oscilloscope calculated its length in beats, but everywhere the variable was called "lengthInRows." Renamed the variable to lengthInBeats and also changed the tooltip to be correct
This commit is contained in:
parent
1c601858ae
commit
76322bb541
@ -18,7 +18,7 @@ type (
|
|||||||
Oscilloscope struct {
|
Oscilloscope struct {
|
||||||
onceBtn *BoolClickable
|
onceBtn *BoolClickable
|
||||||
wrapBtn *BoolClickable
|
wrapBtn *BoolClickable
|
||||||
lengthInRowsNumber *NumberInput
|
lengthInBeatsNumber *NumberInput
|
||||||
triggerChannelNumber *NumberInput
|
triggerChannelNumber *NumberInput
|
||||||
xScale int
|
xScale int
|
||||||
xOffset float32
|
xOffset float32
|
||||||
@ -40,7 +40,7 @@ func NewOscilloscope(model *tracker.Model) *Oscilloscope {
|
|||||||
return &Oscilloscope{
|
return &Oscilloscope{
|
||||||
onceBtn: NewBoolClickable(model.SignalAnalyzer().Once().Bool()),
|
onceBtn: NewBoolClickable(model.SignalAnalyzer().Once().Bool()),
|
||||||
wrapBtn: NewBoolClickable(model.SignalAnalyzer().Wrap().Bool()),
|
wrapBtn: NewBoolClickable(model.SignalAnalyzer().Wrap().Bool()),
|
||||||
lengthInRowsNumber: NewNumberInput(model.SignalAnalyzer().LengthInRows().Int()),
|
lengthInBeatsNumber: NewNumberInput(model.SignalAnalyzer().LengthInBeats().Int()),
|
||||||
triggerChannelNumber: NewNumberInput(model.SignalAnalyzer().TriggerChannel().Int()),
|
triggerChannelNumber: NewNumberInput(model.SignalAnalyzer().TriggerChannel().Int()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@ func (s *OscilloscopeStyle) Layout(gtx C) D {
|
|||||||
wrapBtnStyle := ToggleButton(gtx, s.Theme, s.Oscilloscope.wrapBtn, "Wrap")
|
wrapBtnStyle := ToggleButton(gtx, s.Theme, s.Oscilloscope.wrapBtn, "Wrap")
|
||||||
onceBtnStyle := ToggleButton(gtx, s.Theme, s.Oscilloscope.onceBtn, "Once")
|
onceBtnStyle := ToggleButton(gtx, s.Theme, s.Oscilloscope.onceBtn, "Once")
|
||||||
triggerChannelStyle := NumericUpDown(s.Theme, s.Oscilloscope.triggerChannelNumber, "Trigger channel")
|
triggerChannelStyle := NumericUpDown(s.Theme, s.Oscilloscope.triggerChannelNumber, "Trigger channel")
|
||||||
lengthNumberStyle := NumericUpDown(s.Theme, s.Oscilloscope.lengthInRowsNumber, "Buffer length in rows")
|
lengthNumberStyle := NumericUpDown(s.Theme, s.Oscilloscope.lengthInBeatsNumber, "Buffer length in beats")
|
||||||
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
||||||
layout.Flexed(1, func(gtx C) D { return s.layoutWave(gtx) }),
|
layout.Flexed(1, func(gtx C) D { return s.layoutWave(gtx) }),
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
|
@ -12,7 +12,7 @@ type (
|
|||||||
triggered bool
|
triggered bool
|
||||||
wrap bool
|
wrap bool
|
||||||
triggerChannel int
|
triggerChannel int
|
||||||
lengthInRows int
|
lengthInBeats int
|
||||||
bpm int
|
bpm int
|
||||||
|
|
||||||
broker *Broker
|
broker *Broker
|
||||||
@ -23,10 +23,10 @@ type (
|
|||||||
Cursor int
|
Cursor int
|
||||||
}
|
}
|
||||||
|
|
||||||
SignalOnce ScopeModel
|
SignalOnce ScopeModel
|
||||||
SignalWrap ScopeModel
|
SignalWrap ScopeModel
|
||||||
SignalLengthInRows ScopeModel
|
SignalLengthInBeats ScopeModel
|
||||||
TriggerChannel ScopeModel
|
TriggerChannel ScopeModel
|
||||||
)
|
)
|
||||||
|
|
||||||
func (r *RingBuffer[T]) WriteWrap(values []T) {
|
func (r *RingBuffer[T]) WriteWrap(values []T) {
|
||||||
@ -57,9 +57,9 @@ func (r *RingBuffer[T]) WriteOnceSingle(value T) {
|
|||||||
|
|
||||||
func NewScopeModel(broker *Broker, bpm int) *ScopeModel {
|
func NewScopeModel(broker *Broker, bpm int) *ScopeModel {
|
||||||
s := &ScopeModel{
|
s := &ScopeModel{
|
||||||
broker: broker,
|
broker: broker,
|
||||||
bpm: bpm,
|
bpm: bpm,
|
||||||
lengthInRows: 4,
|
lengthInBeats: 4,
|
||||||
}
|
}
|
||||||
s.updateBufferLength()
|
s.updateBufferLength()
|
||||||
return s
|
return s
|
||||||
@ -67,10 +67,10 @@ func NewScopeModel(broker *Broker, bpm int) *ScopeModel {
|
|||||||
|
|
||||||
func (s *ScopeModel) Waveform() RingBuffer[[2]float32] { return s.waveForm }
|
func (s *ScopeModel) Waveform() RingBuffer[[2]float32] { return s.waveForm }
|
||||||
|
|
||||||
func (s *ScopeModel) Once() *SignalOnce { return (*SignalOnce)(s) }
|
func (s *ScopeModel) Once() *SignalOnce { return (*SignalOnce)(s) }
|
||||||
func (s *ScopeModel) Wrap() *SignalWrap { return (*SignalWrap)(s) }
|
func (s *ScopeModel) Wrap() *SignalWrap { return (*SignalWrap)(s) }
|
||||||
func (s *ScopeModel) LengthInRows() *SignalLengthInRows { return (*SignalLengthInRows)(s) }
|
func (s *ScopeModel) LengthInBeats() *SignalLengthInBeats { return (*SignalLengthInBeats)(s) }
|
||||||
func (s *ScopeModel) TriggerChannel() *TriggerChannel { return (*TriggerChannel)(s) }
|
func (s *ScopeModel) TriggerChannel() *TriggerChannel { return (*TriggerChannel)(s) }
|
||||||
|
|
||||||
func (m *SignalOnce) Bool() Bool { return Bool{m} }
|
func (m *SignalOnce) Bool() Bool { return Bool{m} }
|
||||||
func (m *SignalOnce) Value() bool { return m.once }
|
func (m *SignalOnce) Value() bool { return m.once }
|
||||||
@ -82,15 +82,15 @@ func (m *SignalWrap) Value() bool { return m.wrap }
|
|||||||
func (m *SignalWrap) setValue(val bool) { m.wrap = val }
|
func (m *SignalWrap) setValue(val bool) { m.wrap = val }
|
||||||
func (m *SignalWrap) Enabled() bool { return true }
|
func (m *SignalWrap) Enabled() bool { return true }
|
||||||
|
|
||||||
func (m *SignalLengthInRows) Int() Int { return Int{m} }
|
func (m *SignalLengthInBeats) Int() Int { return Int{m} }
|
||||||
func (m *SignalLengthInRows) Value() int { return m.lengthInRows }
|
func (m *SignalLengthInBeats) Value() int { return m.lengthInBeats }
|
||||||
func (m *SignalLengthInRows) setValue(val int) {
|
func (m *SignalLengthInBeats) setValue(val int) {
|
||||||
m.lengthInRows = val
|
m.lengthInBeats = val
|
||||||
(*ScopeModel)(m).updateBufferLength()
|
(*ScopeModel)(m).updateBufferLength()
|
||||||
}
|
}
|
||||||
func (m *SignalLengthInRows) Enabled() bool { return true }
|
func (m *SignalLengthInBeats) Enabled() bool { return true }
|
||||||
func (m *SignalLengthInRows) Range() intRange { return intRange{1, 999} }
|
func (m *SignalLengthInBeats) Range() intRange { return intRange{1, 999} }
|
||||||
func (m *SignalLengthInRows) change(string) func() { return func() {} }
|
func (m *SignalLengthInBeats) change(string) func() { return func() {} }
|
||||||
|
|
||||||
func (m *TriggerChannel) Int() Int { return Int{m} }
|
func (m *TriggerChannel) Int() Int { return Int{m} }
|
||||||
func (m *TriggerChannel) Value() int { return m.triggerChannel }
|
func (m *TriggerChannel) Value() int { return m.triggerChannel }
|
||||||
@ -134,8 +134,8 @@ func (s *ScopeModel) SetBpm(bpm int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *ScopeModel) updateBufferLength() {
|
func (s *ScopeModel) updateBufferLength() {
|
||||||
if s.bpm == 0 || s.lengthInRows == 0 {
|
if s.bpm == 0 || s.lengthInBeats == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
setSliceLength(&s.waveForm.Buffer, 44100*60*s.lengthInRows/s.bpm)
|
setSliceLength(&s.waveForm.Buffer, 44100*60*s.lengthInBeats/s.bpm)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user