USB Audio Recorder
Default mainpageat91libusbdeviceaudio-speakerUSB Audio Recorder
Description
audio-speaker.dir::USB Audio Recorder
 
This page describes how to add recorder function into the "USB Audio Speaker Device", So that you can learn how to extend your audio device driver from current Audio Speaker demo.
Description
To add audio record function, new Input Terminal, Output Termnial and Feature Unit is added.

UsbAudioSpeakerRecorder.png
USB Desktop Speaker Hierarchy


Modify the configuration descriptor:
New descriptor for the terminals and unit should be added, and according interface, too.

UsbAudioSpeakerRecorderDescriptors.png
USB Desktop Speaker Descriptors


Terminal Descriptors and Unit Descriptor
... !Input Terminal Descriptor for recording ...
OffsetFieldSizeValueDescription
0bLength10x0CSize of this descriptor, in bytes.
1bDescriptorType10x24CS_INTERFACE descriptor
(AUDGenericDescriptor_INTERFACE).
2bDescriptorSubType10x03INPUT_TERMINAL subtype
(AUDGenericDescriptor_INPUTTERMINAL).
3bTerminalID10x03ID of this Input Terminal
(AUDDSpeakerDriverDescriptors_INPUTTERMINAL_REC).
4wTerminalType20x0403Terminal is Speaker Phone
(AUDInputTerminalDescriptor_SPEAKERPHONE).
6bAssocTerminal10x04Associated to Output Terminal
(AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL_REC).
7bNrChannels10x02Two channel.
8wChannelConfig20x0003Left plus right front channel.
10iChannelNames10x00Unused.
11iTerminal10x00Unused.

Output Terminal Descriptor for recording
...
OffsetFieldSizeValueDescription
0bLength10x09Size of this descriptor, in bytes.
1bDescriptorType10x24CS_INTERFACE descriptor
(AUDGenericDescriptor_INTERFACE).
2bDescriptorSubType10x04OUTPUT_TERMINAL subtype
(AUDGenericDescriptor_OUTPUTTERMINAL).
3bTerminalID10x04ID of this Output Terminal
(AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL_REC).
4wTerminalType20x0301Terminal is USB stream
(AUDOutputTerminalDescriptor_USBTREAMING).
6bAssocTerminal10x03Associated to Input Terminal
(AUDDSpeakerDriverDescriptors_INPUTTERMINAL_REC).
7bSourceID10x05From Feature Unit
(AUDDSpeakerDriverDescriptors_FEATUREUNIT_REC).
8iTerminal10x00Unused.

Feature Unit Descriptor for recording
...
OffsetFieldSizeValueDescription
0bLength10x0ASize of this descriptor, in bytes.
1bDescriptorType10x24CS_INTERFACE descriptor
(AUDGenericDescriptor_INTERFACE).
2bDescriptorSubType10x02FEATURE_UNIT subtype
(AUDGenericDescriptor_FEATUREUNIT).
3bUnitID10x05ID of this Feature Unit
(AUDDSpeakerDriverDescriptors_FEATUREUNIT_REC).
4bSourceID10x03From Input Terminal
(AUDDSpeakerDriverDescriptors_INPUTTERMINAL_REC).
5bControlSize10x011 byte per channel for controls
6bmaControls30x000001Master channel mute control, no other controls.
9iFeature10x00Unused.

Interface Descriptor and Endpoint Descriptor for recording
...

Zero-bandwidth Alternate Setting 0
Standard AS Interface Descriptor (USBInterfaceDescriptor)
OffsetFieldSizeValueDescription
0bLength10x09Size of this descriptor, in bytes.
1bDescriptorType10x04INTERFACE descriptor
(USBGenericDescriptor_INTERFACE).
2bInterfaceNumber10x02Index of this interface.
3bAlternateSetting10x00Index of this setting.
4bNumEndpoints10x000 endpoint.
5bInterfaceClass10x01AUDIO (AUDStreamingInterfaceDescriptor_CLASS).
6bInterfaceSubClass10x02AUDIO_STREAMING
(AUDStreamingInterfaceDescriptor_SUBCLASS).
7bInterfaceProtocol10x00Unused (AUDStreamingInterfaceDescriptor_PROTOCOL).
8iInterface10x00Unused.

Operational Alternate Setting 1
Standard AS Interface Descriptor (USBInterfaceDescriptor)
OffsetFieldSizeValueDescription
0bLength10x09Size of USBInterfaceDescriptor in bytes.
1bDescriptorType10x04INTERFACE descriptor
(USBGenericDescriptor_INTERFACE).
2bInterfaceNumber10x02Index of this interface.
3bAlternateSetting10x01Index of this setting.
4bNumEndpoints10x011 endpoint.
5bInterfaceClass10x01AUDIO (AUDStreamingInterfaceDescriptor_CLASS).
6bInterfaceSubClass10x02AUDIO_STREAMING
(AUDStreamingInterfaceDescriptor_SUBCLASS).
7bInterfaceProtocol10x00Unused (AUDStreamingInterfaceDescriptor_PROTOCOL).
8iInterface10x00Unused.

Class-specific AS General Interface Descriptor (AUDStreamingInterfaceDescriptor)
OffsetFieldSizeValueDescription
0bLength10x06Size of AUDStreamingInterfaceDescriptor in bytes.
1bDescriptorType10x24CS_INTERFACE descriptor
(AUDGenericDescriptor_INTERFACE).
2bDescriptorSubType10x01GENERAL subtype
(AUDStreamingInterfaceDescriptor_GENERAL).
3bTerminalLink10x02Unit ID of the Input Terminal
(AUDDSpeakerDriverDescriptors_INPUTTERMINAL).
4bDelay10x00No interface delay.
5wFormatTag20x0001PCM Format (AUDFormatTypeOneDescriptor_PCM).

Type I Format Type Descriptor (AUDFormatTypeOneDescriptor1)
OffsetFieldSizeValueDescription
0bLength10x0BSize of AUDFormatTypeOneDescriptor1 in bytes.
1bDescriptorType10x24CS_INTERFACE descriptor
(AUDGenericDescriptor_INTERFACE).
2bDescriptorSubType10x02FORMAT_TYPE subtype
(AUDStreamingInterfaceDescriptor_FORMATTYPE).
3bFormatType10x01FORMAT_TYPE_I (AUDFormatTypeOneDescriptor_FORMATTYPEONE).
4bNrChannels10x022 channels (AUDDSpeakerDriver_NUMCHANNELS).
5bSubFrameSize10x02Two bytes per audio subframe
(AUDDSpeakerDriver_BYTESPERSAMPLE).
6bBitResolution10x1016 bits per sample
(AUDDSpeakerDriver_BYTESPERSAMPLE * 2).
7bSamFreqType10x01One frequency supported.
8tSamFreq348004800Hz (AUDDSpeakerDriver_SAMPLERATE).

Standard Endpoint Descriptor (AUDEndpointDescriptor)
OffsetFieldSizeValueDescription
0bLength10x09Size of AUDFormatTypeOneDescriptor1 in bytes.
1bDescriptorType10x24ENDPOINT descriptor (USBGenericDescriptor_ENDPOINT).
2bEndpointAddress10x85IN endpoint 5
USBEndpointDescriptor_ADDRESS()
AUDDSpeakerDriverDescriptors_DATAIN
3bmAttributes10x01Isochronous, not shared
(USBEndpointDescriptor_ISOCHRONOUS).
4wMaxPacketSize20x????BOARD_USB_ENDPOINTS_MAXPACKETSIZE(5).
6bInterval10x01One packet per frame.
7bRefresh10x00Unused.
8bSynchAddress10x00Unused.

Class-specific Isochronous Audio Data Endpoint Descriptor (AUDDataEndpointDescriptor)
OffsetFieldSizeValueDescription
0bLength10x07Size of AUDDataEndpointDescriptor in bytes.
1bDescriptorType10x25CS_ENDPOINT descriptor
(AUDGenericDescriptor_ENDPOINT).
2bDescriptorSubType10x01GENERAL subtype
(AUDDataEndpointDescriptor_SUBTYPE).
3bmAttributes10x00No sampling frequency control
no pitch control
no packet padding
4bLockDelayUnits10x00Unused.
5wLockDelay20x0000Unused.

Modified methods for new function
Several methods modified for new recorder function.

Request handlers callbacks
Add handler for new Interface, Terminal and Unit IDs. See AUDDSpeakerDriver_RequestHandler.

Add function for recording USB stream
See AUDDSpeakerDriver_Write.
 
Source
The documentation for this Page was generated from the following file:
  • audio-speaker.dir