|
Sound Byte Libs 0.5.1-340-gab5b79a
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
|
Always-on audio capture ring buffer for host-side analysis. More...
Always-on audio capture ring buffer for host-side analysis.
Continuously records the last MaxFrames of audio into a circular buffer. No arming needed - the buffer always has the latest audio. To read:
The sbl-debugger audio_capture tool handles all of this automatically.
Example:
When frozen, feed() is a single branch.
Template parameter MaxFrames controls buffer size and capture duration:
Definition at line 54 of file audio_capture.hpp.
#include <audio_capture.hpp>
Public Member Functions | |
| void | feed (const float *left, const float *right, uint16_t frames) |
| Write one block into the ring; a no-op when frozen. | |
| void | freeze () |
| Freeze the buffer: feed() stops writing; the audio callback runs on. | |
| void | unfreeze () |
| Resume writing after a freeze. | |
Public Attributes | |
| volatile bool | frozen_ = false |
| volatile bool | ready_ = false |
| volatile uint16_t | pos_ = 0 |
| volatile uint32_t | written_ = 0 |
| float | buf_left_ [MaxFrames] = {} |
| float | buf_right_ [MaxFrames] = {} |
Static Public Attributes | |
| static constexpr uint16_t | MAX_FRAMES = MaxFrames |
|
inline |
Write one block into the ring; a no-op when frozen.
| left | Left channel samples |
| right | Right channel samples |
| frames | Frames in each channel |
Definition at line 63 of file audio_capture.hpp.
References sbl::diagnostics::AudioCapture< MaxFrames >::buf_left_, sbl::diagnostics::AudioCapture< MaxFrames >::buf_right_, sbl::diagnostics::AudioCapture< MaxFrames >::frozen_, sbl::diagnostics::AudioCapture< MaxFrames >::pos_, sbl::diagnostics::AudioCapture< MaxFrames >::ready_, and sbl::diagnostics::AudioCapture< MaxFrames >::written_.
|
inline |
Freeze the buffer: feed() stops writing; the audio callback runs on.
Definition at line 88 of file audio_capture.hpp.
References sbl::diagnostics::AudioCapture< MaxFrames >::frozen_.
|
inline |
Resume writing after a freeze.
Definition at line 91 of file audio_capture.hpp.
References sbl::diagnostics::AudioCapture< MaxFrames >::frozen_.
| volatile bool sbl::diagnostics::AudioCapture< MaxFrames >::frozen_ = false |
When true, feed() is a no-op
Definition at line 162 of file audio_capture.hpp.
Referenced by sbl::diagnostics::AudioCapture< MaxFrames >::feed(), sbl::diagnostics::AudioCapture< MaxFrames >::freeze(), and sbl::diagnostics::AudioCapture< MaxFrames >::unfreeze().
| volatile bool sbl::diagnostics::AudioCapture< MaxFrames >::ready_ = false |
True once the buffer has been fully written
Definition at line 163 of file audio_capture.hpp.
Referenced by sbl::diagnostics::AudioCapture< MaxFrames >::feed().
| volatile uint16_t sbl::diagnostics::AudioCapture< MaxFrames >::pos_ = 0 |
Ring head: next write position
Definition at line 164 of file audio_capture.hpp.
Referenced by sbl::diagnostics::AudioCapture< MaxFrames >::feed().
| volatile uint32_t sbl::diagnostics::AudioCapture< MaxFrames >::written_ = 0 |
Total frames written (for ready_ detection)
Definition at line 165 of file audio_capture.hpp.
Referenced by sbl::diagnostics::AudioCapture< MaxFrames >::feed().
| float sbl::diagnostics::AudioCapture< MaxFrames >::buf_left_[MaxFrames] = {} |
Left channel ring
Definition at line 169 of file audio_capture.hpp.
Referenced by sbl::diagnostics::AudioCapture< MaxFrames >::feed().
| float sbl::diagnostics::AudioCapture< MaxFrames >::buf_right_[MaxFrames] = {} |
Right channel ring
Definition at line 170 of file audio_capture.hpp.
Referenced by sbl::diagnostics::AudioCapture< MaxFrames >::feed().
|
staticconstexpr |
Ring length in frames
Definition at line 173 of file audio_capture.hpp.