NAudio and DirectX 12

607 views Asked by At

I'm getting a DirectX sourced error when using NAudio. I'm not that knowledgeable when it comes to DirectX so would appreciate some pointers.

There error I am receiving when getting NAudio initialized on a windows 10 PC with DirectX 12 install is this:

NAudio.Dmo.DmoResampler..ctor System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {F447B69E-1884-4A7E-8055-346F74D6EDB3} failed due to the following error: 80040154 Class not registered (Exception from >HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

NAudio.Dmo.DmoResampler..ctor

NAudio.Wave.ResamplerDmoStream..ctor IWaveProvider inputProvider, WaveFormat outputFormat

NAudio.Wave.WasapiOut.Init IWaveProvider waveProvider

Sound.Support.AudioPlaybackEngine..ctor MMDevice device, Int32 sampleRate, Int32 channelCount

Sound.Manager.PerformInitialization

Analyze.ViewModels.ApplicationViewModel.InitSoundManager

Okay, it's pretty obvious some COM object isn't registered, so what to do?

Here's the code invoking NAudio:

    public AudioPlaybackEngine(MMDevice device, int sampleRate = 44100, int channelCount = 2)
    {
        Device = device;

        mOutputDevice = new WasapiOut(device,
                                      AudioClientShareMode.Shared,
                                      true,
                                      200);

        mMixer = new MixingSampleProvider(WaveFormat.CreateIeeeFloatWaveFormat(sampleRate, channelCount))
                {
                    ReadFully = true
                };

        mMixer.MixerInputEnded += OnMixerInputEnded;

        mOutputDevice.Init(mMixer);
        mOutputDevice.Play();
    }

The fault occurs on the first call.

This works just fine on DirectX 11, on any platform

Any thoughts?

1

There are 1 answers

1
Chuck Walbourn On BEST ANSWER

Windows 10 has DirectX 9.0c through DirectX 12 all side-by-side. This is probably better considered a Media Foundation question.

That GUID ({F447B69E-1884-4A7E-8055-346F74D6EDB3}) appears to be the Resampler DMO (DirectX Media Objects). DMOs were part of the legacy DirectShow technologies which are primarily used today by the Media Foundation APIs--I won't get into the tortured history of how "DirectShow" originally called "ActiveMovie" ended up being branded DirectX, but needless to say the technology was removed from the DirectX SDK back in 2005.

Therefore, my question would be: are you using a N or KN edition of Windows 10? If so, then it does not contain Media Foundation by default. You have to install it via a Restore Pack. See Who moved my Windows Media Cheese?.

You can try using this sample program to ensure the GUID is present on your machine.

If you are developing a Universal Windows Platform (UWP) app rather than classic Win32 desktop app, there might also be some restrictions on available transforms that could be impacting you.