[wdmaudiodev] Re: Default Sampling Rate

  • From: Anton Shpakovsky <anton.shpakovsky@xxxxxxxxx>
  • To: wdmaudiodev@xxxxxxxxxxxxx
  • Date: Tue, 8 May 2012 11:52:40 +0700

Matthew,

I guess this property is unsupported by most devices, correct?
The fact is, that we've tried our code on several sound cards, but no
success.

Obtaining the devicepath is correct for sure because we are able to request
some other properties from the device.
Please, take a look at the code below.

KSPROPERTY KSProp;
KSP_PIN KSPin;

// filling the KSProp structure
KSProp.Set = KSPROPSETID_Pin;
KSProp.Id = KSPROPERTY_PIN_PROPOSEDATAFORMAT;
KSProp.Flags = KSPROPERTY_TYPE_GET;

// and the KSPin structure
KSPin.PinId = 0;
KSPin.Property = KSProp;
KSPin.Reserved = 0;

// negotiating to the driver
hDevice = CreateFile(tczDevicePath, GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, 0, NULL);

if (hDevice != INVALID_HANDLE_VALUE)
{
// requesting KSCOMPONENTID structure
BOOL res = DeviceIoControl(hDevice, IOCTL_KS_PROPERTY,
&KSPin, sizeof(KSPin),
&ksDataFormat, sizeof(ksDataFormat),
&dwBytesRet, 0 );
DWORD err = GetLastError();
// the error code is 1168 which stands for "ERROR_NOT_FOUND 1168 (0x490)
Element not found."
CloseHandle(hDevice);
}

We also tried to request KSPROPERTY_PIN_CTYPES data and it returned two
pins available.
The first was identified as "Recording Control" while the second appeared
to be ERROR_FILE_NOT_FOUND. Weird.

Are we doing something wrong or it's normal that some devices may not
support this property?
Please advice.

Btw, from where it all started. We are implementing acoustic echo
cancellation for our product and we found out
that the best result we can get only on specific frequencies that appear to
be the native ones. When we request e.g. 22050Hz from the soundcard,
we guess a hardware resampling may occur because the sound card returns
strange amount of samples per second - sometimes less than 22050, sometimes
more. E.g. the 48000Hz works perfect so we though it may be the native
frequency for the device.

Thanks in advance,
Anton

On Mon, Apr 30, 2012 at 11:27 PM, Matthew van Eerde <
Matthew.van.Eerde@xxxxxxxxxxxxx> wrote:

>  If the device supports GET requests of the
> KSPROPERTY_PIN_PROPOSEDATAFORMAT property, you can assume that this is the
> device's preferred format.  If the device supports this, Windows will
> (usually) have that be the default format (though the user can still change
> the default to a different format.)
>
>
>
> If the device does not support GET requests of the
> KSPROPERTY_PIN_PROPOSEDATAFORMAT, then it comes down to figuring out what
> formats the device supports.  Windows has a list of formats that it will
> try, and the device can expose KS data ranges with specific sample rates.
>
>
>
> In addition to the below, you may come across devices that natively
> support 8 kHz (so you will not need a conversion at all.)
>
>
>
> ------------------------------
>
> *From:* wdmaudiodev-bounce@xxxxxxxxxxxxx [wdmaudiodev-bounce@xxxxxxxxxxxxx]
> on behalf of Finn William-A19681 [wfinn@xxxxxxxxxxxxxxxxxxxxx]
> *Sent:* Monday, April 30, 2012 7:10 AM
> *To:* wdmaudiodev@xxxxxxxxxxxxx
> *Cc:* Finn William-A19681
> *Subject:* [wdmaudiodev] Default Sampling Rate
>
>   Hi All,
>
>
>
> I am not developing an audio device driver, but rather I am interested in
> finding out the default sampling rate for a given device. I am developing
> an application that must operate on 8 kHz sampled data. I currently support
> resampling to/from 48k, 44.1k, 22.05k, and 16k endpoint sampling rates.
> However, during testing, I came across a device using a 32 kHz sampling
> rate, and I want to figure out if a user intentionally changed the sampling
> rate to 32 kHz or if it was the default sampling rate at installation.
>
>
>
> TL;DR: Is there an easy way to find the default sampling rate for a given
> input/output device in Windows?
>
>
>
> Thanks,
>
> Bill
>



-- 
Best Regards,
Anton Shpakovsky

Other related posts: