nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
audio_defines.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
11#ifndef _AUDIO_DEFINES_H_
12#define _AUDIO_DEFINES_H_
13
14#include <zephyr/types.h>
15#include <stdbool.h>
16
24};
25
26#define AUDIO_MIC 0
27
31enum coding {
32 /* Raw PCM audio data */
33 PCM = 1,
34
35 /* LC3-coded audio data */
36 LC3
37};
38
40 /* Indicates the data type/encoding. */
42
43 /* Playback length in microseconds. */
44 uint32_t data_len_us;
45
46 /* The audio sample rate.
47 * This may typically be 16000, 24000, 44100 or 48000 Hz.
48 */
50
51 /* Number of valid bits for a sample (bit depth). Typically 16 or 24. */
53
54 /* Number of bits used to carry a sample of size bits_per_sample.
55 * For example, say we have a 24 bit sample stored in a 32 bit
56 * word (int32_t), then:
57 * bits_per_sample = 24
58 * carrier_size = 32
59 */
61
62 /* A 32 bit mask indicating which channel(s)/locations are active within
63 * the data. A bit set indicates the location is active and
64 * a count of these will give the number of locations within the
65 * audio stream.
66 * Note: This will follow the ANSI/CTA-861-G’s Table 34 codes
67 * for speaker placement (as used by Bluetooth Low Energy Audio).
68 */
69 uint32_t locations;
70
71 /* Reference time stamp (e.g. ISO timestamp reference from BLE controller). */
73
74 /* The timestamp for when the data was received. */
75 uint32_t data_rx_ts_us;
76
77 /* A Boolean flag to indicate this data has errors
78 * (true = bad, false = good).
79 * Note: Timestamps are still valid even though this flag is set.
80 */
82};
83
90struct audio_data {
91 /* A pointer to the raw or coded data (e.g., PCM, LC3, etc.) buffer. */
92 void *data;
93
94 /* The size in bytes of the data buffer.
95 * To get the size of each channel, this value must be divided by the number of
96 * used channels. Metadata is not included in this figure.
97 */
98 size_t data_size;
99
100 /* Additional information describing the audio data.
101 */
103};
104
105#endif /* _AUDIO_DEFINES_H_ */
audio_channel
Audio channel assignment values.
Definition: audio_defines.h:20
@ AUDIO_CH_L
Definition: audio_defines.h:21
@ AUDIO_CH_R
Definition: audio_defines.h:22
@ AUDIO_CH_NUM
Definition: audio_defines.h:23
coding
Audio data coding.
Definition: audio_defines.h:31
@ PCM
Definition: audio_defines.h:33
@ LC3
Definition: audio_defines.h:36
size_t data_size
Definition: audio_defines.h:98
struct audio_metadata meta
Definition: audio_defines.h:102
void * data
Definition: audio_defines.h:92
A unit of audio.
Definition: audio_defines.h:90
uint32_t reference_ts_us
Definition: audio_defines.h:72
uint8_t carried_bits_per_sample
Definition: audio_defines.h:60
uint32_t data_rx_ts_us
Definition: audio_defines.h:75
bool bad_data
Definition: audio_defines.h:81
uint32_t data_len_us
Definition: audio_defines.h:44
enum coding data_coding
Definition: audio_defines.h:41
uint8_t bits_per_sample
Definition: audio_defines.h:52
uint32_t sample_rate_hz
Definition: audio_defines.h:49
uint32_t locations
Definition: audio_defines.h:69
Definition: audio_defines.h:39