arduino-audio-tools
Loading...
Searching...
No Matches
USBAudio2DescriptorBuilder.h
Go to the documentation of this file.
1#pragma once
2#include <cstdint>
3#include <cstring>
4
5#include "USBAudioConfig.h"
6
7namespace audio_tools {
8
30 public:
31 // UAC2 entity IDs — assigned sequentially from 1.
32 // Chain 1 is used for the OUT path (or the only path in pure-IN mode).
33 // Chain 2 is used for the IN path in RXTX mode.
34 static constexpr uint8_t ENTITY_CLOCK = 1;
35 static constexpr uint8_t ENTITY_IT1 = 2;
36 static constexpr uint8_t ENTITY_FU1 = 3;
37 static constexpr uint8_t ENTITY_OT1 = 4;
38 static constexpr uint8_t ENTITY_IT2 = 5;
39 static constexpr uint8_t ENTITY_FU2 = 6;
40 static constexpr uint8_t ENTITY_OT2 = 7;
41
43
44
45 // Kept for backward compatibility with existing call sites.
46 const uint16_t buildDescriptor(uint8_t /*itf*/, uint8_t /*alt*/, uint8_t* desc) {
47 return buildFullDescriptor(desc);
48 }
49
50 // Build the complete audio-function descriptor using interface numbers from
51 // config. Returns a pointer to an internal static buffer; *outLen receives
52 // the total byte count.
53 const uint16_t buildFullDescriptor(uint8_t* desc) {
55 }
56
57 // Same but with an explicit first (AC) interface number.
58 const uint16_t buildFullDescriptor(uint8_t first_itf, uint8_t* desc) {
59 uint8_t* p = desc;
60
61 const uint8_t itf_ac = first_itf;
62 uint8_t itf_as = (uint8_t)(first_itf + 1);
63 const uint8_t num_as = (uint8_t)audioFunctionsCount();
64
65 // ── IAD ──────────────────────────────────────────────────────────────────
66 p = writeIAD(p, itf_ac, (uint8_t)(1 + num_as));
67
68 // ── Standard AC Interface ─────────────────────────────────────────────
69 const uint8_t ac_nEps = p_config->enable_interrupt_ep ? 1 : 0;
70 p = writeStdIface(p, itf_ac, 0, ac_nEps, 0x01 /*AUDIO*/, 0x01 /*CONTROL*/, 0x20 /*UAC2*/);
71
72 // ── CS AC entities — patch wTotalLength after ────────────────────────────
73 uint8_t* cs_ac_start = p;
74 p = writeCsAcHeader(p);
76
78 // OUT path: USB Streaming input → Feature Unit → Speaker output
80 0x0101 /*USB Streaming*/, ENTITY_CLOCK);
83 0x0301 /*Speaker*/, ENTITY_FU1,
85 }
86
88 // IN path: Microphone input → Feature Unit → USB Streaming output.
89 // Pure-IN mode reuses chain 1 IDs; RXTX mode uses chain 2 IDs.
90 const bool rxtx = p_config->enable_ep_out;
91 const uint8_t it = rxtx ? ENTITY_IT2 : ENTITY_IT1;
92 const uint8_t fu = rxtx ? ENTITY_FU2 : ENTITY_FU1;
93 const uint8_t ot = rxtx ? ENTITY_OT2 : ENTITY_OT1;
94 p = writeInputTerminal(p, it, 0x0201 /*Microphone*/, ENTITY_CLOCK);
95 p = writeFeatureUnit(p, fu, it);
96 p = writeOutputTerminal(p, ot, 0x0101 /*USB Streaming*/, fu,
98 }
99
100 // Patch wTotalLength (bytes 6-7 of CS AC Header) — covers only the
101 // class-specific descriptors above, not the interrupt endpoint below.
102 const uint16_t cs_ac_len = (uint16_t)(p - cs_ac_start);
103 cs_ac_start[6] = (uint8_t)(cs_ac_len & 0xFF);
104 cs_ac_start[7] = (uint8_t)(cs_ac_len >> 8);
105
106 // Interrupt EP must follow the CS AC block (USB spec §9.6.6:
107 // endpoint descriptors come after class-specific interface descriptors).
110 }
111
112 // ── OUT AS Interface ─────────────────────────────────────────────────────
113 if (p_config->enable_ep_out) {
114 const uint8_t nEps = enableFeedbackEp() ? 2 : 1;
115 p = writeStdIface(p, itf_as, 0, 0, 0x01, 0x02, 0x20); // alt=0 zero BW
116 p = writeStdIface(p, itf_as, 1, nEps, 0x01, 0x02, 0x20); // alt=1 active
117 p = writeCsAsInterface(p, ENTITY_IT1); // links to USB Streaming IT
118 p = writeFormatType(p);
120 p = writeCsIsoEndpoint(p);
121 if (enableFeedbackEp()) {
123 }
124 ++itf_as;
125 }
126
127 // ── IN AS Interface ──────────────────────────────────────────────────────
128 if (p_config->enable_ep_in) {
129 // Links to the Output Terminal that has USB Streaming type
131 : ENTITY_OT1;
132 p = writeStdIface(p, itf_as, 0, 0, 0x01, 0x02, 0x20); // alt=0 zero BW
133 p = writeStdIface(p, itf_as, 1, 1, 0x01, 0x02, 0x20); // alt=1 active
134 p = writeCsAsInterface(p, ot);
135 p = writeFormatType(p);
137 p = writeCsIsoEndpoint(p);
138 }
139
140 uint16_t outLen = (uint16_t)(p - desc);
141 return outLen;
142 }
143
145 return (p_config->enable_ep_in ? 1 : 0) + (p_config->enable_ep_out ? 1 : 0);
146 }
147
148
149 // True when the explicit-feedback endpoint should appear in the descriptor.
150 // Mirrors isFeedbackEpEnabled() in USBAudioDeviceBase. TX-only mode has no
151 // OUT EP at all. In RXTX mode it's opt-in (enable_feedback_ep_rxtx): the
152 // host does NOT use the IN stream as implicit feedback here, since that
153 // needs an asynchronous OUT endpoint and an IN endpoint declared as
154 // implicit feedback (usage type 10b), and without this the OUT endpoint is
155 // adaptive (see writeIsoEndpoint()) -- ie: the host ignores the device's
156 // clock entirely. It needs three ISO endpoints, so platforms with fewer
157 // (USB_AUDIO_MAX_ISO_EP) can't have it, and ep_fb can't be the same
158 // endpoint as ep_in.
159 bool enableFeedbackEp() const {
160 if (!p_config->enable_feedback_ep || !p_config->enable_ep_out) return false;
161 if (!p_config->enable_ep_in) return true;
163 !(p_config->ep_fb >= 0 && p_config->ep_fb == p_config->ep_in);
164 }
165
166 // Isochronous packet size for one 1 ms frame at a given rate.
167 // +1 extra sample provides headroom for clock-drift compensation: the host
168 // may send ceil(rate/1000)+1 samples in occasional frames to stay in sync.
169 uint16_t calcPacketSizeForRate(uint32_t rate) const {
170 const uint16_t bytes_per_sample = (p_config->bits_per_sample / 8) * p_config->channels;
171 return bytes_per_sample * (uint16_t)(((rate + 999) / 1000) + 1);
172 }
173
174 // Isochronous packet size for one 1 ms frame at the configured rate/format.
175 // +1 extra sample is required for Windows: at rates that are exact multiples
176 // of 1000 Hz (e.g. 48000 Hz = exactly 48 samples/frame), Windows' USB audio
177 // driver may deliver 49 samples in some frames for synchronisation, causing
178 // a descriptor rejection when wMaxPacketSize is set to the nominal 48-sample
179 // value. Rates like 44100 Hz already have implicit headroom from ceiling
180 // division (44.1 → 45), but the +1 makes this safe for all rates.
181 uint16_t calcMaxPacketSize() const {
182 const uint16_t bytes_per_sample = (p_config->bits_per_sample / 8) * p_config->channels;
183 return bytes_per_sample * (uint16_t)(((p_config->sample_rate + 999) / 1000) + 1);
184 }
185
186 protected:
188
189 // ── helpers ─────────────────────────────────────────────────────────────────
190
192 // Stereo: FL+FR = bits 0-1; mono: FL = bit 0; >2ch: lower N bits.
193 if (p_config->channels == 1) return 0x00000001u;
194 if (p_config->channels == 2) return 0x00000003u;
195 return (1u << p_config->channels) - 1u;
196 }
197
198 // ── descriptor writers ──────────────────────────────────────────────────────
199
200 // Interface Association Descriptor (8 bytes)
201 uint8_t* writeIAD(uint8_t* p, uint8_t first_itf, uint8_t count) {
202 *p++ = 8;
203 *p++ = 0x0B; // INTERFACE_ASSOCIATION
204 *p++ = first_itf;
205 *p++ = count;
206 *p++ = 0x01; // bFunctionClass AUDIO
207 *p++ = 0x00; // bFunctionSubClass
208 *p++ = 0x20; // bFunctionProtocol UAC2
209 *p++ = 0x00; // iFunction
210 return p;
211 }
212
213 // Standard Interface Descriptor (9 bytes)
215 uint8_t nEps, uint8_t cls, uint8_t sub, uint8_t proto) {
216 *p++ = 9;
217 *p++ = 0x04; // INTERFACE
218 *p++ = itf;
219 *p++ = alt;
220 *p++ = nEps;
221 *p++ = cls;
222 *p++ = sub;
223 *p++ = proto;
224 *p++ = 0; // iInterface
225 return p;
226 }
227
228 // UAC2 CS AC Interface Header (9 bytes).
229 // Caller patches wTotalLength at offsets [6] and [7].
231 *p++ = 9;
232 *p++ = 0x24; // CS_INTERFACE
233 *p++ = 0x01; // HEADER
234 *p++ = 0x00;
235 *p++ = 0x02; // bcdADC 2.00
236 *p++ = deviceCategory();
237 *p++ = 0x00; // wTotalLength LSB — patched by caller
238 *p++ = 0x00; // wTotalLength MSB — patched by caller
239 *p++ = 0x00; // bmControls
240 return p;
241 }
242
243 // UAC2 bCategory: Windows uses this to classify the audio endpoint.
244 // Using the wrong category (e.g. IO_BOX for a capture-only device) causes
245 // Windows to look for a playback path that does not exist and fail to
246 // enumerate the audio format (Details tab missing in microphone properties).
248 bool has_in = p_config->enable_ep_in;
249 bool has_out = p_config->enable_ep_out;
250 if (has_in && !has_out) return 0x03; // Microphone
251 if (!has_in && has_out) return 0x01; // Desktop Speaker
252 return 0x08; // I/O Box (bidirectional)
253 }
254
255 // UAC2 Clock Source Descriptor (8 bytes)
256 //
257 // bmAttributes D1..D0 — clock type:
258 // 0x00 = external, 0x01 = internal fixed, 0x02 = internal variable,
259 // 0x03 = internal programmable
260 // bmControls — bit-pair encoding:
261 // D1..D0 = Clock Frequency (01=read-only, 11=host-programmable)
262 // D3..D2 = Clock Validity (01=read-only)
263 //
264 // Always declare "internal programmable" (0x03) with "host-programmable
265 // frequency" (0x07), even when only one rate is supported. Windows 11's
266 // usbaudio2.sys requires the ability to round-trip a SET_CUR / GET_CUR for
267 // the clock frequency before it will populate the audio format in the device
268 // properties (Details tab) and accept the device in WASAPI. With a "fixed"
269 // clock (0x01 / 0x05) Windows skips the SET_CUR step at integer rates
270 // (48000, 16000 Hz) and then fails to enumerate the format — the Details tab
271 // does not appear and Audacity returns error -9999. At fractional rates
272 // (44100 Hz) it works by accident because the ceiling arithmetic in
273 // calcMaxPacketSize already signals the irregular-frame nature of the stream.
274 // The single-rate vs multi-rate distinction is carried by GET_RANGE only.
276 *p++ = 8;
277 *p++ = 0x24; // CS_INTERFACE
278 *p++ = 0x0A; // CLOCK_SOURCE
279 *p++ = clock_id;
280 *p++ = 0x03; // bmAttributes: internal programmable clock
281 *p++ = 0x07; // bmControls: freq host-programmable (11b), validity read-only (01b)
282 *p++ = 0x00; // bAssocTerminal
283 *p++ = 0x00; // iClockSource
284 return p;
285 }
286
287 // UAC2 Input Terminal Descriptor (17 bytes)
289 uint16_t term_type, uint8_t clock_id) {
290 const uint32_t ch_cfg = channelConfig();
291 *p++ = 17;
292 *p++ = 0x24; // CS_INTERFACE
293 *p++ = 0x02; // INPUT_TERMINAL
294 *p++ = term_id;
295 *p++ = (uint8_t)(term_type & 0xFF);
296 *p++ = (uint8_t)(term_type >> 8);
297 *p++ = 0x00; // bAssocTerminal
298 *p++ = clock_id; // bCSourceID
299 *p++ = p_config->channels;
300 *p++ = (uint8_t)(ch_cfg & 0xFF);
301 *p++ = (uint8_t)((ch_cfg >> 8) & 0xFF);
302 *p++ = (uint8_t)((ch_cfg >> 16) & 0xFF);
303 *p++ = (uint8_t)((ch_cfg >> 24) & 0xFF);
304 *p++ = 0; // iChannelNames
305 *p++ = 0x00;
306 *p++ = 0x00; // bmControls
307 *p++ = 0; // iTerminal
308 return p;
309 }
310
311 // UAC2 Feature Unit Descriptor (6 + (channels+1)*4 bytes)
312 //
313 // bmaControls[] is a 32-bit bitmap per channel (+ master at index 0).
314 // Each control is a 2-bit pair:
315 // 00 = not present, 01 = read-only, 11 = host-programmable
316 //
317 // D1..D0 = Mute (FU_CTRL_MUTE = 0x01)
318 // D3..D2 = Volume (FU_CTRL_VOLUME = 0x02)
319 //
320 // 0x0F = Mute host-programmable (11b) | Volume host-programmable (11b)
321 //
322 // Volume uses int16 in 1/256 dB units (0x8000 = silence, 0 = 0 dB).
323 // AudioTools maps this to float 0.0 (silence) – 1.0 (0 dB).
324 // GET_RANGE reports -100 dB .. 0 dB in 1 dB steps.
326 const uint8_t len = (uint8_t)(6 + (p_config->channels + 1) * 4);
327 *p++ = len;
328 *p++ = 0x24; // CS_INTERFACE
329 *p++ = 0x06; // FEATURE_UNIT
330 *p++ = unit_id;
331 *p++ = src_id;
332 // Master bmaControls[0]: Mute + Volume, host-programmable
333 *p++ = 0x0F; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;
334 // Per-channel bmaControls[1..N]: same controls
335 for (uint8_t i = 0; i < p_config->channels; i++) {
336 *p++ = 0x0F; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;
337 }
338 *p++ = 0x00; // iFeature
339 return p;
340 }
341
342 // UAC2 Output Terminal Descriptor (12 bytes)
343 uint8_t* writeOutputTerminal(uint8_t* p, uint8_t term_id, uint16_t term_type,
344 uint8_t src_id, uint8_t clock_id) {
345 *p++ = 12;
346 *p++ = 0x24; // CS_INTERFACE
347 *p++ = 0x03; // OUTPUT_TERMINAL
348 *p++ = term_id;
349 *p++ = (uint8_t)(term_type & 0xFF);
350 *p++ = (uint8_t)(term_type >> 8);
351 *p++ = 0x00; // bAssocTerminal
352 *p++ = src_id; // bSourceID
353 *p++ = clock_id; // bCSourceID
354 *p++ = 0x00;
355 *p++ = 0x00; // bmControls
356 *p++ = 0; // iTerminal
357 return p;
358 }
359
360 // UAC2 CS AS Interface Descriptor (16 bytes)
362 const uint32_t ch_cfg = channelConfig();
363 *p++ = 16;
364 *p++ = 0x24; // CS_INTERFACE
365 *p++ = 0x01; // AS_GENERAL
366 *p++ = terminal_link;
367 *p++ = 0x00; // bmControls
368 *p++ = 0x01; // bFormatType TYPE_I
369 // bmFormats: PCM = 0x00000001
370 *p++ = 0x01; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;
371 *p++ = p_config->channels;
372 *p++ = (uint8_t)(ch_cfg & 0xFF);
373 *p++ = (uint8_t)((ch_cfg >> 8) & 0xFF);
374 *p++ = (uint8_t)((ch_cfg >> 16) & 0xFF);
375 *p++ = (uint8_t)((ch_cfg >> 24) & 0xFF);
376 *p++ = 0; // iChannelNames
377 return p;
378 }
379
380 // UAC2 Type I Format Type Descriptor (6 bytes)
382 *p++ = 6;
383 *p++ = 0x24; // CS_INTERFACE
384 *p++ = 0x02; // FORMAT_TYPE
385 *p++ = 0x01; // FORMAT_TYPE_I
386 *p++ = (uint8_t)(p_config->bits_per_sample / 8); // bSubslotSize
387 *p++ = p_config->bits_per_sample; // bBitResolution
388 return p;
389 }
390
391 // Standard Isochronous Endpoint Descriptor (7 bytes)
392 //
393 // wMaxPacketSize must be large enough for the highest rate the device
394 // advertises in the Clock Source GET_RANGE response. The actual per-frame
395 // byte count varies with the current sample rate; the host will never
396 // send or expect more than wMaxPacketSize in a single (micro)frame.
398 // Fixed clock: wMaxPacketSize matches the configured rate.
399 // Multi-rate: covers the highest rate actually advertised via GET_RANGE
400 // (see supported_sample_rates) -- sizing for anything higher would waste
401 // buffer/FIFO space for a rate the host can never select.
402 const uint16_t pkt = p_config->enable_multi_sample_rate
405 // bmAttributes: Isochronous (01) + sync type (bits[3:2]) + usage=data (00)
406 // bits 3:2: 00=None, 01=Async, 10=Adaptive, 11=Sync
407 // IN endpoints: Asynchronous (0x05) — device drives the clock.
408 // OUT endpoints: Asynchronous (0x05) when a feedback EP is present,
409 // Adaptive (0x09) otherwise (device adapts to host rate).
410 bool const is_in = (ep_addr & 0x80u);
411 bool const is_out = !is_in;
412 uint8_t bmAttr;
413 if (is_in) bmAttr = 0x05u; // ISO + Async
414 else if (is_out && enableFeedbackEp()) bmAttr = 0x05u; // ISO + Async
415 else bmAttr = 0x09u; // ISO + Adaptive
416 *p++ = 7;
417 *p++ = 0x05; // ENDPOINT
418 *p++ = ep_addr;
419 *p++ = bmAttr;
420 *p++ = (uint8_t)(pkt & 0xFF);
421 *p++ = (uint8_t)(pkt >> 8);
422 *p++ = 0x01; // bInterval (1 = every frame for FS; host uses 125 µs for HS)
423 return p;
424 }
425
426 // Explicit Feedback Endpoint Descriptor (7 bytes, IN, no CS descriptor)
428 *p++ = 7;
429 *p++ = 0x05; // ENDPOINT
430 *p++ = ep_addr; // must be an IN address (bit 7 set)
431 *p++ = 0x11; // Isochronous, No Sync, Explicit Feedback usage
432 *p++ = 0x04; // wMaxPacketSize LSB (4 bytes)
433 *p++ = 0x00; // wMaxPacketSize MSB
434 *p++ = 0x01; // bInterval
435 return p;
436 }
437
438 // Audio Control Interrupt IN Endpoint Descriptor (7 bytes)
439 //
440 // Carries 6-byte UAC2 status/change notifications (bInfo, bAttribute,
441 // wValue = CS<<8|CN, wIndex = EntityID<<8|Itf) so the device can push
442 // volume, mute, or sample-rate changes to the host.
444 *p++ = 7;
445 *p++ = 0x05; // ENDPOINT
446 *p++ = ep_addr; // IN address (bit 7 set)
447 *p++ = 0x03; // bmAttributes: Interrupt
448 *p++ = 0x06; // wMaxPacketSize LSB (6 bytes for UAC2 notification)
449 *p++ = 0x00; // wMaxPacketSize MSB
450 *p++ = 0x10; // bInterval: 2^(16-1) = 32768 frames ≈ poll only when needed
451 return p;
452 }
453
454 // UAC2 CS ISO Endpoint Descriptor (8 bytes)
456 *p++ = 8;
457 *p++ = 0x25; // CS_ENDPOINT
458 *p++ = 0x01; // EP_GENERAL
459 *p++ = 0x00; // bmAttributes
460 *p++ = 0x00; // bmControls
461 *p++ = 0x00; // bLockDelayUnits (no locking)
462 *p++ = 0x00;
463 *p++ = 0x00; // wLockDelay
464 return p;
465 }
466};
467
468} // namespace audio_tools
#define USB_AUDIO_MAX_ISO_EP
Definition USBAudioConfig.h:96
USB Audio Class 2.0 descriptor generator.
Definition USBAudio2DescriptorBuilder.h:29
uint8_t * writeInputTerminal(uint8_t *p, uint8_t term_id, uint16_t term_type, uint8_t clock_id)
Definition USBAudio2DescriptorBuilder.h:288
uint8_t * writeFeedbackEndpoint(uint8_t *p, uint8_t ep_addr)
Definition USBAudio2DescriptorBuilder.h:427
uint8_t * writeIsoEndpoint(uint8_t *p, uint8_t ep_addr)
Definition USBAudio2DescriptorBuilder.h:397
uint8_t * writeClockSource(uint8_t *p, uint8_t clock_id)
Definition USBAudio2DescriptorBuilder.h:275
static constexpr uint8_t ENTITY_OT1
first Output Terminal
Definition USBAudio2DescriptorBuilder.h:37
uint8_t * writeCsIsoEndpoint(uint8_t *p)
Definition USBAudio2DescriptorBuilder.h:455
const uint16_t buildFullDescriptor(uint8_t *desc)
Definition USBAudio2DescriptorBuilder.h:53
static constexpr uint8_t ENTITY_FU2
second Feature Unit (RXTX)
Definition USBAudio2DescriptorBuilder.h:39
static constexpr uint8_t ENTITY_FU1
first Feature Unit
Definition USBAudio2DescriptorBuilder.h:36
uint8_t * writeInterruptEndpoint(uint8_t *p, uint8_t ep_addr)
Definition USBAudio2DescriptorBuilder.h:443
uint8_t * writeStdIface(uint8_t *p, uint8_t itf, uint8_t alt, uint8_t nEps, uint8_t cls, uint8_t sub, uint8_t proto)
Definition USBAudio2DescriptorBuilder.h:214
int audioFunctionsCount() const
Definition USBAudio2DescriptorBuilder.h:144
static constexpr uint8_t ENTITY_CLOCK
Definition USBAudio2DescriptorBuilder.h:34
uint8_t * writeOutputTerminal(uint8_t *p, uint8_t term_id, uint16_t term_type, uint8_t src_id, uint8_t clock_id)
Definition USBAudio2DescriptorBuilder.h:343
const uint16_t buildFullDescriptor(uint8_t first_itf, uint8_t *desc)
Definition USBAudio2DescriptorBuilder.h:58
uint8_t deviceCategory() const
Definition USBAudio2DescriptorBuilder.h:247
static constexpr uint8_t ENTITY_IT2
second Input Terminal (RXTX)
Definition USBAudio2DescriptorBuilder.h:38
uint32_t channelConfig() const
Definition USBAudio2DescriptorBuilder.h:191
uint8_t * writeIAD(uint8_t *p, uint8_t first_itf, uint8_t count)
Definition USBAudio2DescriptorBuilder.h:201
uint8_t * writeCsAcHeader(uint8_t *p)
Definition USBAudio2DescriptorBuilder.h:230
static constexpr uint8_t ENTITY_OT2
second Output Terminal (RXTX)
Definition USBAudio2DescriptorBuilder.h:40
static constexpr uint8_t ENTITY_IT1
first Input Terminal
Definition USBAudio2DescriptorBuilder.h:35
uint16_t calcPacketSizeForRate(uint32_t rate) const
Definition USBAudio2DescriptorBuilder.h:169
const uint16_t buildDescriptor(uint8_t, uint8_t, uint8_t *desc)
Definition USBAudio2DescriptorBuilder.h:46
USBAudioConfig * p_config
Definition USBAudio2DescriptorBuilder.h:187
uint8_t * writeFormatType(uint8_t *p)
Definition USBAudio2DescriptorBuilder.h:381
uint16_t calcMaxPacketSize() const
Definition USBAudio2DescriptorBuilder.h:181
bool enableFeedbackEp() const
Definition USBAudio2DescriptorBuilder.h:159
uint8_t * writeFeatureUnit(uint8_t *p, uint8_t unit_id, uint8_t src_id)
Definition USBAudio2DescriptorBuilder.h:325
uint8_t * writeCsAsInterface(uint8_t *p, uint8_t terminal_link)
Definition USBAudio2DescriptorBuilder.h:361
USBAudio2DescriptorBuilder(USBAudioConfig &cfg)
Definition USBAudio2DescriptorBuilder.h:42
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition LMSEchoCancellationStream.h:6
uint32_t highestSupportedSampleRate(const USBAudioConfig &cfg)
Definition USBAudioConfig.h:342
sample_rate_t sample_rate
Sample Rate: e.g 44100.
Definition AudioTypes.h:58
uint16_t channels
Number of channels: 2=stereo, 1=mono.
Definition AudioTypes.h:60
uint8_t bits_per_sample
Number of bits per sample (int16_t = 16 bits)
Definition AudioTypes.h:62
Configuration for USB Audio (inherits sample_rate / channels / bits_per_sample from AudioInfo).
Definition USBAudioConfig.h:128
bool enable_interrupt_ep
Definition USBAudioConfig.h:221
bool enable_feedback_ep_rxtx
Definition USBAudioConfig.h:192
int16_t ep_fb
ISO IN (explicit feedback, see enable_feedback_ep)
Definition USBAudioConfig.h:145
int16_t ep_in
ISO IN (device → host, capture/microphone)
Definition USBAudioConfig.h:143
bool enable_multi_sample_rate
Definition USBAudioConfig.h:201
int16_t ep_int
INT IN (AC status/change notifications)
Definition USBAudioConfig.h:146
bool enable_feedback_ep
Definition USBAudioConfig.h:181
int16_t ep_out
ISO OUT (host → device, playback/speaker)
Definition USBAudioConfig.h:144
bool enable_ep_in
device → host (capture / microphone)
Definition USBAudioConfig.h:131
uint8_t itf_num_ac
Definition USBAudioConfig.h:151
bool enable_ep_out
host → device (playback / speaker)
Definition USBAudioConfig.h:132