Cabbage Logo
Back to Cabbage Site

Csound wrapper/plugin for Unreal Engine

I set the UE API manual to the dark theme, and it still makes no sense to me :thinking:

1 Like

Do you have any intel on using a USoundWave class in BP?

absolutely no idea was trying to figure it out the other day, but only realised i should be upsing bp based projects yesterday hahahah

I might be on to something here…create an AudioComponent class, and then pass the USoundWave to it…

Ooh keep me posted, where are you making the AudioComponent?

As a C++ class, but it’s not working out as I had expected…

I can create an AudioComponent class for BP, but I can’t seem to assign it a Csound USoundWaveProcedural object. Hmmm, there has to be a way. The AudioComponent class has a method for setting aUSoundWave, which my Csound class now is.

After going around in circles over this, I think it might be best to try to start a single instance of the synth, but instead of just playing it for a few second, play it indefinitely. We can then send score events to it. The only thing is I don’t know how to set an on event to run indefinitely. Right now it’s being triggered from the projectile object. We just need to trigger it a different way, and don’t turn it off.

1 Like

@giovannibedetti Have you used UE4 much before? I’m struggling with some basic concepts!

What if we actually connected it to the player spawn node if thats possible?

I would do this differently. Instead of spawning an instance of Csound each time the bullet firing event is triggered you could instead create a Blueprint callable C++ function inside your Csound component that calls Csound->ReadScore to call the instrument that makes the sound effect (if that’s what you are trying to do). USynthComponent is an Actor component so you could add it to any Blueprint Actor in the components section, then access it to trigger notes. Also USynthComponent inherits from USoundWave already. Once added as a component it can be routed or spatialized as any other audio source.



1 Like

No I’m sorry never opened it!
But I can ask around :wink:

I think @virtualHC already cleared this up :thumbsup. I will try this a little. It’s taking a while to get my head around the BP system.

Do you have to call Start on this synth for it to sound once you send a score event? How are you triggering the OnGenerateAudio(float* OutAudio, int32 NumSamples) method? In my remedial tests I’ve had to use Start, or else the generate audio method is not called?

I’m just up and also about to try virtualHc’s way of it, will let yous know what happens!!

@rorywalsh have you had any luck getting BlueprintCallables to show up in the UE Blueprint editor? I’ve got this and its just NOT showing :((
BP2 BP1

EDIT: worked after restarting the UE editor, that is NOT ideal hahahhaa

So something along these lines you mean right?

Edit: Okay I moved AddCsoundWrapper to be connected to Event BeginPlay node in FirstPersonCharacter, that assigns it to a variable called CsoundInstance then calls Start, then when the projectile gets spawned, it’s calling the playNote() function, but when I try and copy from Spout to OutAudio in OnGenerateAudio() it crashes, god its TANGIBLE, any ideas? Edit edit: spout is a nullptr, even after calling GetSpout()…

Yes, USynthComponents need their Start method to be called so OnGenerateAudio starts looping. This is an example of my Event Begin Play. The Set Mic Positions is a BP function for a virtual speaker ambisonic decode, but the rest are calls to C++ functions inside my Csound component. Note On then can be called from any other BP or within the same via event calls (see example in screenshot).

Is there any chance you could send on your SynthComponent class source code? Feel like I’m missing something really obvious here

Okay I got this working, always on csd setting channels, only thing is once the note event finishes I get horrible noise from the SPOUT buffer, is there a way to like, clear the SPOUT?