Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a simple FAPO that takes a user-provided sample ring buffer and sample counter and will write incoming samples into it. It averages all incoming channels so the user doesn't need to know the channel count. The sample counter increases once per input block from the mixer, which allows the user to detect whether a new block of samples has been processed since the last time they checked.
The sample counter is written using atomics so the user won't observe a torn write, and since the ring buffer is updated one float at a time it's safe for us to race against the consumer without a lock (the odds of them reading from the buffer while we're writing to it are quite low, and for most use cases it would be unobservable).
This is designed to work great as a way to feed a spectrum analyzer or realtime waveform display, where you just want a buffer with N recent samples into it independent of the mixer resolution - for an FFT you probably want a buffer size that's a power of two, for example.
Haven't been able to test this yet so this draft is mostly to solicit API design feedback etc. and give people time to think about it.