arduino-audio-tools
Loading...
Searching...
No Matches
USBAudioConfig.h
Go to the documentation of this file.
1#pragma once
2#include <stdint.h>
3
4#include <cstring>
5
7
8namespace audio_tools {
9
10#ifdef STANDALONE_USB
18struct USBAudioConfig {
19 uint32_t sample_rate = 44100;
20 uint8_t channels = 2;
22#else
27struct USBAudioConfig : public AudioInfo {
28#endif
29
30 // ── Direction ─────────────────────────────────────────────────────────────
31 bool enable_ep_in = true;
32 bool enable_ep_out = true;
33
34 // ── USB endpoint addresses ────────────────────────────────────────────────
38 uint8_t ep_in = 0x83;
39 uint8_t ep_out = 0x03;
40 uint8_t ep_fb = 0x84;
41 uint8_t ep_int = 0x85;
42
43 // ── Interface numbering ───────────────────────────────────────────────────
46 uint8_t itf_num_ac = 0;
47
48 // ── Buffering ─────────────────────────────────────────────────────────────
51 uint8_t fifo_packets = 16;
52
53 // ── Device identity ───────────────────────────────────────────────────────
54 uint16_t vid = 0xCafe;
55 uint16_t pid = 0x4002;
56 const char* manufacturer = "Audio Tools";
57 const char* product = "USB Audio";
58 const char* serial = "000001";
59 bool self_powered = true;
60 uint8_t max_power_ma = 100;
61
62 // ── Advanced ──────────────────────────────────────────────────────────────
64 bool enable_feedback_ep = true;
65
72 bool enable_multi_sample_rate = false;
73
77 bool enable_interrupt_ep = false;
78
84 bool enable_ep_in_flow_control = true;
85
88 bool use_linear_buffer_rx = true;
91 bool use_linear_buffer_tx = true;
92 // ── Volume Handling ────────────────────────────────────────────────────────
96 bool volume_active = false;
97
98 // ── ESP32-specific ────────────────────────────────────────────────────────
102 bool begin_usb = false;
103
104 // ── Zephyr-specific ───────────────────────────────────────────────────────
109 uint8_t terminal_id = 1;
110
111 bool operator==(const USBAudioConfig& other) {
112 return sample_rate == other.sample_rate && channels == other.channels &&
113 bits_per_sample == other.bits_per_sample &&
114
115 enable_ep_in == other.enable_ep_in &&
116 enable_ep_out == other.enable_ep_out &&
117
118 ep_in == other.ep_in && ep_out == other.ep_out &&
119 ep_fb == other.ep_fb &&
120
121 itf_num_ac == other.itf_num_ac &&
122 fifo_packets == other.fifo_packets &&
123
124 vid == other.vid && pid == other.pid &&
125
126 std::strcmp(manufacturer ? manufacturer : "",
127 other.manufacturer ? other.manufacturer : "") == 0 &&
128
129 std::strcmp(product ? product : "",
130 other.product ? other.product : "") == 0 &&
131
132 std::strcmp(serial ? serial : "",
133 other.serial ? other.serial : "") == 0 &&
134
135 self_powered == other.self_powered &&
136 max_power_ma == other.max_power_ma &&
137
138 enable_feedback_ep == other.enable_feedback_ep &&
139 enable_ep_in_flow_control == other.enable_ep_in_flow_control &&
140 use_linear_buffer_rx == other.use_linear_buffer_rx &&
141 use_linear_buffer_tx == other.use_linear_buffer_tx &&
142
143 begin_usb == other.begin_usb && terminal_id == other.terminal_id;
144 }
145
146 bool operator!=(const USBAudioConfig& other) { return !(*this == other); }
147};
148
149} // namespace audio_tools
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition AudioCodecsBase.h:10
size_t writeData(Print *p_out, T *data, int samples, int maxSamples=512)
Definition AudioTypes.h:512
Basic Audio information which drives e.g. I2S.
Definition AudioTypes.h:55
sample_rate_t sample_rate
Sample Rate: e.g 44100.
Definition AudioTypes.h:57
uint16_t channels
Number of channels: 2=stereo, 1=mono.
Definition AudioTypes.h:59
uint8_t bits_per_sample
Number of bits per sample (int16_t = 16 bits)
Definition AudioTypes.h:61
Configuration for USB Audio (inherits sample_rate / channels / bits_per_sample from AudioInfo).
Definition USBAudioConfig.h:27
bool operator==(const USBAudioConfig &other)
Definition USBAudioConfig.h:111
bool operator!=(const USBAudioConfig &other)
Definition USBAudioConfig.h:146