This commit is contained in:
5684185+vsariola@users.noreply.github.com
2025-12-30 22:43:35 +02:00
parent f765d75fde
commit 2303e89bbd
10 changed files with 330 additions and 110 deletions

View File

@ -14,8 +14,6 @@ type (
triggerChannel int
lengthInBeats int
bpm int
broker *Broker
}
RingBuffer[T any] struct {
@ -55,9 +53,8 @@ func (r *RingBuffer[T]) WriteOnceSingle(value T) {
}
}
func NewScopeModel(broker *Broker, bpm int) *ScopeModel {
func NewScopeModel(bpm int) *ScopeModel {
s := &ScopeModel{
broker: broker,
bpm: bpm,
lengthInBeats: 4,
}
@ -96,10 +93,6 @@ func (s *ScopeModel) ProcessAudioBuffer(bufPtr *sointu.AudioBuffer) {
} else {
s.waveForm.WriteOnce(*bufPtr)
}
// chain the messages: when we have a new audio buffer, try passing it on to the detector
if !TrySend(s.broker.ToDetector, MsgToDetector{Data: bufPtr}) {
s.broker.PutAudioBuffer(bufPtr)
}
}
// Note: channel 1 is the first channel
@ -116,7 +109,6 @@ func (s *ScopeModel) Reset() {
l := len(s.waveForm.Buffer)
s.waveForm.Buffer = s.waveForm.Buffer[:0]
s.waveForm.Buffer = append(s.waveForm.Buffer, make([][2]float32, l)...)
TrySend(s.broker.ToDetector, MsgToDetector{Reset: true}) // chain the messages: when the signal analyzer is reset, also reset the detector
}
func (s *ScopeModel) SetBpm(bpm int) {