Discussion:
How to enumerate audio devices?
(too old to reply)
Chris P. [MVP]
2006-04-18 15:29:05 UTC
Permalink
I beg your pardon if the question is too simple for the group.
I try to enumerate audio devices to find my device and to check its
properties.
devNum = waveInGetNumDevs();
mRes=waveInGetDevCaps(devNum, &WIC, sizeof(WAVEINCAPS));
return correct number of devices and my device's devNum and MID/PID.
waveInGetDevCaps() is pretty much useless. It doesn't list any of the
extended formats and only returns the capabilities of the KMixer in most
cases.
Now I want to query device capabilities to know how many pins, nodes,
channels, bps etc
it support. (I have 64-channel 24bps 16ksps PCM audio recording device)
m_stWFEX.Format.cbSize=sizeof(WAVEFORMATEXTENSIBLE);
MMRESULT mRes=waveInOpen(&m_hWaveIn, devNum, (WAVEFORMATEX *)&m_stWFEX,
(DWORD_PTR)NULL, (DWORD_PTR)NULL, CALLBACK_NULL);
always return WAVEERR_BADFORMAT.
But this is exactly I'd like to - to know the format . Any format (if
the device supports any).
Where I'm wrong? How to open wave device if I do not know format it
supports?
It won't tell you, you have to guess or enumerate through the common
formats. Fully populate the WAVEFORMATEXTENSIBLE structure and call
waveInOpen(), if the format is supported it will succeed, otherwise it will
fail. You can add the WAVE_FORMAT_QUERY if you don't wish the device to
actually open.
Is there a way to ask the driver to fill WAVEFORMATEXTENSIBLE structure
for particular device so that after then to use it for device opening.
No. If you can locate the actual driver pins you should be able to
enumerate the driver supported formats, it's not something I have much
experience with.
--
http://www.chrisnet.net/code.htm
http://www.avdevforum.com/AV
a***@aol.com
2006-04-18 17:07:02 UTC
Permalink
m_stWFEX.Format.cbSize=sizeof(WAVEFORMATEXTENSIBLE);
MMRESULT mRes=waveInOpen(&m_hWaveIn, devNum, (WAVEFORMATEX *)&m_stWFEX,
(DWORD_PTR)NULL, (DWORD_PTR)NULL, CALLBACK_NULL);
always return WAVEERR_BADFORMAT.
Most likely to <g>. m_stWFEX.Format.cbSize is the size of extra bytes
over and above the basic size of WaveFormatEx (18).
SizeOf(WaveFormatExtensible is most likely 40 (18 + 22). MSDN says of
WAVEFORMATEXTENSIBLE ...

"typedef struct {
WAVEFORMATEX Format;
union {
WORD wValidBitsPerSample;
WORD wSamplesPerBlock;
WORD wReserved;
} Samples;
DWORD dwChannelMask;
GUID SubFormat;
} WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE;

Members

Format

WAVEFORMATEX structure that specifies the basic format. The wFormatTag
member must be WAVE_FORMAT_EXTENSIBLE, defined in Mmreg.h. The cbSize
member must be at least 22.

<snip>"

Try putting 22 in cbSize and see if it works.

Alan Lloyd
KathiMarge
2006-04-20 09:22:35 UTC
Permalink
Thank you, Chris
This is really helpful.

One more thing: could you (or somebody here) suggest:
if an audio stream (pin) is attached to a mixer and this pin
has many, say 7 (or 64 as in my case) channels, how to mute
all but one. (I can mute all or none, but I need to selectively route
audio channels - one at a time - to speaker)

Or could you suggest any comprehensive source of information about
mixer use. In MSDN there is (I've found) a very short description of
its 10 functions. It is too short for me to understand how to use them.
Post by Chris P. [MVP]
I beg your pardon if the question is too simple for the group.
I try to enumerate audio devices to find my device and to check its
properties.
devNum = waveInGetNumDevs();
mRes=waveInGetDevCaps(devNum, &WIC, sizeof(WAVEINCAPS));
return correct number of devices and my device's devNum and MID/PID.
waveInGetDevCaps() is pretty much useless. It doesn't list any of the
extended formats and only returns the capabilities of the KMixer in most
cases.
Now I want to query device capabilities to know how many pins, nodes,
channels, bps etc
it support. (I have 64-channel 24bps 16ksps PCM audio recording device)
m_stWFEX.Format.cbSize=sizeof(WAVEFORMATEXTENSIBLE);
MMRESULT mRes=waveInOpen(&m_hWaveIn, devNum, (WAVEFORMATEX
*)&m_stWFEX,
(DWORD_PTR)NULL, (DWORD_PTR)NULL, CALLBACK_NULL);
always return WAVEERR_BADFORMAT.
But this is exactly I'd like to - to know the format . Any format (if
the device supports any).
Where I'm wrong? How to open wave device if I do not know format it
supports?
It won't tell you, you have to guess or enumerate through the common
formats. Fully populate the WAVEFORMATEXTENSIBLE structure and call
waveInOpen(), if the format is supported it will succeed, otherwise it will
fail. You can add the WAVE_FORMAT_QUERY if you don't wish the device to
actually open.
Is there a way to ask the driver to fill WAVEFORMATEXTENSIBLE
structure
for particular device so that after then to use it for device
opening.
No. If you can locate the actual driver pins you should be able to
enumerate the driver supported formats, it's not something I have much
experience with.
--
http://www.chrisnet.net/code.htm
http://www.avdevforum.com/AV
a***@aol.com
2006-04-20 09:57:11 UTC
Permalink
This post might be inappropriate. Click to display it.
Loading...