Search code examples
c++-winrt

winrt::hresult_class_not_registered - AudioEffectDefinition with custom effect


I'm trying to create a winrt custom audio effect using this tutorial.

#include "MyAudioEffect.g.h"

auto effectName = winrt::name_of<winrt::MRE_ClassNotRegistered::MyAudioEffect>();
auto effect = winrt::Windows::Media::Effects::AudioEffectDefinition(effectName);
// Exception thrown
// winrt::hresult_class_not_registered 
// 80040154 - Class not registered

I made a MRE: https://github.com/tom-huntington/MRE_ClassNotRegistered

To create the .idl .h .cpp files for the MyAudioEffect class, I used the template

-> Add -> New Item -> Custom Control (WinUI 3)

How do I register the class? Can someone fix my MRE please?


Solution

  • Apparently, I need to create a separate project for the audio effect https://learn.microsoft.com/en-us/windows/uwp/audio-video-camera/custom-audio-effects

    Add a custom effect to your app

    A custom audio effect is defined in a class that implements the IBasicAudioEffect interface. This class can't be included directly in your app's project. Instead, you must use a Windows Runtime component to host your audio effect class.

    Add a Windows Runtime component for your audio effect:

    • In Microsoft Visual Studio, with your solution open, go to the File menu and select Add->New Project.
    • Select the Windows Runtime Component (Universal Windows) project type.