This commit is contained in:
5684185+vsariola@users.noreply.github.com
2026-01-17 23:55:37 +02:00
parent fd5e2c3bb8
commit b328cc3a07
5 changed files with 62 additions and 50 deletions

View File

@ -79,6 +79,7 @@ type (
oversampling bool
specAnSettings SpecAnSettings
specAnEnabled bool
alerts []Alert
dialog Dialog
@ -402,14 +403,16 @@ func (m *Model) ProcessMsg(msg MsgToModel) {
case *sointu.AudioBuffer:
m.signalAnalyzer.ProcessAudioBuffer(e)
// chain the messages: when we have a new audio buffer, send them to the detector and the spectrum analyzer
clone := m.broker.GetAudioBuffer()
*clone = append(*clone, *e...)
if m.specAnEnabled { // send buffers to spectrum analyzer only if it's enabled
clone := m.broker.GetAudioBuffer()
*clone = append(*clone, *e...)
if !TrySend(m.broker.ToSpecAn, MsgToSpecAn{Data: clone}) {
m.broker.PutAudioBuffer(clone)
}
}
if !TrySend(m.broker.ToDetector, MsgToDetector{Data: e}) {
m.broker.PutAudioBuffer(e)
}
if !TrySend(m.broker.ToSpecAn, MsgToSpecAn{Data: clone}) {
m.broker.PutAudioBuffer(clone)
}
case *Spectrum:
m.broker.PutSpectrum(m.spectrum)
m.spectrum = e