feat(tracker): spectrum analyzer

Closes #67
This commit is contained in:
5684185+vsariola@users.noreply.github.com
2025-12-29 23:57:08 +02:00
parent 4d09e04a49
commit 3a7010f897
16 changed files with 977 additions and 211 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) {