[wdmaudiodev] Re: USB audio record problem

  • From: "Daniel E. Germann" <deg@xxxxxxxx>
  • To: <wdmaudiodev@xxxxxxxxxxxxx>
  • Date: Fri, 14 Oct 2011 18:25:17 -0500

Hi, Matthew.

What I want to get in my wave input device capture buffer is 24-bit data in a 32-bit DWORD.  But for some reason, I'm not seeing that.  And I can't see a problem in the wave format descriptors I'm using.  If you have any suggestions, I'd really appreciate them.

David Hoatson recommended I delete the "+ 7" from my nBlockAlign computation (cut-and-paste leftover from pre-WAVE_FORMAT_EXTENSIBLE days) since it isn't doing anything, and I've done that.  But it doesn't change the result of the computation and it doesn't change the captured data.

wform.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
wform.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
wform.Format.nChannels = 2;
wform.Format.nSamplesPerSec = samplerate;
wform.Format.wBitsPerSample = alignment;
wform.Format.nBlockAlign = (alignment * wform.Format.nChannels) / 8;
wform.Format.nAvgBytesPerSec = wform.Format.nSamplesPerSec * wform.Format.nBlockAlign;
wform.Samples.wValidBitsPerSample = bitspersample;
wform.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;
wform.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;

Here are memory dumps of tests run with different wave formats.  All are using WAVE_FORMAT_EXTENSIBLE.  I am playing a signal out the playback side of the device and looping it back into the record side of the device.  I had an oscilloscope on the output signal, and it was always a ~1.4v p-p 1 kHz sine wave during the test.  So the output side of all this works fine.

16-bit container, 16 valid data bits:
00DE9148  EF5C  EF8D  EFDF  F010  F0B4  F0E2  F1D7  F201  F342  F369  F4EE  F510 
00DE9160  F6D2  F6F0  F8E6  F8FC  FB1D  FB2E  FD6D  FD78  FFCA  FFCD  0229  0224 
00DE9178  047B  0471  06B7  06A7  08D1  08BA  0ABF  0AA2  0C76  0C53  0DED  0DC6 
00DE9190  0F1C  0EF2  1000  0FD3  1091  1063  10CE  109F  10B7  1087  1049  101B 
00DE91A8  0F89  0F5C  0E79  0E50  0D20  0CFB  0B85  0B63  09AD  0992  07A5  0790 
00DE91C0  0577  0568  032D  0323  00D2  00CF  FE73  FE76  FC1B  FC27  F9D9  F9E9 
00DE91D8  F7B4  F7CC  F5BA  F5D7  F3F4  F417  F26C  F293  F129  F155  F032  F05F 
00DE91F0  EF8A  EFBA  EF38  EF69  EF39  EF6B  EF8F  EFC0  F03B  F06A  F136  F162 
00DE9208  F27D  F2A6  F408  F42C  F5CF  F5EF  F7CC  F7E6  F9F1  FA05  FC35  FC43 
00DE9220  FE8E  FE94  00EC  00ED  0347  0340  0590  0583  07BE  07AA  09C4  09AA 
00DE9238  0B98  0B79  0D31  0D0D  0E86  0E5E  0F93  0F68  1050  1022  10B8  1089 
00DE9250  10CD  109E  108C  105D  0FF8  0FCA  0F11  0EE5  0DDC  0DB5  0C63  0C40 
00DE9268  0AAA  0A8B  08BA  08A2  06A0  068B  0462  0454  020D  0207  FFAF  FFB0 
00DE9280  FD52  FD59  FB03  FB11  F8CE  F8E2  F6BC  F6D7  F4DA  F4FA  F331  F356 
00DE9298  F1CA  F1F3  F0A8  F0D5  EFD7  F007  EF58  EF89  EF2C  EF5E  EF58  EF89 
00DE92B0  EFD7  F007  F0AA  F0D7  F1C8  F1F4  F331  F359  F4DA  F4FD  F6BD  F6DA 
00DE92C8  F8CE  F8E6  FB04  FB14  FD52  FD5D  FFB0  FFB3  020E  020B  0461  0458 
00DE92E0  06A0  068F  08BB  08A4  0AAA  0A8E  0C64  0C42  0DDD  0DB7  0F11  0EE6 
00DE92F8  0FF7  0FCA  108C  105E  10CE  109E  10B9  108A  104F  1021  0F92  0F66 

This looks like a sine wave ranging from EFxx to 10xx.  It's not high-amplitude (to be expected with this test configuration), but it's clearly there.

32-bit container, 24 valid data bits:
00D20040  FFFFFF62  FFFFFF51  FFFFFF6C  0000003D  FFFFFFB1  FFFFFF73  00000091 
00D2005C  FFFFFFAC  00000010  000000B8  00000001  FFFFFFBD  FFFFFFB1  000000D5 
00D20078  000000AB  00000041  FFFFFF70  FFFFFF90  FFFFFFC9  0000002E  00000040 
00D20094  FFFFFFFA  FFFFFF69  FFFFFF1A  FFFFFF7D  FFFFFF4C  FFFFFFEF  00000045 
00D200B0  FFFFFFD3  0000001B  00000076  0000004C  000000C7  FFFFFFE1  000000AF 
00D200CC  FFFFFFB8  FFFFFFF6  00000017  FFFFFF94  FFFFFFDE  00000023  FFFFFFD3 
00D200E8  0000001D  FFFFFFF3  FFFFFF40  FFFFFFBF  FFFFFFDD  FFFFFF96  00000029 
00D20104  FFFFFF78  00000013  FFFFFF3B  FFFFFF4E  00000064  FFFFFF8B  FFFFFFFB 
00D20120  0000000A  00000009  00000047  00000024  FFFFFFCF  00000069  0000003E 
00D2013C  FFFFFFA6  00000032  FFFFFFF5  FFFFFFB6  FFFFFFB5  FFFFFFA9  FFFFFFFE 
00D20158  FFFFFFF3  FFFFFF22  00000006  FFFFFF24  FFFFFF97  00000052  0000000F 
00D20174  FFFFFFF0  FFFFFFFB  FFFFFFEB  00000095  FFFFFFE2  FFFFFFE3  FFFFFFF4 
00D20190  FFFFFF57  00000054  0000003C  FFFFFFC5  FFFFFFCE  0000009A  FFFFFFF8 
00D201AC  00000018  FFFFFF97  FFFFFF5A  FFFFFFB3  FFFFFFE9  FFFFFF7B  FFFFFFA1 
00D201C8  FFFFFFD3  00000078  FFFFFF4B  00000021  FFFFFF8B  0000006E  00000011 
00D201E4  FFFFFFE6  FFFFFFBC  0000002B  00000002  FFFFFF79  00000066  00000035 
00D20200  FFFFFFD2  FFFFFFEF  00000041  FFFFFF93  FFFFFFF4  000000AF  0000006D 
00D2021C  FFFFFFA0  FFFFFF7E  00000007  FFFFFFAD  FFFFFF9C  00000057  FFFFFFAF 
00D20238  0000001A  000000BE  FFFFFFFB  FFFFFF10  FFFFFF6F  00000025  FFFFFFEB 
00D20254  FFFFFF90  FFFFFFDF  FFFFFF97  FFFFFFBE  FFFFFF53  FFFFFFE7  FFFFFF40 
00D20270  00000055  FFFFFFAD  00000037  00000076  000000F2  00000010  00000028 

There doesn't appear to be anything valid here.  And the LSB doesn't look like the sine wave shifted down 24 bits.

24-bit container, 24 valid data bits (sorry, MSDEV doesn't have a 24-bit dump mode):
00D20040  00 00 00 00 00 00 00 00 00 FF FF FF 00 00 00 FF  .........ÿÿÿ...ÿ
00D20050  FF FF FF FF FF 00 00 00 FF FF FF FF FF FF FF FF  ÿÿÿÿÿ...ÿÿÿÿÿÿÿÿ
00D20060  FF 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF  ÿ...ÿÿÿÿÿÿÿÿÿÿÿÿ
00D20070  FF FF FF 00 00 00 00 00 00 00 00 00 FF FF FF FF  ÿÿÿ.........ÿÿÿÿ
00D20080  FF FF 00 00 00 00 00 00 FF FF FF 00 00 00 00 00  ÿÿ......ÿÿÿ.....
00D20090  00 00 00 00 FF FF FF 00 00 00 00 00 00 FF FF FF  ....ÿÿÿ......ÿÿÿ
00D200A0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00D200B0  00 00 00 00 00 FF FF FF 00 00 00 FF FF FF FF FF  .....ÿÿÿ...ÿÿÿÿÿ
00D200C0  FF FF FF FF 00 00 00 FF FF FF 00 00 00 00 00 00  ÿÿÿÿ...ÿÿÿ......
00D200D0  FF FF FF 00 00 00 FF FF FF FF FF FF 00 00 00 00  ÿÿÿ...ÿÿÿÿÿÿ....
00D200E0  00 00 FF FF FF 00 00 00 FF FF FF FF FF FF 00 00  ..ÿÿÿ...ÿÿÿÿÿÿ..
00D200F0  00 FF FF FF 00 00 00 FF FF FF FF FF FF FF FF FF  .ÿÿÿ...ÿÿÿÿÿÿÿÿÿ
00D20100  FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00D20110  FF FF 00 00 00 FF FF FF FF FF FF 00 00 00 FF FF  ÿÿ...ÿÿÿÿÿÿ...ÿÿ
00D20120  FF FF FF FF 00 00 00 FF FF FF 00 00 00 FF FF FF  ÿÿÿÿ...ÿÿÿ...ÿÿÿ
00D20130  FF FF FF 00 00 00 00 00 00 FF FF FF FF FF FF 00  ÿÿÿ......ÿÿÿÿÿÿ.
00D20140  00 00 00 00 00 FF FF FF 00 00 00 FF FF FF FF FF  .....ÿÿÿ...ÿÿÿÿÿ
00D20150  FF FF FF FF FF FF FF FF FF FF 00 00 00 FF FF FF  ÿÿÿÿÿÿÿÿÿÿ...ÿÿÿ
00D20160  00 00 00 00 00 00 00 00 00 FF FF FF 00 00 00 FF  .........ÿÿÿ...ÿ
00D20170  FF FF FF FF FF 00 00 00 00 00 00 FF FF FF 00 00  ÿÿÿÿÿ......ÿÿÿ..
00D20180  00 FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00  .ÿÿÿÿÿÿ.........
00D20190  00 00 00 00 00 00 FF FF FF 00 00 00 00 00 00 FF  ......ÿÿÿ......ÿ
00D201A0  FF FF FF FF FF FF FF FF 00 00 00 FF FF FF FF FF  ÿÿÿÿÿÿÿÿ...ÿÿÿÿÿ
00D201B0  FF FF FF FF 00 00 00 00 00 00 FF FF FF 00 00 00  ÿÿÿÿ......ÿÿÿ...
00D201C0  00 00 00 FF FF FF 00 00 00 00 00 00 00 00 00 FF  ...ÿÿÿ.........ÿ
00D201D0  FF FF 00 00 00 FF FF FF FF FF FF 00 00 00 FF FF  ÿÿ...ÿÿÿÿÿÿ...ÿÿ
00D201E0  FF FF FF FF 00 00 00 FF FF FF FF FF FF FF FF FF  ÿÿÿÿ...ÿÿÿÿÿÿÿÿÿ
00D201F0  00 00 00 FF FF FF FF FF FF 00 00 00 00 00 00 00  ...ÿÿÿÿÿÿ.......
00D20200  00 00 FF FF FF FF FF FF 00 00 00 FF FF FF 00 00  ..ÿÿÿÿÿÿ...ÿÿÿ..
00D20210  00 00 00 00 00 00 00 FF FF FF 00 00 00 00 00 00  .......ÿÿÿ......

No valid data, just 000000 and FFFFFF.

32-bit container, 32 valid data bits:
00D20040  00000000  00000000  00000000  00000000  00000000  00000000  00000001 
00D2005C  00000000  00000001  00000000  00000000  00000000  00000000  00000000 
00D20078  00000000  00000000  00000000  FFFFFFFF  00000000  00000001  00000000 
00D20094  FFFFFFFF  00000000  00000000  00000000  00000000  00000000  FFFFFFFF 
00D200B0  00000000  00000000  00000001  FFFFFFFF  00000001  00000001  FFFFFFFF 
00D200CC  00000000  FFFFFFFF  00000000  00000000  00000000  00000001  FFFFFFFF 
00D200E8  FFFFFFFF  00000000  FFFFFFFF  FFFFFFFF  00000000  00000000  00000000 
00D20104  FFFFFFFF  00000000  00000000  00000000  00000000  00000000  00000000 
00D20120  00000000  FFFFFFFF  00000000  00000000  00000000  00000000  00000000 
00D2013C  00000000  00000000  00000000  00000000  00000000  FFFFFFFF  00000000 
00D20158  00000001  00000000  00000000  00000000  00000000  00000000  FFFFFFFF 
00D20174  00000000  00000000  00000000  00000000  00000001  00000000  00000000 
00D20190  00000000  00000000  00000000  FFFFFFFF  00000000  00000000  00000001 
00D201AC  00000001  00000000  00000000  FFFFFFFF  00000000  00000000  00000000 
00D201C8  00000000  00000001  00000001  FFFFFFFF  00000000  FFFFFFFF  00000000 
00D201E4  00000000  00000001  00000000  00000000  00000000  00000000  00000000 
00D20200  00000000  00000000  00000000  00000000  00000000  00000000  00000000 
00D2021C  00000001  00000000  00000000  FFFFFFFF  00000000  00000001  00000001 
00D20238  00000000  00000000  00000000  00000000  00000000  00000000  00000000 
00D20254  00000000  FFFFFFFF  00000000  00000000  00000000  00000000  00000001 
00D20270  FFFFFFFF  00000000  00000000  00000000  00000000  00000000  00000001 

Nothing valid here, either.  But it does look like a dither pattern around 0...

And, just to be complete, 32-bit container, 16 valid data bits:
00D20068  FFFF6C5B  00000C00  00004699  FFFFB773  00004DA3  FFFF98B4  0000066D 
00D20084  0000B6AD  00002698  FFFF706D  00008E86  FFFF5006  FFFFA117  FFFFE88D 
00D200A0  000039DE  00000E38  000034E2  00003093  FFFFCFCA  FFFFDF3C  0000DD89 
00D200BC  FFFF65FF  00005745  00006523  00000149  000069CF  00006513  000043AD 
00D200D8  00006FAA  FFFFE30D  0000287D  FFFFEF9F  0000398A  0000BE48  FFFF999F 
00D200F4  FFFFDDED  000079D2  FFFF91A8  FFFF75F4  0000E0DD  00000CEF  FFFFD17C 
00D20110  00008BDC  0000911E  FFFFB8C8  FFFFD51E  0000497F  000050DF  FFFFBD8F 
00D2012C  0000588E  0000C77E  FFFFFB0F  FFFF9945  FFFFAFAD  000062AD  FFFF9EF8 
00D20148  00004406  0000328E  FFFFB0D3  00001173  00009A01  FFFF25E1  FFFFCFB5 
00D20164  00003BD9  00009608  00001C63  FFFF8985  FFFF4DE9  FFFFB7D1  FFFFC9DC 
00D20180  0000265F  000006E9  FFFFA705  FFFFC2FE  FFFFB728  00005A2B  FFFFF8CA 
00D2019C  FFFFE05F  FFFF157F  FFFFFE23  0000956B  FFFFC63C  FFFFDF98  00006C0A 
00D201B8  FFFF9717  FFFF8897  00008E3A  FFFFB207  000019D4  00003DFA  00007F67 
00D201D4  0000282F  000004AD  00003890  000079AF  FFFFDE19  000058A4  FFFFDA0D 
00D201F0  FFFFF669  FFFFC2AC  00000FFC  FFFFE513  00003A2D  00000FCB  FFFFCC7D 
00D2020C  FFFF7262  00000ED4  FFFFE96D  0000C9DE  00008E30  FFFFFD90  00001755 

Nothing -- just 0000 and FFFF (and not even the same sign for samples that should have the same sign).  And, again, the 16 lowest bits don't look like a sine wave, either.

In all cases, there was a test signal on the 'scope, so I know the ADC is getting a sine wave.  The only variable is the wave format descriptor.  I'm willing to consider that our USB device is causing this behavior, but I can't imagine how it could be doing this -- it doesn't know (or care) what bit depth the application opens the device at; it's always streaming 24-bit audio (3 bytes/sample; 6 bytes/frame, stereo) -- that's the only format it supports.  So how can I possibly get these results?  Am I missing something?  I cannot fathom how even messed up wave format parameters would cause this behavior.  And only on the record side for >16-bit containers.

Does anyone have any good (or even bad) ideas / suggestions?

Thank you,
-Dan

-----

>From: Matthew van Eerde <Matthew.van.Eerde@xxxxxxxxxxxxx>
> Subject: [wdmaudiodev] Re: USB audio record problem
> Date: Wed, 12 Oct 2011 22:59:17 +0000
>
> How are you interpreting the samples?  If the container
>size is greater than the valid bits, then the invalid
>bits are the least significant ones.
> Does 24-bit-samples-in-24-bit-containers work?
>
>From: wdmaudiodev-bounce@xxxxxxxxxxxxx
>[mailto:wdmaudiodev-bounce@xxxxxxxxxxxxx] On Behalf Of
>Daniel E. Germann
> Sent: Wednesday, October 12, 2011 3:52 PM
> To: wdmaudiodev@xxxxxxxxxxxxx
> Subject: [wdmaudiodev] USB audio record problem
>
> We developed a USB audio device (2 channels, 44.1 / 48
>kHz, 24-bit (3 byte) samples, full duplex play and
>record), and it seems to work pretty well most of the
>time.  But we have one interesting scenario where
>recording doesn't appear to work under Windows XP (SP3).
>
> If I open the device with 16-bit resolution
>(WAVE_FORMAT_PCM or WAVE_FORMAT_EXTENSIBLE) and try to
>record, I can see plausible audio in the wave capture
>buffer.  If I open the device with 32-bit resolution
>(WAVE_FORMAT_EXTENSIBLE, 32-bit container, 24-bit audio)
>and try to record, the audio is not there (or is greatly
>attenuated) -- the upper 16 bits are either 0000 or FFFF
>and there is only data in the lower 8 bits (hard to tell
>if it's real or not).  If I open the device with 32-bit
>resolution (WAVE_FORMAT_EXTENSIBLE, 32-bit container,
>32-bit audio) and try to record, the upper 24 bits of the
>sample are either 000000 or FFFFFF and the lowest 8 bits
>have some sort of data in them (again, hard to tell if
>it's real or not).
>
> Playback works fine with both 16-bit and 24-bit
>resolution.
>
> The really interesting thing is that the internal sound
>card on my laptop does pretty much the same thing.
>
> That makes me wonder if there's something wrong with my
>wave format descriptor (pasted below).  But it does work
>(both WAVE_FORMAT_PCM and WAVE_FORMAT_EXTENSIBLE) at
>16-bit resolution.  Only 24-bit resolution fails.  And
>I've checked the filled-in struct in the debugger, and
>the values all seem to make sense (in fact, they match an
>example in the online docs).
>
> Also, we have at least one other customer application
>that experiences the same problem when recording.
>
> Does this sound familiar to anyone?  Or am I just
>missing something really obvious?
>
> Thanks,
> -Dan
>
>
> int alignment, bitspersample, samplerate;
> WAVEFORMATEXTENSIBLE wform;
>
> samplerate = 48000;  // actually comes from UI
> bitspersample = IsDlgButtonChecked(IDC_BITS24) ? 24 :
>16;
> if (bitspersample == 24)
>  alignment = 32;
> else
>  alignment = 16;
>
> memset(&wform, 0, sizeof(wform));
> #if 1  // 0=force WAVE_FORMAT_EXTENSIBLE for 16-bit
>audio
> if (bitspersample == 16)
> {
>  wform.Format.wFormatTag = WAVE_FORMAT_PCM;
>  wform.Format.cbSize = 0;
>  wform.Format.nChannels = 2;
>  wform.Format.nSamplesPerSec = samplerate;
>  wform.Format.wBitsPerSample = bitspersample;
>  wform.Format.nBlockAlign = (alignment *
>wform.Format.nChannels + 7) / 8;
>  wform.Format.nAvgBytesPerSec =
>wform.Format.nSamplesPerSec * wform.Format.nBlockAlign;
> }
> else
> #endif
> {
>  wform.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
>  wform.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) -
>sizeof(WAVEFORMATEX);  // = 22
>  wform.Format.nChannels = 2;
>  wform.Format.nSamplesPerSec = samplerate;
>  wform.Format.wBitsPerSample = alignment;
>  wform.Format.nBlockAlign = (alignment *
>wform.Format.nChannels + 7) / 8;
>  wform.Format.nAvgBytesPerSec =
>wform.Format.nSamplesPerSec * wform.Format.nBlockAlign;
>  wform.Samples.wValidBitsPerSample = bitspersample;
>  wform.dwChannelMask = SPEAKER_FRONT_LEFT |
>SPEAKER_FRONT_RIGHT;
>  wform.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
> }
****************** WDMAUDIODEV addresses: Post message: mailto:wdmaudiodev@xxxxxxxxxxxxx Subscribe: mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=subscribe Unsubscribe: mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=unsubscribe Moderator: mailto:wdmaudiodev-moderators@xxxxxxxxxxxxx URL to WDMAUDIODEV page: http://www.wdmaudiodev.com/

Other related posts: