Sound Byte Libs 0.5.1-121-g3358a44
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
sample_clock.hpp File Reference

Audio-clock frame counter — the elapsed-samples source for control code. More...

Detailed Description

Audio-clock frame counter — the elapsed-samples source for control code.

Counts stereo frames the audio driver has handed to the codec since boot. The count advances only with the audio clock, so control code that needs elapsed time (the FDP-073 scheduler's tick(elapsed_samples)) reads it instead of assuming a timer rate: the 1 kHz control timer is not sample-locked to the codec.

One writer: the audio driver calls advance() once per block, after the application callback returns. Any context may call now(). Consumers take unsigned deltas, which stay correct across the wrap every 2^32 frames (~24.8 h at 48 kHz).

The counter is a relaxed atomic: race-free between the audio thread and the control thread on the workbench, plain LDR/STR on Cortex-M7. It publishes no other data, so no ordering is needed.

Definition in file sample_clock.hpp.

#include <atomic>
#include <cstdint>

Go to the source code of this file.

Classes

class  sbl::hal::audio::SampleClock
 

Namespaces

namespace  sbl
 Root namespace for all Sound Byte Libs code.
 
namespace  sbl::hal
 Hardware abstraction: handles and convenience layers over the drivers.
 
namespace  sbl::hal::audio
 Audio streams and the sample clock.