Converting sampling rate for microphone input RRS feed

  • Question

  • I'm trying to record audio from the microphone in wave PCM format at 16bit, 16KHz . However using WASAPI for wave capture, it does not automatically convert the sampling rate of the audio, and continues to record at CD Quality. I remembered sampling rate conversion was really easy with legacy waveIn APIs, DirectSound, or DirectShow. 

    Then I attempted to use the Resampler MFT, but could not find a way to insert the MFT using Media Foundation or Windows.Media.Capture APIs. Windows Store app certification seems to block all necessary APIs like MFEnum.To use media extensions through ApplyAudioEffect, it's seems that I have to encode audio to Mp3/WMA first.

    Has someone figured this out? Is there a way for a Windows Store app to access the built in audio sampling rate converter?

    What about other custom audio dsps, what is the best way to implement them in a Windows Store app? I prefer to apply dsps to streaming audio.


    • Edited by Mallets Monday, April 15, 2013 6:16 PM
    Monday, April 15, 2013 6:10 PM


All replies

  • Hi Mallets,

    See James' comments on this topic in the Adaptive WASAPI capture buffer sampling and WinRT (ARM) considerations thread. There isn't a way to access built-in converter. The Media Engine has limited conversion capabilities (as it sounds like you've discovered) and he recommends doing the conversion on your own.


    • Marked as answer by Jesse Jiang Monday, April 22, 2013 3:02 AM
    Tuesday, April 16, 2013 1:31 AM
  • I found a way around this. With the audio captured from WASAPI, transfer it into XAudio audio graph with input format set to WASAPI's mixing format. Then, set the masteringvoice format to 16kHz or expected output format. Play the audio, and the output will be converted to expected sampling rate. I've created an XAPO inserted to the masteringvoice, to collect the converted audio. I did have to manually convert 32bit floats to 16bit pcm in the XAPO. The application can also mute the volume if the audio shouldn't be played.

    Not an ideal solution, but it's a workable solution for converting wav audio formats, when APIs are unavailable.

    Tuesday, May 14, 2013 9:44 PM