2

I use RTAudio to get a signal from Microphone and use this signal as the input for another encoder. It seems UWP always return fixed audio sample rate which different from sample rate my encoder wants.

WASAPICapture return 44100 Hz signal, 2 channel(input). I want to convert this input to 1600 Hz signal, 1 channel (output). How do I make the resample correctly?

Data I received from WASAPICapture’s callback. This callback is called every 64 ms, and each time it gave me 480 samples. My Encoder required 320 sample every 20 ms. What should I do to get this (re-frame)?

Could you suggest me any library to do this? or should I write the code myself?

Lahiru Jayaratne
  • 1,684
  • 4
  • 31
  • 35

2 Answers2

0

I want to convert this input to 1600 Hz signal, 1 channel (output). How do I make the resample correctly

Ref here

WASAPI is locked to the sample rate of the audio engine (determined at startup) and cannot be changed within the WinRT environment. You will need to write your own sample rate converter to go from the sample rate of the media engine to your targeted output sample rate.

For example, NAudio has a WASAPI wrapper, some cases talk about this: change wav file ( to 16KHz and 8bit ) with using NAudio

Community
  • 1
  • 1
Franklin Chen - MSFT
  • 4,845
  • 2
  • 17
  • 28
0

As of RtAudio PR 119, the library now supports sample rate changes for WASAPI.

This PR was merged into master on 16 Oct 2018 but, at the time of writing, is not part of an official release.

From the PR:

As WASAPI itself does not provide support for sample rates other than the current system default, I've introduced the Microsoft MFT (Media Foundation Transform) library into RtApiWasapi in order to allow users to specify the sample rate they wish to use.

Paul Masri-Stone
  • 2,843
  • 3
  • 29
  • 51