Download

Simple tone generator?

If you create a New C++ class SynthComponent, it will code gen a simple sine tone generator with an example of a BP API function for changing pitch, starting, stopping, etc.

Watch Dan do it on stage live at GDC 2017 here: https://youtu.be/ErejaBCicds?t=47m52s

Ah, this is perfect. Thank you!

I spent the last 6-8 hours searching and scouring the internet and this is the only reference I have found that mentions the generation of sound waves in the Unreal Engine. Does anyone have any other references for this? I went to that video above and all he did was show you how to create a new C++ SynthComponent…I guess there must be an extra step somewhere to get it to work because I tried using the Start function on beginplay and placed it in the scene and it doesn’t make any sound.

You probably haven’t activated the synth component - I always forget!! Add your synth component to an Actor Blueprint then add the Blueprint to the scene. Then in the actor blueprint either Activate the synth component with a BP node or set it to Auto Activate in the details panel. No need for anything else and it should work when you Play.

Yeah Idk, I did it like it showed me to but he had it connected to something else so I’m not sure what all he left out. I know next to nothing about synth components, I should probably look into learning more about them. I imagine I’m just not doing something right, I had it on a BP and even added it to the seen. I tried activate, and the start function but neither of them seemed to do anything. No sound would play when I started the level. No doubt it’s just my lack of understanding, if you do have any good sources though that break the SynthComponent down and explain it better please share. I would appreciate it.

Lol your funny, I’m not trying to build hardware. I’m into building software, that’s why I’m on an UnrealEngine forum not a tech forum.

1 Like

I just learnt from the UE code in the dsp library to see how it worked in UE4 but
I have done DSP coding before. I would recommend finding a book on Audio programming for C++ if you are serious about it. UE4 is pretty standard in how it implements DSP and has its own DSP library to help you so downloading the source is good. But I have never seen any step by step tutorials specific to UE4.

What C++ code did you add to your synth component to generate the sound in the OnGenerateAudio method? The Default synth component wont make any sound without a few modifications - to get the oscillator to work there is a #define that has to be set to 1 and the comment in the .h file tells you to add the dsp path to the project (I forgot exactly what because I never use that code and delete it immediately!). If you dont want to use their oscillator the simplest thing to do is generate noise - In the OnGenerateAudio method make the OutAudio[Sample] = a random number between -1.0 and +1.0 in the for loop and you will hear white noise.

Once you get it going you can control the frequency with a variable float from the output back to the input. As you adjust that variable it should change your frequency at the oscillator output. If you are wanting to get a constant output at one frequency lock the output with a RC filter. i would think a constant float would do that job nicely for the RC filter.

When you get this running i would be interested just seeing it work. Video would be sweet. I was thinking of trying to make a basic electronics learning game, but i do not think many would be interested in it. So i scrapped the idea. Looks like a fun little project you have going :slight_smile:

Ah thanks for the info, I’ll probably have to do that. UE4 I’ve found isn’t quite as straightforward in some areas as it would be coding it outside of the Engine. I was primarily just trying to get it up and running and understand how it all worked before actually trying to manipulate it to meet my needs.

Yeah, I might do that if I can get this figured out. I did it in Unity and it was so straight forward and simple. I just feel lost when it comes to trying to do the same thing in UE4.

i would do what the guys aboveSandyBeachSystem was saying and what he is saying to get it going. Once you have white noise you can start adjusting according. 1st thing to do is to get a oscillator running > basically a loop that does not stop that makes noise. Then solve what frequency your at < if you need to.

If you were using OnAudioFilterRead in Unity, OnGenerateAudio is works basically the same but is less of a fudge. TBH it took me ages to make any noise in UE4 but most was getting my head around how the Engine worked. But once you get any sound it gets easier very quickly and you can do anything.

In theory, this should work. As for me, now there are many different software that can provide work with an audio track and get a sound of a different range.

I was messing around yesterday with the audio set up stuff and there are many ways to do the sound stuff. I found the oscillator and the white noise items. I can see once i decide to hook up those in the proper set up, it all should work. I am working on a play the music and make the different colored lights light up at certain frequencies, like the christmas lights on the houses we see today is what i am after.
What makes this tough is it is done in code not actual electronic circuits. So it makes you think how the heck can i get this in code, but if it were actual electronic circuits it be a lot easier. Example is getting the frequencies from the audio track you play. Is there a function in UNREAL4 that will spit out the frequencies that are being played in the audio? Any ideas would be appreciated very much.

EDIT: Think i might have found ithttps://docs.unrealengine.com/en-US/BlueprintAPI/SoundVisualization/CalculateFrequencySpectrum/index.html

EDIT: Must watch video if you want to get frequencies
https://www.bing.com/videos/search?q=how+to+get+frequencies+from+audio&&view=detail&mid=78A9B5E3C05B44C4096878A9B5E3C05B44C40968&&FORM=VDRVRV

Eww no don’t use that old plugin for getting freqs! It is MUCH easier, better, and already built-in to later versions of Unreal! Check out tons of examples in my free project: Arthurs Audio BPs

sweet, thanks for the info. i will check that out right now :slight_smile:

EDIT: that is awesome man, good job on that.
Again, that it just plain badass! Thanks for your time you put into that. That is one hell of a setup it is just plain awesome. your the man.

1 Like

Thanks for the response, I’ll keep that in mind and just start working through some audio tutorials. I too found it quite easy too pull off in Unity with my limited knowledge of their system at the time. Unreal seems to lack many tutorials on specific things like this so I assume you really have to wrap your head around their system before you understand things like that.

Yeah it does help to have a good understanding of audio. Then everything makes sense when your doing it. If your not fully up on audio it can take awhile to understand it all as there is alot to audio, way more then most imagine. Only reason i jumped into this thread was that i’ve been repairing audio for over 30 years. So the knowledge i have from that applies here very well, but sometimes in code it is tough to figure out exactly how to accomplish the same thing that is done in an actual audio circuitry. Can be a real pain at times.

Associative thinking is cool. It’s great when a person can apply their professional knowledge in different areas of life.