Deluge Firmware 1.4.0
Build date: 2026.11.30
Loading...
Searching...
No Matches
deluge::mic_velocity::input Namespace Reference

Typedefs

using Frame = uint32_t
using Consumer = void (*)(Frame first, std::span<int32_t const> mic, std::span<int16_t const> ref)
 What a block of frames is handed to. Up to kMaxBlock frames at a time, in order.

Functions

Frame now ()
 The frame the DMA is writing now.
void setConsumer (Consumer consumer)
 Start or stop passing frames to a consumer (nullptr: stop). Reading starts from now.
bool hasConsumer ()
uint32_t framesDropped ()
 Frames lost because the reader fell more than a ring behind (since boot).
void setSentDelay (Frame frames)
void service ()
void feedOutput (std::span< StereoSample const > written, int32_t framesQueuedAfter)

Variables

constexpr int32_t kMaxBlock = 64
constexpr Frame kMaxSentDelay = SSI_RX_BUFFER_NUM_SAMPLES * 3 - SSI_TX_BUFFER_NUM_SAMPLES

Detailed Description

Reads the internal mic as it arrives, for mic velocity.

The codec's input ring (SSI_RX_BUFFER_NUM_SAMPLES frames, ~46 ms) is written by DMA all the time. The audio engine reads it at i2sRXBufferPos, which trails the DMA by 3-6 ms and jumps in 128-frame steps. This reader keeps its own position and reads right up to the DMA, so a pad press handled now sees the mic up to now.

Frames are counted on a clock that starts at boot and never wraps in practice (27 hours at 44.1 kHz). Each frame also carries the mono output that the audio engine sent to the codec at the same moment (for echo cancellation).

Function Documentation

◆ feedOutput()

void deluge::mic_velocity::input::feedOutput ( std::span< StereoSample const > written,
int32_t framesQueuedAfter )

From AudioEngine::doSomeOutputting(): the frames just written to the codec, and how many frames are queued in its output ring after them.

◆ service()

void deluge::mic_velocity::input::service ( )

Reads all new frames and passes them to the consumer, if there is one. Called from the audio routine and when a pad press is handled. Cheap when there's no consumer.

Variable Documentation

◆ kMaxSentDelay

Frame deluge::mic_velocity::input::kMaxSentDelay = SSI_RX_BUFFER_NUM_SAMPLES * 3 - SSI_TX_BUFFER_NUM_SAMPLES
constexpr

Hands each mic frame the output sent this many frames before it instead of at the same moment: how much later speakers further off are heard. Up to kMaxSentDelay (136 ms).