[Stk] STK dll for Unreal Engine - threading quesiton

Gary Scavone gary at ccrma.Stanford.EDU
Tue Sep 10 05:47:49 PDT 2019


Hi Rob,

Sounds interesting! I have no experience with the Unreal Engine but I would expect that it would handle the interface with the audio and control hardware(?). In that case, you would want to remove any STK classes from your DLL that do similar things (RtAudio, RtMidi, various socket classes, Messager, … anything that might involve threading or a mutex for sure). Then the STK DLL would either take a buffer of data to process / filter (such as the Effects classes) or simply generate a buffer of data (synthesis classes) based on some control messages that you send it.

I’m probably over-simplifying the situation but I don’t see why an STK process running in a separate thread would lock Unreal unless you had some class that was blocking, waiting for input.

Regards,

—gary

> On Sep 6, 2019, at 11:22 PM, rob at ccrma.stanford.edu wrote:
> 
> Hi all,
> 
> In a similar thread to the STK => C# posts from July, I'm rolling a Windows STK dll for use in the Unreal Engine. My C++ is rusty these days but I've got it started. Any suggestions from the STK brain-trust would be great.
> 
> So far I've made a simple STK Windows dll and a small test console app that will run it. Works. Can compile in Visual Studio, 64bit, Asio.
> 
> My main question is how should I be approaching threading with STK as a dll and passing in control data for this kind of project? I don't think I've got it right in my head quite yet. I shouldn't be thinking about using SKINI or passing messages in over ports right? I'm generating all the control data I need in Unreal and should just be passing that in directly through noteOn/Off functions with frequency, bowPressure and amplitude as my data?
> 
> For example, in my test app, I include my dll and call my "initSTK" function, which is just a tweaked version of one of the STK example scripts, on a separate thread like:
> 
>   std::thread initThread(initSTK);
> 
> That function just instantiates an array of four Bowed strings using the Voicer, opens and starts my audio stream.
> 
> Then I have simple noteOn() noteOff() functions which take frequency, string number(1-4) and amplitude as parameters. Works in my test app, like a terrible C++Sound.
> 
> Within Unreal, I wrote an interface for my dll and can load it successfully (meaning the Unreal project will compile and sees the DLL). However as expected, when I try to call my init function (without any special threading) it locks up Unreal.
> 
> Before I start down the path of how to properly implement multi-threaded audio processes in dll's within Unreal Engine does this seem like the right way I should be approaching this? Is there a way within my STK dll to call that init function in a separate thread or do I need some kind of call-back here looking for my control data? I haven't built anything worthwhile in C++ in a while now.
> 
> thanks all, any thoughts would be super helpful.
> 
> Go Cardinal!
> 
> rob
> 
> 
> 
> _______________________________________________
> Stk mailing list
> Stk at ccrma.stanford.edu
> https://cm-mail.stanford.edu/mailman/listinfo/stk
> 




More information about the Stk mailing list