PDA

View Full Version : DirectShow Audio Renderer using Vista's WASAPI exclusive mode


mrcorbo
21st December 2008, 22:43
My apologies if this is the incorrect section for this.

Does anyone know where I might suggest this as a project for someone to take on?

-Some background:

Vista's new audio API allows for a mode of operation called "exclusive mode" that mutes all other audio sources and provides a path for audio data to pass "unmolested" (no resampling or mixing) to the audio device. Prior to Vista, this has been achieved using kernel streaming and ASIO output plugins for media playback applications. These are not always supported by PC audio devices, though. The advantage of WASAPI's exclusive mode is that any Vista audio driver should support this mode of operation.

-Why does this matter?

Primarily, because it has always been a desire for audio purists to have the source signal stay as pristine as possible in the playback process up to the final digital to analog conversion.

Secondarily, it also fixes a problem that effects those of us using HDMI audio devices to output multichannel PCM audio to an AV receiver/preamp. When operating in "shared mode" all audio is mixed and resampled into the default format. This means, though, that if Vista is set up to output 5.1 channels that stereo sources will be recognized by the receiver/preamp as 5.1 channels (the center/surrounds/sub will just be silent). This prevents use of the processing functions of the external device such as DPLII and DTS:Neo to turn the stereo source into surround.

Right now the media playback application with the best support for WASAPI exclusive mode output is Foobar 2000. I am able to play everything from 16bit/44kHz stereo mp3s to 24bit/96kHz 6-channel FLAC files and my receiver locks in at the source bitrate/number of channels. I can even playback DTS-encoded .wavs, the ultimate sign of bit-perfect playback. The limitation, of course, is that Foobar is audio only.

My hope is to be able to enjoy the benefits of bit-perfect audio output in any DirectShow media player.

Does anyone have a suggestion for a forum where I can propose this to those who may have the desire and knowledge to implement this? Thanks.

leeperry
22nd December 2008, 02:07
MC12 supports WASAPI :)

mrcorbo
22nd December 2008, 03:32
MC12 supports WASAPI :)

Do you mean J. River MC13 beta? It's got some bugs (limited to 16 bit, continually loops the last buffered audio samples on stoppage of playback) and it's WASAPI output is also limited to audio-only, even though the program will playback video via DirectShow.

leeperry
22nd December 2008, 11:18
Do you mean J. River MC13 beta? It's got some bugs (limited to 16 bit, continually loops the last buffered audio samples on stoppage of playback) and it's WASAPI output is also limited to audio-only, even though the program will playback video via DirectShow.
yup, apparently you need to select WASAPI for DS in the options ?

I gave up on Vista(I got some old MME drivers that bypass KMixer on XP), and I found the MC12 GUI butt-ugly :eek:

tetsuo55
22nd December 2008, 11:33
Awesome feature.

Every player should support this!

mrcorbo
24th December 2008, 05:10
yup, apparently you need to select WASAPI for DS in the options ?

You can't for video sources, though it's possible for audio files. When I made a request to add the ability to use the J River audio renderer for video files I was informed that they had looked into it a long time ago (I'm guessing for it's ability to output with ASIO) and that it wasn't possible. Possibly their audio renderer wasn't designed to accommodate synchronizing audio and video streams?

leeperry
24th December 2008, 10:16
oh ok, well some guy was talking about a DS>WASAPI wrapper built in MC12 on AVS, but I think he didn't really know what he was talking about.

well you also have the option to use Reclock in KS, so you get bitperfect audio in any app ;)

JohnnyMalaria
24th December 2008, 16:30
Any DirectShow application that relies on Windows to provide the audio renderer will default to the DirectSound renderer. Vista emulates DirectSound and this creates performance issues with certain (most) audio chipsets. DirectShow players have to either be (re)written to be Vista aware and/or permit the user to choose the audio renderer. Many don't.

It may be possible to change the merit value of the DirectSound renderer in the registry to force a different one to be selected by default but it's been a while since I had to cross that particularly frustrating bridge.

leeperry
24th December 2008, 17:27
DirectShow players have to either be (re)written to be Vista aware and/or permit the user to choose the audio renderer. Many don't.

It may be possible to change the merit value of the DirectSound renderer in the registry to force a different one to be selected by default but it's been a while since I had to cross that particularly frustrating bridge.
well you do get bitperfect audio with KS in Reclock on XP or Vista...besides most DS players let you choose the renderer so I'm not too sure what you are referring to ? WMP11 ?

mrcorbo
25th December 2008, 06:36
oh ok, well some guy was talking about a DS>WASAPI wrapper built in MC12 on AVS, but I think he didn't really know what he was talking about.

well you also have the option to use Reclock in KS, so you get bitperfect audio in any app ;)

You mean this thread:http://www.avsforum.com/avs-vb/showthread.php?t=1078264&highlight=

I'm pretty familiar with it, since I was the OP :)

I did know what I was talking about, the problem was you didn't know what I was talking about ;)

After I posted my update (that J River were saying that using their renderer with video sources wasn't possible) I stopped following the thread so I didn't see your post and wasn't able to clarify what I meant.

And unfortunately, KS doesn't work from ReClock for me on my hardware which brings me back to one of my original points about the advantages of exclusive mode - it should work on a lot more hardware.

leeperry
25th December 2008, 11:03
oh ok, coz this thread was pretty confusing :confused:

IMHO you'd be better off getting a soundcard that's compatible w/ KS Reclock or that has MME drivers that bypass KMixer....or better that has rewire in its drivers(AudioTrak/ESI have E-WDM drivers so you can route internally DS/MME to ASIO ;))

http://pix.nofrag.com/8/0/7/4e0f16cee95ec457ee7e6a71ed3c1.png

mrcorbo
2nd March 2009, 04:10
Turns out the the answer was Reclock. As of version 1.8.3.7 beta KS has been replaced (only for those using Vista SP1 and above, KS is still available for use with prior versions of Windows) by WASAPI+exclusive mode. As of the current version (1.8.3.9) this is working really well for me with a variety of files I have attempted to play back with varying audio characteristics (mono 16bit/32kHz to 24bit/6ch/96kHz and 24bit/stereo/192kHz). The output is modified in each case to match the source file with the exception that for compatibility reasons I have selected the option to always pad the bit-depth to 32bit-int.

nlnl
2nd March 2009, 08:30
Turns out the the answer was Reclock. As of version 1.8.3.7 beta KS has been replaced (only for those using Vista SP1 and above, KS is still available for use with prior versions of Windows) by WASAPI+exclusive mode. As of the current version (1.8.3.9) this is working really well for me with a variety of files I have attempted to play back with varying audio characteristics (mono 16bit/32kHz to 24bit/6ch/96kHz and 24bit/stereo/192kHz). The output is modified in each case to match the source file with the exception that for compatibility reasons I have selected the option to always pad the bit-depth to 32bit-int.
But ReClock resamples the audio stream playing movies :(
Is there any way to stop Reclock resample audio and get bit exact audio in WASAPI mode?

mrcorbo
3rd March 2009, 00:26
But ReClock resamples the audio stream playing movies :(
Is there any way to stop Reclock resample audio and get bit exact audio in WASAPI mode?

If you check "Slave reference clock to audio" and set Media adaptation to "Original speed" it should prevent Reclock from resampling. I can't think of a way to confirm this, though. What I can confirm is that when playing back a DTS encoded wav file using the Reclock renderer my receiver indicates DTS and the sound plays back properly. So Reclock is capable of outputting bit-perfect audio.

rica
3rd March 2009, 00:56
If you check "Slave reference clock to audio" and set Media adaptation to "Original speed" it should prevent Reclock from resampling...
So Reclock is capable of outputting bit-perfect audio.

Agreed.
Even "slave ref..." isn't selected, ReClock just adjusts the audio clock which means +/- 5-10 Hz; to me resampling means downsampling or upsampling, not to adjust the clock.
You will get the same bitdepth of your audio file via bypassing VistaMixer.
This means "bitperfect" into my understanding. :)

This evening i returned back to TMT .121, removed CheckUpdate.dll and checkupdate.set and rica is very happy with the latest ReClock.

Kado
3rd March 2009, 03:20
@rica
Any adjustment will not give an exact copy of the audio stream, i.e., not "bitperfect".
I remember some audio amplifiers having the "direct source" option that bypasses the equalizer or other audio processing features in the amplifier.

rica
3rd March 2009, 03:26
@rica
Any adjustment will not give an exact copy of the audio stream, i.e., not "bitperfect".
I remember some audio amplifiers having the "direct source" option that bypasses the equalizer or other audio processing features in the amplifier.

I say this is possible if you get a real bitperfect audio and send it to an ampli not to a receiver. (except over SPDIF or HDMI)
Anyway here is the rest of the discussion:
http://forum.slysoft.com/showthread.php?p=179683#post179683

yesgrey
6th March 2009, 10:53
If you check "Slave reference clock to audio" and set Media adaptation to "Original speed" it should prevent Reclock from resampling.
Yes, if you configure reclock that way you get exactly the original sound. When configured like that, the words "bit exact" appear in reclock's dialog.
Is there any way to stop Reclock resample audio and get bit exact audio in WASAPI mode?
The above do what you want, but there is another way...
If you have a soundcard that allows setting the soundcard's clock frequency to whichever value you want (like RME and Lynx), you can use that to pitch correct your movie's audio without any resampling.:)
I have posted instructions about that in reclock's forum.;)

leeperry
6th March 2009, 12:48
If you have a soundcard that allows setting the soundcard's clock frequency to whichever value you want (like RME and Lynx)
I believe noone does, except you and some guys on HCFR.

anyway, ppl keep complaining that Reclock resamples.....yet they watch movies in DS where KMixer butchers their audio anyway :D

if you're not willing to spend $1000 on a soundcard, Reclock in excellent mode w/ a bitperfect renderer sounds pretty fine to me :o

plus as you said, the brain is too busy analyzing the video when watching a movie to really care about the sound degradation....which is way lower than w/ 1.7b4 IMVHO, this one was really lousy ;)

Beliyaal
6th March 2009, 20:14
I'm now able to get bit perfect audio with the newest beta of Reclock and wasapi. The problem that might not be apparent is that it will drop/repeat frames when it's passing through DTS and AC3 even when it reports bit-perfect. That can be fixed by telling SPDIFer to output in "PCM" instead. That this works is a clear indication that I'm having bit-perfect passthrough of PCM! The sligtest resampling would destroy the DTS and AC3 signal in PCM output mode.

Slave reference clock must be selected of course.

nand chan
17th September 2011, 15:20
Going to bump this instead of opening a new thread. Does anybody know what could be causing this?

http://img831.imageshack.us/img831/7825/reclockwasapifail.png

I am streaming PCM through S/PDIF (I have ReClock's video detection, frame rate adjustment, resampling etc. features all completely disabled) to my DAC.

My DAC supports up to 96 kHz / 24 bit.

I created a 48 kHz / 24 bit / 2 channel test file and attempted to play it back using foobar2000 in WASAPI exclusive mode, and it works fine - so that can't be the issue, it must be an issue with ReClock specifically.

nevcairiel
17th September 2011, 16:24
You probably want to configure ReClock to output 24bit padded to 32, alot of devices actually don't support "raw" 24 bit, they need the 4 byte container for alignment purposes.
If you want audio "untouched" by ReClock, i recommend setting the format to 24 bit padded to 32, and checking the 16 bit for 16 bit sources checkbox.

nand chan
17th September 2011, 16:29
You probably want to configure ReClock to output 24bit padded to 32, alot of devices actually don't support "raw" 24 bit, they need the 4 byte container for alignment purposes.
If you want audio "untouched" by ReClock, i recommend setting the format to 24 bit padded to 32, and checking the 16 bit for 16 bit sources checkbox.

Thanks, this worked perfectly - didn't realize my DAC requires it to be padded to 32 bit. (It works fine in foobar2000 when set to “24 bit” so I thought that was actual 24 bit)

/me thinks it's time to write up a ReClock guide.

nevcairiel
17th September 2011, 16:30
foobar probably does that by default when it sees that the driver only exposes 32-bit instead.

nand chan
17th September 2011, 17:31
/me thinks it's time to write up a ReClock guide.

Made this for now (http://img683.imageshack.us/img683/8949/reclockguide.png), did I miss anything?

Thunderbolt8
17th September 2011, 17:44
checking the 16 bit for 16 bit sources checkbox.is that actually necessary when your DAC supports >16-bit ? afaik zero bits are added in case of 16-bit input, wouldnt this then still be considered lossless?

Qaq
17th September 2011, 17:46
I'd say it depends on what you prefer - pretty smooth video playback or "bit exact" sign in ReClock's window.;)

nand chan
17th September 2011, 17:49
I'd say it depends on what you prefer - pretty smooth video playback or "bit exact" sign in ReClock's window.;)

Even with the “clock correction” features of ReClock the judder was just as awful as before, if not even worse. I don't see a point in using it.

And vsync is handled fine by Aero and/or madVR - no need for ReClock interfering.

Qaq
17th September 2011, 17:49
Sure your audio driver does not convert DWORD > WORD?

Thunderbolt8
17th September 2011, 17:50
Made this for now (http://img683.imageshack.us/img683/8949/reclockguide.png), did I miss anything?what I did is to add the registry key 'bypassresampler' (dword = 1) so that all resampling automatically gets disabled and to be really sure that the audio does not get modified by reclock.

also ticked force reclock to be loaded instead of default renderer and only load in application mpc-hc & always load.

I'd say it depends on what you prefer - pretty smooth video playback or "bit exact" sign in ReClock's window.;)just for bit exact output, afaik its supposed to be the same with zero bytes for 16-bit input -> 24-bit DAC. the sound is supposed to be untouched then.

Qaq
17th September 2011, 17:55
Even with the “clock correction” features of ReClock the judder was just as awful as before, if not even worse. I don't see a point in using it.
Well, I'm under XP ATM using JanWillem's EVR CP with ATI 5450 and I'd say ReClock helps me to avoid judder a bit. Also works fine with madVR.

nand chan
17th September 2011, 18:02
Sure your audio driver does not convert DWORD > WORD?

I'm not actually sure - the sound chip is an ALC888 and I'm running the stock Realtek HD drivers. It shows 16 bit and 24 bit as compatible formats, though - so I'm going to guess that it doesn't convert it back down to 16-bit.

what I did is to add the registry key 'bypassresampler' (dword = 1) so that all resampling automatically gets disabled and to be really sure that the audio does not get modified by reclock.

Alright. I've exported a .reg file for it. (http://www.mediafire.com/?hjxwiw2vg8u5syp)

also ticked force reclock to be loaded instead of default renderer and only load in application mpc-hc & always load.

I figured it's unnecessary to make ReClock load itself if it's just for one application, so I just disabled it and set it as the actual playback device in MPC-HC.

Qaq
17th September 2011, 18:11
I'm not actually sure - the sound chip is an ALC888 and I'm running the stock Realtek HD drivers.
With coaxial it shold be able to connect on 192kHz. I mean bitrate will be really huge for 2x192/32.

nand chan
17th September 2011, 18:12
With coaxial it shold be able to connect on 192kHz. I mean bitrate will be really huge for 2x192/32.

I can output 192/24 but my DAC doesn't support it, so I get glitches during playback. 96/24 works fine.