Download

FFT and Spectrum Analysis using the new audio engine

Hi folks,

I’m looking to create a spectrum analyzer that can be used in the new audio engine in a similar manner to the Envelope follower.

I already have the FFT code working nicely outside of unreal and I’m hoping that someone can point me towards the appropriate files in the source tree for the Envelope follower so that I can pull them into a new project and use them as an integration starting point.

Also are there any special considerations that I should take into account when building modules that expand the new audio engine?

Many thanks,

Andrew

You should put your stuff in a plugin. check out the Synthesis plugin for a bunch of examples of source and submix effects.

You’ll want to make your new thing either a source effect or a submix effect too. There’s lots of examples. Search for any file called “SourceEffect*” or “SubmixEffect*”.

Many thanks for your response, I’ll take a look at the files you suggest.

Hi

This maybe comes a little late, but i guess it matters not.

I have started the pitchshift by making a copy of the BitCrusher DSP and BitCrusher Source Effect classes straight into a project, because i found it is straightforward, and easy to modify.

However, you are indeed better to be going with the implementation of Envelope Follower and it will show the example of the use of a multicast delegate which the solution is based on.

You will find the component used to access the delegate in a convinient way stuffed in the Listener Source Effect. I believe it would be better to separate it out to file and use the delegate by including it but it’s up to your decision i guess :slight_smile:

One thing regarding the FFT, the DSP’s are running as instanced classes (parallel), so you have to make sure don’t run into issues with static variables and the kind of that. Check for cpu and ram usage as well. The incoming audio you get in dsp is in -1.f to 1.f range, and you will receive the data on a per sample basis, that you may want to accumulate first into a buffer. But again it is up to your implementation.

Also, there are a few FFT implementations floating around the webs, but you have to make sure the licenses are compatible with the epic eula, otherwise it may not gonna work out well in the end.

We have KissFFT in UE4 already. Just check it out. https://github.com/mymei/UE4/tree/master/Engine/Source/ThirdParty/Kiss_FFT/kiss_fft129

It’s on our list to add support for like the envelope follower (but better). We added a much easier way to get per-source envelope following from an audio component or synth component for 4.19 (should be in Master branch on github now). It’s just a first-class delegate now like “playback percent” and “sound done”. We want to add that also for FFT delegates for visualization, etc.

But, if you want to write your own, go right ahead! KissFFT is fairly easy to figure out. It’s not the most efficient FFT lib out there, but it’s good and it’s already in UE4.

Sorry about the delay in response, got pulled into actual paying projects! But I now have some time to work on something fun again, so many thanks for the pointers!