wasapi

WASAPI: Play sine wave sound in minimum latency without glitches (exclusive-event driven mode)

穿精又带淫゛_ 提交于 2021-02-18 03:26:47
问题 I'm trying to play a simple sineous waveform using the Windows Audio Session API (WASAPI) in exclusive mode, but encountering sound glitches no matter what I do. I've been using the MSDN Exclusive-Mode Streams example as a reference point, and here's how the slightly adapted code currently looks like. Setup code: -- <variable declarations, incl. "HRESULT hr; BYTE *pData;" > -- // also, hr is checked for errors every step of the way hr = CoCreateInstance( CLSID_MMDeviceEnumerator, NULL, CLSCTX

Efficient sampling of audio render client position

扶醉桌前 提交于 2021-02-11 15:44:50
问题 I want to efficiently monitor audio playback position. I understand I can use IAudioClock::GetPosition() and that this is a blocking call that can fail, and should not be called from a thread that is decoding or resampling the audio stream. So I set a waitable timer object with a dedicated thread blocked on it, that then calls IAudioClock::GetPosition() and invokes a callback function to process that. There is the concern of the effect on low power state if the timers frequency is too high,

Efficient sampling of audio render client position

99封情书 提交于 2021-02-11 15:44:45
问题 I want to efficiently monitor audio playback position. I understand I can use IAudioClock::GetPosition() and that this is a blocking call that can fail, and should not be called from a thread that is decoding or resampling the audio stream. So I set a waitable timer object with a dedicated thread blocked on it, that then calls IAudioClock::GetPosition() and invokes a callback function to process that. There is the concern of the effect on low power state if the timers frequency is too high,

IMFTransform SetInputType()/SetOutputType() fails

一曲冷凌霜 提交于 2020-12-14 06:33:13
问题 I'm trying to playback MP3 (and similar audio files) using WASAPI shared mode and a media foundation IMFSourceReader on Windows 7. From what I understand I have to use an IMFTransform between the IMFSourceReader decoding and the WASAPI playback. Everything seems fine apart from when I call SetInputType()/SetOutputType() on the IMFTransform? The relevant snippets of code are: MFCreateSourceReaderFromURL(...); // Various test mp3 files ... sourceReader->GetCurrentMediaType(MF_SOURCE_READER

IMFTransform SetInputType()/SetOutputType() fails

假装没事ソ 提交于 2020-12-14 06:23:22
问题 I'm trying to playback MP3 (and similar audio files) using WASAPI shared mode and a media foundation IMFSourceReader on Windows 7. From what I understand I have to use an IMFTransform between the IMFSourceReader decoding and the WASAPI playback. Everything seems fine apart from when I call SetInputType()/SetOutputType() on the IMFTransform? The relevant snippets of code are: MFCreateSourceReaderFromURL(...); // Various test mp3 files ... sourceReader->GetCurrentMediaType(MF_SOURCE_READER

Capture audio from WasapiLoopbackCapture, and convert to muLaw

喜夏-厌秋 提交于 2020-02-01 07:59:13
问题 I'm capturing audio with WasapiLoopbackCapture - format = IeeeFloat - SampleRate = 48000 - BitsPerSample = 32 I need to convert this to muLaw (8Khz, 8 bit, mono) - eventually it'll be sent to a phone via SIP trunking. I've tried 100s of samples (most of them with NAudio) and solutions but still have no clue how to do this ... 回答1: The Mu-Law tools in NAudio are limited so you might have to roll your own. You'll need to set up a chain of IWaveProvider filters to convert to mono, change bit

handling specific applications volume-level

夙愿已清 提交于 2019-12-25 07:20:11
问题 Using WASAPI, I could control system volume. I wonder, I can control the specific application's volume level programmatically. (of course, this is after windows7 only) is it possible? 回答1: You can control application (session) volume, just like standard Volume Mixer does it. Read up on this in Session Volume Controls where it is explained pretty detailed: WASAPI clients can individually control the volume level of each audio session. [...] To support this behavior, WASAPI implements the

WASAPI: Identify non-active channels on loopback recording

假装没事ソ 提交于 2019-12-23 02:48:14
问题 I have a DSP software which captures the audio playing using the WASAPI api in shared loopback mode. hr = _pAudioClient->Initialize(AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_LOOPBACK, 0, 0, _pFormat, 0); This part works fine, but now I want to be able to detect the number of channels actually playing. In other words how would I be able to detect if the audio playing is in stereo, 5.1, 7.1? The problem is: * Since loopback have to use shared mode there could be multiple sources playing. *

WASAPI Resampling / Windows Media Foundation

…衆ロ難τιáo~ 提交于 2019-12-22 10:37:57
问题 I'm writing a Pro Audio application using WASAPI. This application runs a stream in exclusive mode, and resamples the audio data to and from a constant format in both directions (one resample between the capture device and the app, and another between the app and the output device). There's a page on MSDN about an Audio Resampler DSP here, but I'm not sure if this is the API I want to use. The reason I'm not sure about it is the way the API is designed. Using IMFTransform, I need a bunch of

Captured audio buffers are all silent on Windows Phone 8

我的梦境 提交于 2019-12-14 03:52:58
问题 I'm trying to capture audio using WASAPI. My code is largely based on the ChatterBox VoIP sample app. I'm getting audio buffers, but they are all silent (flagged AUDCLNT_BUFFERFLAGS_SILENT). I'm using Visual Studio Express 2012 for Windows Phone. Running on the emulator. 回答1: I had the exact same problem and managed to reproduce it in the ChatterBox sample app if I set Visual Studio to native debugging and at any point stepped through the code. Also, closing the App without going through the