Check alle échte Black Friday-deals Ook zo moe van nepaanbiedingen? Wij laten alleen échte deals zien

USB Audio class descriptors

Pagina: 1
Acties:

  • Marc.O
  • Registratie: Maart 2013
  • Laatst online: 03-03-2024
Ik ben bezig een usb audio streaming device te maken die ik aan mijn pc kan hangen. Hiervoor gebruik ik de voglende descriptors om mijn audio out endpoint te beschrijven:

C:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Interface 2: Speaker, alternate setting 1. Type 1 format descriptor.
static const UsbAudioStreamingType1DescriptorType UsbIfd2Format =
{
  sizeof(UsbAudioStreamingType1DescriptorType),                                       // uint8 bLength;
  UDESC_CS_INTERFACE,                                                                 // uint8 bDescriptorType;
  UA_FORMAT_TYPE,                                                                     // uint8 bDescriptorSubtype;
  UA_FORMAT_TYPE_I,                                                                   // uint8 bFormatType;
  AUDIO_LSR_NOC,                                                                      // uint8 bNrChannels;
  AUDIO_LSR_SAMPLE_SIZE,                                                              // uint8 bSubFrameSize;
  AUDIO_LSR_SAMPLE_SIZE << 3,                                                         // uint8 bBitResolution;
  0x00,                                                                               // uint8 bSamFreqType;
  (uint8)((AUDIO_LSR_MIN_SAMPLE_FREQUENCY) & 0xFF),                                   // uint8 first byte minumum sample frequency 
  (uint8)((AUDIO_LSR_MIN_SAMPLE_FREQUENCY >> 8) & 0xFF),                              // uint8 second byte minumum sample frequency                           
  (uint8)(((0x10000000 | AUDIO_LSR_MIN_SAMPLE_FREQUENCY) >> 16) & 0xFF),              // uint8 third byte minumum sample frequency 
  (uint8)((AUDIO_LSR_MAX_SAMPLE_FREQUENCY) & 0xFF),                                   // uint8 first byte maximum sample frequency 
  (uint8)((AUDIO_LSR_MAX_SAMPLE_FREQUENCY >> 8) & 0xFF),                              // uint8 second byte maximum sample frequency 
  (uint8)(((0x10000000 | AUDIO_LSR_MAX_SAMPLE_FREQUENCY) >> 16) & 0xFF),              // uint8 third byte maximum sample frequency 
};

// Interface 2: Speaker, alternate setting 1. Audio endpoint descriptor.
static const UsbAudioEndpointDescriptorType UsbIfd2StdEndpoint =
{
  sizeof(UsbAudioEndpointDescriptorType),                                             // uint8 bLength;
  USB_DT_ENDPOINT,                                                                    // uint8 bDescriptorType;
  USB_DIR_OUT | USB_EP_AUDIO_RX,                                                      // uint8 bEndpointAddress;
  0x01,                                                                               // uint8 bmAttributes;
  ((AUDIO_LSR_MAX_SAMPLE_FREQUENCY / 1000) * AUDIO_LSR_SAMPLE_SIZE) * AUDIO_LSR_NOC,  // uint16 wMaxPacketSize;
  0x01,                                                                               // uint8 bInterval;
  0x00,                                                                               // uint8 bRefresh;
  0x00,                                                                               // uint8 bSynchAddress;
};


Dit werkt prachtig met een sample format van 16bits gebruik makende van de volgende AUDIO_ settings.
C:
1
2
3
4
5
6
7
8
9
// Sample frequencies
#define AUDIO_LSR_MIN_SAMPLE_FREQUENCY 0x01F40  // 8kHz
#define AUDIO_LSR_MAX_SAMPLE_FREQUENCY 0x0BB80  // 48kHz

// Sample size
#define AUDIO_LSR_SAMPLE_SIZE 0x02 // in bytes

// Defines for mono/stereo.
#define AUDIO_LSR_NOC 0x02 // Number Of Channels (stereo)


Ik kan in windows gewoon kiezen tussen alle sample rates in de properties van playback devices.


Nu wil ik graag dat de audio stream gebruik gaat maken van een 24bits sample format. Dus met de volgende settings:
C:
1
2
3
4
5
6
7
8
9
// Sample frequencies
#define AUDIO_LSR_MIN_SAMPLE_FREQUENCY 0x01F40  // 8kHz
#define AUDIO_LSR_MAX_SAMPLE_FREQUENCY 0x0BB80  // 48kHz

// Sample size
#define AUDIO_LSR_SAMPLE_SIZE 0x03 // in bytes

// Defines for mono/stereo.
#define AUDIO_LSR_NOC 0x02 // Number Of Channels (stereo)


Het device meld zich nog steeds aan en er worden ook netjes 24bits per sample verstuurd. Het enige is dat ik geen verschillende sample frequencies meer kan selecteren in de properties van het playback device. Deze staat nu grayed out op 2 channel, 24bit, 48000 Hz.

Ik kan op google hier geen voorbeelden van vinden. Alleen de hele usb documentatie. Heeft iemand enig idee waar het aan kan liggen?

  • MSalters
  • Registratie: Juni 2001
  • Laatst online: 13-09 00:05
De beschikbare frequenties zijn natuurlijk alleen die frequenties die zowel door device als OS worden ondersteund. Heb je reden om aan te nemen dat Windows 24 bits/8kHz ondersteunt?

Resmapling is niet triviaal, en als Windows geen 24 bits resampler heeft dan kan ik me voorstellen dat er beperkingen aan de frequenties zijn.

Man hopes. Genius creates. Ralph Waldo Emerson
Never worry about theory as long as the machinery does what it's supposed to do. R. A. Heinlein


  • Marc.O
  • Registratie: Maart 2013
  • Laatst online: 03-03-2024
Er zijn andere devices waarbij je wel gewoon 24bits kan selecteren.
Door de bSamFreqType; op 0 te zetten worden alle sample frequency's tussen 8kHz en 48kHz ondersteunt.
(8kHz 11.025kHz 16kHz 22.05kHz 32kHz 44.1kHz 48kHz). En bij 16bits samples werken deze dus allemaal.

[ Voor 60% gewijzigd door Marc.O op 29-11-2013 14:10 ]


  • Marc.O
  • Registratie: Maart 2013
  • Laatst online: 03-03-2024
Het blijkt dat het probleem niet in deze descriptors ligt. De Input Terminal Descriptor had een verkeerde channel config. Waarom het met 16bit wel werkt blijft een raadsel...