Download

Help incorporating the ASIO SDK into RtAudio as a Plugin - Unable to compile ASIO

Hey there community! Hope everyone is keeping well.

I’ve been attempting to get ASIO compiled into the engine using RtAudio. I’ve based a lot of my solution off the already implemented AudioCapture plugin. I essentially ported all the relevant Windows stuff and left out the other backend factory that produces audio capture implementations for other Platforms. My port works fine with Direct Sound and also works with WASAPI (although a bit clicky). I’m now wanting to get ASIO incorporated because it provides me with multichannel input from my soundcard which I’d really like have because it allows me to loopback multichannel. I’m hoping that I can just grab hold of the multichannel buffer and then choose a specific channel from it to feed a synth component.

I’m using Visual Studio 2019 with the 2017 build tools. Nothing strange here from what I can see.

I’ve gone ahead and compiled theRtAudio examples with ASIO - this is all working fine aswell, no problems.

Now, when I try to compile the ASIO third party headers + source into UE4, I’m hit with this error to do with a file in the Windows kits headers that I can’t quite figure and the Build.bat/Rebuild.bat returns with a code -1 and no more information. I’ve tried running Visual Studio as admin and still get the same errors. Not sure this would be the issue as I’ve had it crop up before in other projects, but it was actually something in my code.

In order to get to this point I’ve gone through the including Third Party documentation on the UE site. → https://docs.unrealengine.com/en-US/…ies/index.html

I’ve done the following things to get to this point:

  • I’ve replaced all the occurrences of #include <windows.h> with #include “Windows/WindowsHWrapper.h”.
  • I’ve wrapped references to the Windows macros TRUE or FALSE with #include “Windows/AllowWindowsPlatformTypes.h” and #include “Windows/HideWindowsPlatformTypes.h”
  • I’ve wrapped THIRD_PARTY_INCLUDES_START and THIRD_PARTY_INCLUDES_END around other third party includes (like <string.h>)
  • I’ve replaced references to WIN32 with PLATFORM_WINDOWS (not sure this is necessary though - doesn’t seem to change much)
  • To stop the compiler throwing errors about macros being undefined I removed the #undef macros for MAC, SGI, BEOS in g_include.h
  • In order to use a standard C++ forward defined interface for IASIO used in iasiodrv.h, I was required to add an include an <objbase.h> header from the windows kit.

Here is my compiler output:



1>------ Rebuild All started: Project: PluginMaker, Configuration: Development_Editor x64 ------
1>Cleaning PluginMakerEditor and UnrealHeaderTool binaries...
1>Creating makefile for PluginMakerEditor (no existing makefile)
1>Parsing headers for PluginMakerEditor
1>  Running UnrealHeaderTool "D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\PluginMaker.uproject" "D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Intermediate\Build\Win64\PluginMakerEditor\Development\PluginMakerEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
1>Reflection code generated for PluginMakerEditor in 5,7706694 seconds
1>Building PluginMakerEditor...
1>Using Visual Studio 2019 14.25.28614 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610) and Windows 10.0.18362.0 SDK (C:\Program Files (x86)\Windows Kits\10).
1>Building 25 actions with 16 processes...
1>  [1/25] Default.rc2
1>  [2/25] Default.rc2
1>  [3/25] SharedPCH.Engine.ShadowErrors.cpp
1>  [4/25] asiolist.cpp
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\rpc.h(135): fatal error C1083: Cannot open include file: 'rpcerr.h': No such file or directory
1>  [5/25] ConfigurableAudioCapComponent.cpp
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\rpc.h(135): fatal error C1083: Cannot open include file: 'rpcerr.h': No such file or directory
1>  [6/25] asiodrivers.cpp
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\rpc.h(135): fatal error C1083: Cannot open include file: 'rpcerr.h': No such file or directory
1>  [7/25] asio.cpp
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\rpc.h(135): fatal error C1083: Cannot open include file: 'rpcerr.h': No such file or directory
1>  [8/25] PluginMaker.init.gen.cpp
1>  [9/25] ConfigurableAudioCap.cpp
1>  [10/25] PluginMakerGameModeBase.cpp
1>  [11/25] ConfigurableAudioCapture.init.gen.cpp
1>  [12/25] PluginMaker.cpp
1>  [13/25] iasiothiscallresolver.cpp
1>  [14/25] ConfigurableAudioCapture.cpp
1>  [15/25] ConfigurableAudioCapComponent.gen.cpp
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\rpc.h(135): fatal error C1083: Cannot open include file: 'rpcerr.h': No such file or directory
1>  [16/25] PluginMakerGameModeBase.gen.cpp
1>  [17/25] ConfigurableAudioCap.gen.cpp
1>  [18/25] TestBlueprintFunctionLibrary.gen.cpp
1>  [19/25] TestBlueprintFunctionLibrary.cpp
1>  [20/25] UE4Editor-PluginMaker.lib
1>     Creating library D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Intermediate\Build\Win64\UE4Editor\Development\PluginMaker\UE4Editor-PluginMaker.lib and object D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Intermediate\Build\Win64\UE4Editor\Development\PluginMaker\UE4Editor-PluginMaker.exp
1>  [21/25] UE4Editor-PluginMaker.dll
1>     Creating library D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Intermediate\Build\Win64\UE4Editor\Development\PluginMaker\UE4Editor-PluginMaker.suppressed.lib and object D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Intermediate\Build\Win64\UE4Editor\Development\PluginMaker\UE4Editor-PluginMaker.suppressed.exp
1>  [22/25] RtAudio.cpp
1>C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\rpc.h(135): fatal error C1083: Cannot open include file: 'rpcerr.h': No such file or directory
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(49,5): error MSB3073: The command ""C:\Program Files\Epic Games\UE_4.24\Engine\Build\BatchFiles\Rebuild.bat" PluginMakerEditor Win64 Development -Project="D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\PluginMaker.uproject" -WaitMutex -FromMsBuild" exited with code -1.
1>Done building project "PluginMaker.vcxproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========


My Module build code is the following:



// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;

public class ConfigurableAudioCapture : ModuleRules
{
    public ConfigurableAudioCapture(ReadOnlyTargetRules Target) : base(Target)
    {
        PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
        bEnforceIWYU = false;

        PublicDependencyModuleNames.AddRange(
            new string] {
                    "Core",
                    "CoreUObject",
                    "Engine",
                    "AudioMixer",
                    "SignalProcessing"
            }
        );

        PublicIncludePaths.AddRange(new string] { "ConfigurableAudioCapture/Public" });
        PrivateIncludePaths.AddRange(new string] { "ConfigurableAudioCapture/Private", "ConfigurableAudioCapture/ThirdParty" });

        if (Target.Platform == UnrealTargetPlatform.Win32 ||
            Target.Platform == UnrealTargetPlatform.Win64)
        {
            PublicDefinitions.Add("WITH_RTAUDIO=1");
            PublicDefinitions.Add("WITH_CONFIGURABLEAUDIOCAPTURE=1");

            // Allow us to use direct sound
            AddEngineThirdPartyPrivateStaticDependencies(Target, "DirectSound");
        }
        else
        {
            // Not supported on this platform
            //PublicDefinitions.Add("WITH_CONFIGURABLEAUDIOCAPTURE=0");
        }
    }
}


If anyone has any bright ideas about this compiler error I’d be super appreciative! Maybe you could point me in the right direction, it feels like it’s getting close to being able to compile!

Ok, so some developments. Turns out the ASIO library uses a macro called “MAC” that causes errors with the Windows rpc library. After undefining it (as they do in the original ASIO g_include.h, I no longer get the rpcerr.h not found problem. However, now I run into some very cryptic build errors with not much info giving on how to get around it. Also, it seems the compiler is now giving me errors about the macros not being defined, although I don’t think this is much of a problem.



1>Parsing headers for PluginMakerEditor
1>  Running UnrealHeaderTool "D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\PluginMaker.uproject" "D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Intermediate\Build\Win64\PluginMakerEditor\Development\PluginMakerEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
1>Reflection code generated for PluginMakerEditor in 6,2246462 seconds
1>Building PluginMakerEditor...
1>Using Visual Studio 2019 14.25.28614 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610) and Windows 10.0.18362.0 SDK (C:\Program Files (x86)\Windows Kits\10).
1>Building 25 actions with 16 processes...
1>  [1/25] Default.rc2
1>  [2/25] Default.rc2
1>  [3/25] SharedPCH.Engine.ShadowErrors.cpp
1>  [4/25] iasiothiscallresolver.cpp
1>  [5/25] PluginMaker.cpp
1>  [6/25] ConfigurableAudioCapture.cpp
1>  [7/25] PluginMaker.init.gen.cpp
1>  [8/25] ConfigurableAudioCapture.init.gen.cpp
1>  [9/25] ConfigurableAudioCap.cpp
1>  [10/25] TestBlueprintFunctionLibrary.gen.cpp
1>  [11/25] asiodrivers.cpp
1>D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Source\ConfigurableAudioCapture\ThirdParty\ginclude.h(4): error C4668: 'SGI' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
1>D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Source\ConfigurableAudioCapture\ThirdParty\asiodrivers.h(6): error C4668: 'MAC' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
1>D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Source\ConfigurableAudioCapture\ThirdParty\asiodrivers.cpp(21): error C4668: 'MAC' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
1>  [12/25] asio.cpp
1>D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Source\ConfigurableAudioCapture\ThirdParty\asio.cpp(17): error C4668: 'MAC' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
1>D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Source\ConfigurableAudioCapture\ThirdParty\asiodrivers.h(6): error C4668: 'MAC' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
1>D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Source\ConfigurableAudioCapture\ThirdParty\asio.cpp(52): error C4668: 'MAC' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
1>D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Source\ConfigurableAudioCapture\ThirdParty\asio.cpp(52): error C4668: 'SGI' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
1>D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Source\ConfigurableAudioCapture\ThirdParty\asio.cpp(52): error C4668: 'BEOS' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
1>D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Source\ConfigurableAudioCapture\ThirdParty\asio.cpp(81): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Source\ConfigurableAudioCapture\ThirdParty\asio.cpp(91): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Source\ConfigurableAudioCapture\ThirdParty\asio.cpp(210): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Source\ConfigurableAudioCapture\ThirdParty\asio.cpp(257): error C4668: 'MAC' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
1>  [13/25] PluginMakerGameModeBase.cpp
1>  [14/25] asiolist.cpp
1>D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Source\ConfigurableAudioCapture\ThirdParty\asiolist.cpp(128): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Source\ConfigurableAudioCapture\ThirdParty\asiolist.cpp(130): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Source\ConfigurableAudioCapture\ThirdParty\asiolist.cpp(277): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Source\ConfigurableAudioCapture\ThirdParty\asiolist.cpp(299): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>  [15/25] ConfigurableAudioCap.gen.cpp
1>  [16/25] PluginMakerGameModeBase.gen.cpp
1>  [17/25] TestBlueprintFunctionLibrary.cpp
1>  [18/25] UE4Editor-PluginMaker.lib
1>     Creating library D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Intermediate\Build\Win64\UE4Editor\Development\PluginMaker\UE4Editor-PluginMaker.lib and object D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Intermediate\Build\Win64\UE4Editor\Development\PluginMaker\UE4Editor-PluginMaker.exp
1>  [19/25] UE4Editor-PluginMaker.dll
1>     Creating library D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Intermediate\Build\Win64\UE4Editor\Development\PluginMaker\UE4Editor-PluginMaker.suppressed.lib and object D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Intermediate\Build\Win64\UE4Editor\Development\PluginMaker\UE4Editor-PluginMaker.suppressed.exp
1>  [20/25] RtAudio.cpp
1>D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\Source\ConfigurableAudioCapture\ThirdParty\asiodrivers.h(6): error C4668: 'MAC' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
1>  [21/25] ConfigurableAudioCapComponent.gen.cpp
1>  [22/25] ConfigurableAudioCapComponent.cpp
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(44,5): error MSB3075: The command ""C:\Program Files\Epic Games\UE_4.24\Engine\Build\BatchFiles\Build.bat" PluginMakerEditor Win64 Development -Project="D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\PluginMaker.uproject" -WaitMutex -FromMsBuild" exited with code 5. Please verify that you have sufficient rights to run this command.
1>Done building project "PluginMaker.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


I’ve regenerated the project multiple times, and also deleted the .vs, Intermediate and Binaries folder manually before regenerating. Still nothing seems to help. Seems the main issue is the last line there where it exits with Code 5 and says I don’t have sufficient rights to run a command? This same command has also ended up with an error code -1 a few times before.



1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(44,5): error MSB3075: The command ""C:\Program Files\Epic Games\UE_4.24\Engine\Build\BatchFiles\Build.bat" PluginMakerEditor Win64 Development -Project="D:\Unreal Projects\ConfigurableAudioCapturePlugin\PluginMaker\PluginMaker.uproject" -WaitMutex -FromMsBuild" exited with code 5. Please verify that you have sufficient rights to run this command.


Alright, so great news! Finally got this thing to compile :slight_smile:

Turns out those preprocessor macro warnings were causing a problem… I went through all the code and simply removed all the references to those macros which aren’t needed in my case. As far as I know, ASIO is only really implemented in Windows, so need for branching cases for MAC/SGI/BEOS etc…

Shyoh, very happy here! Now onto the real work and getting ASIO into this system! Wish me luck!

How did you end up going with this? I figured this was my best bet for low latency mic input. Though, after finding this thread, it looks like a bit of a mission haha.
I just thought I’d see how you went before starting to follow your (already very helpful) problem solving steps.

I’d also LOVE to see how you did this! Are you planning to release the plugin on the marketplace/post to GitHub? Amazing work!

Echo this post.

Hey everyone,

Super sorry, didn’t see these notifications till now. Great to hear you are all so excited. and see the same value in this as I do! I did manage to get it working :slight_smile:
https://forums.unrealengine.com/core/image/gif;base64
​ I’ve been successfully porting 32 channels of audio (although there is support for more) from my ASIO devices into the engine.

Planning to release a more formal version of this plugin in the next couple months. Please DM me if you’d like to chat more!

Indeed, it was a bit of a mission, but not too difficult after getting RTAudio to compile. I think there are a variety of ways to implement it depending on your needs. ASIO does give lower latency but you’ll always be at the mercy of the game engine audio buffer since it all gets buffered through there. Try checking your Engine Audio settings and mess with the buffer size, smaller is generally better :slight_smile:

I’d really love to see this plugin out :smiley:

Me also :slight_smile: