What engine version are you on? There is a lot of work I’ve done coming out in 5.1 to make managing Quartz from C++ a bit easier.
Can you tell where you are crashing with a debugger attached? Something inside of the UClockHandle::SetBeatsPerMinute()
function is null. With a debugger attached, you could see what it invalid.
Might be worth to mention that I’m still fairly new to C++.
If you aren’t running with a debugger attached, this is the first thing I’d figure out. It will make life sooo much easier :). That and poking around on how to debug Unreal in general (specifically, un-optimizing modules) will give you way more info as you’re working.
That said, if I were to hip-fire a guess, I’d say make sure that these functions aren’t just returning null:
UQuartzSubsystem* QuartzSubsystem = AudioComponent->GetQuartzSubsystem();
const UWorld* World = AudioComponent->QuartzGetWorld();
This is one of the things that has been improved in 5.1, but those things are lazy-initialized all over Audio Component with code like this:
//Initialize the tickable object portion of the Audio Component, if it hasn't been initialized already
if (!FQuartzTickableObject::IsInitialized())
{
Init(GetWorld());
}
check(FQuartzTickableObject::IsInitialized());
So I’d guess your problem is those things haven’t been initialized on the AudioComponent by the time you’re calling those functions.
It would be safer to obtain that information yourself.
AActor
inherits from UObject
(I’m assuming that your ANewConductor
class inherits from AActor
). So you can get the world from your own actor there instead of the AudioComponent, replacing it with :
const UWorld* World = GetWorld();
Then right below that, you can use the UWorld to get the Quartz Subsystem directly (using a static method on that class):
UQuartzSubsystem::Get(World);
This code may or may not work depending on which engine version you’re on.
Good luck!