[wdmaudiodev] Race to set record sampling rate on KMixer / KS pin / soundcard

  • From: Evan Lerch <mievlecl@xxxxxxxxx>
  • To: wdmaudiodev@xxxxxxxxxxxxx
  • Date: Wed, 3 Mar 2010 11:48:45 -0700

Hi all,

I am faced with a situation where my users must use two independent software
applications throughout the day: the first application (a phone) records
audio at 8kHz and the second application (an automatic transcriber) records
audio at 16kHz.  I am an engineer responsible for working on the transcriber
application.

My problem is that if my users launch the phone first, Windows initializes
the sound system to a sampling rate of 8kHz.  When the users subsequently
launch the transcriber, the transcriber requests 16kHz audio from the sound
system.  The sound system provides a 16kHz audio stream, but it is really
8kHz audio resampled by KMixer to 16kHz.  This results in an unacceptable
loss of audio quality.

I need to find a way to programmatically detect this situation.  Upon
detection I would warn the user and provide problem resolution
instructions.  Something like "please launch transcriber first, phone
second."

My question is: can you think of a way to programmatically detect
this situation?  My first thought was to run FFT analysis on the
recorded audio and look for relatively low amplitude in the 4kHz+ range.
However, this approach isn't very deterministic, and the heuristics would be
tricky to implement.

What I'd really like is some way to query the Windows audio subsystem to try
and determine definitively what's going on.  So I started learning about the
Windows audio subsystems.  I gave up pretty quickly on waveIn, waveOut and
DirectSound: they are too high level and don't know about what KMixer and KS
are doing behind the scenes.  I looked into KMixer a bit, but it has no
documented APIs.

I then started looking into Kernel Streaming (KS), which has a huge API.  I
started modifying the DirectKS example application to query filters and
their pins for information.  I tried many approaches to querying the exposed
KS filters and pins, with no luck.  The KS APIs just seem like they aren't
designed to help an external observer query for detailed status information;
they're more designed around a participant in the system.  For example
retrieving certain pin properties requires a handle to the pin, and there is
no way to get a list of instantiated pin handles.  The information that can
be retrieved without pin handles seems unhelpful: the format intersection
information doesn't seem to change based on the pin's state.  Some devices
update their pin's GLOBALCINSTANCES property, but others don't.
KSPROPERTY_CONNECTION_DATAFORMAT seems like it can only be set, not
retrieved.

I'm not very hopeful about finding an elegant solution to detecting this
situation.  But, I've seen that there are a lot of knowledgeable people here
and I thought it might be worth a query.  It seems like the problem might be
relevant to others as well, since the problem can exhibit with any two
programs which want to record at different sampling rates.

thanks!

Other related posts: