Sound Byte Libs
0.5.1-340-gab5b79a
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
types.hpp
Go to the documentation of this file.
1
/**
2
* @file types.hpp
3
* @brief Audio common types and configuration
4
* @ingroup hal
5
*
6
* Platform-agnostic audio types shared across the HAL layer.
7
* These types are used by both the HAL interface and platform implementations.
8
*
9
* Audio drivers (SAI, I2S, etc.) include this header and use these types
10
* in their public interface, ensuring a consistent contract across platforms.
11
*/
12
13
#ifndef SBL_HW_HAL_AUDIO_TYPES_HPP_
14
#define SBL_HW_HAL_AUDIO_TYPES_HPP_
15
16
#include <cstdint>
17
18
namespace
sbl
{
19
namespace
hal {
20
namespace
audio {
21
22
/**
23
* @brief SAI block direction layout
24
*
25
* Determines which SAI block is TX (to DAC) and which is RX (from ADC).
26
* This is board-level configuration - the codec wiring determines the mapping.
27
*/
28
// NOLINTBEGIN(readability-identifier-naming): spelled after the SAI blocks; used by sbl-hardware and sbl-apps.
29
enum class
SaiLayout
: uint8_t {
30
A_TX_B_RX
,
/**< Block A = Master TX, Block B = Slave RX (Daisy Seed / AK4556) */
31
A_RX_B_TX
/**< Block A = Slave RX, Block B = Master TX (Patch SM / PCM3060) */
32
};
33
// NOLINTEND(readability-identifier-naming)
34
35
/**
36
* @brief Audio stream configuration
37
*
38
* Describes the audio format for streaming. Drivers may ignore fields
39
* that are fixed by hardware (e.g., sample_rate when set by PLL).
40
*/
41
struct
AudioConfig
{
42
uint32_t
sample_rate
= 48000;
/**< Sample rate in Hz */
43
uint8_t
bit_depth
= 24;
/**< Bits per sample */
44
uint16_t
block_size
= 48;
/**< Stereo frames per callback */
45
SaiLayout
layout
=
SaiLayout::A_TX_B_RX
;
/**< SAI block direction */
46
};
47
48
/**
49
* @brief Audio processing callback (called from ISR context)
50
*
51
* One int32_t per sample: 24-bit two's complement, right-aligned, the
52
* format <sbl/dsp/types/convert.hpp> converts. Saturation is the caller's
53
* responsibility; interleave_from_float() clamps to +/-1.0 before scaling.
54
* The SAI driver outputs raw values with no implicit clamping.
55
*
56
* @param tx_buf Interleaved output [L0,R0,L1,R1,...] - fill these
57
* @param rx_buf Interleaved input [L0,R0,L1,R1,...] - read-only
58
* @param frames Frame count, at most block_size from AudioConfig
59
*/
60
using
AudioCallback
= void (*)(int32_t* tx_buf,
const
int32_t* rx_buf, uint16_t frames);
61
62
}
// namespace audio
63
}
// namespace hal
64
}
// namespace sbl
65
66
#endif
// SBL_HW_HAL_AUDIO_TYPES_HPP_
sbl::hal::audio::SaiLayout
SaiLayout
SAI block direction layout.
Definition
types.hpp:29
sbl::hal::audio::SaiLayout::A_TX_B_RX
@ A_TX_B_RX
sbl::hal::audio::SaiLayout::A_RX_B_TX
@ A_RX_B_TX
sbl::hal::audio::AudioCallback
void(*)(int32_t *tx_buf, const int32_t *rx_buf, uint16_t frames) AudioCallback
Audio processing callback (called from ISR context)
Definition
types.hpp:60
sbl
Root namespace for all Sound Byte Libs code.
Definition
audio_capture.hpp:16
sbl::hal::audio::AudioConfig
Audio stream configuration.
Definition
types.hpp:41
sbl::hal::audio::AudioConfig::bit_depth
uint8_t bit_depth
Definition
types.hpp:43
sbl::hal::audio::AudioConfig::layout
SaiLayout layout
Definition
types.hpp:45
sbl::hal::audio::AudioConfig::block_size
uint16_t block_size
Definition
types.hpp:44
sbl::hal::audio::AudioConfig::sample_rate
uint32_t sample_rate
Definition
types.hpp:42
src
sbl
hw
hal
audio
types.hpp
Generated by
1.9.8