Home

2024

Worklog

LETSGO Game

Playing Drums from Code surprisingly sus

Date
August 5, 2024
Hours
6
Tags
UnrealCodeC++LETSGO

Stat holiday, still woke up at 5 after severe cold last week.

Big 6 hour push on Playing Quantized sounds from code, as represented by this large commit:

The problem is if I have a single AudioComponent representing the kick, but PlayQuantized per beat, the new Play command squashes the previous Play command. This makes the Kick sound cut, half volume, low volume, etc.

image

I tried creating unique AudioComponents OnQuantizationBoundaryTriggered, but it sounds like its playing all the beats at the same time (I think at bar?)

image

So my idea was to create a wrapper Actor around the AudioComponent, spin up a whole actor to see in the world outliner exactly what was going on. It would create and play 4~ actors at the same time, sounding much like the AudioComponent way.

The other advantage of this approach is that I can easily destroy the AudioComponent within the Actor. Without the Actor I lose the reference to the AudioComponent. I worry about a massive amount of AudioComponents just sitting there attached to the Drums actor.

image

Anyways, it’s not working correctly, and much trickier than I was expecting.

My assumption was that the amount of time to create the AudioComponent/WrappedActor was longer than the beat itself.

But I’m wondering if I’m losing something on the quantization boundary:

image

PlayQuantizationDelegate binds to the logic above, where I create and play the audio cue. That event is triggering at the correct rate. So I’m now wondering if there is an issue at the PlayQuantized() level.

Candidates for what the issue is in that case:

image
  1. EQuartzCommandQuantization::Bar is not being overwritten (unlikely)
  2. EQuarztQuantizationReference::BarRelative is delaying the sounds. I’m not sure what this does honestly, I was just copying the settings from the Blueprint (which did work).

But, I’m calling it here for today. Definitely upped my stamina from working every day. Still not quite at 8 hours per day. But thats arbitrary anyways isn’t it? 6 straight hours working on this is really damn good imo.

Peace.