Download

Dynamic music

https://youtube.com/watch?v=yZYW1fjtFTw

Here is a video for my dynamic music setup. Using timeline blueprints, this system keeps tabs on where the beat is and checks when it is appropriate to switch to the next track in the sequence.

If anyone is interested, I’ll do a tutorial :slight_smile:

Would love a tutorial on this! This is great!

Okay, I’ll do it!

The tutorial will have to be after thanksgiving, though :slight_smile:

Really nice!

This is pretty amazing ! Good job !

Wow this is pretty cool, thanks for being nice enough to help everyone out with working on a tutorial - can’t wait to see it! :slight_smile:

Sorry this is taking so long, guys! In recording the tutorial, It crashed and I didn’t notice it so i did the whole thing and it didn’t even record!

I’ll try again tonight.

No worries Steven! Youre doing us huge favor with this so thanks again

Haha dude that’s awesome! Did you align to a specific tempo to make sure everything crossfades correctly or does it just wait until one file is finished playing and queue the next?

Excellent tutorial. Back in the early 90s, LucasArts used this sort of technology called “iMuse” in Monkey Island and other games, reworking the song to transition to the next rooms audio. This has been something i’ve been wanting to do in my game, so I’m happy to see someone did it before me! :smiley: Thank you so much.

I think this can be taken even further. I wonder if we can work it a certain way where we have music separated by instrument, fading/volume/pitch depending on the trigger, more so like iMuse. Its an interesting thought, but it would greatly increase the size of the final game.

How soon will there be a tutorial? No rush.

Sorry about the wait, guys! Due to some technical limitations I can’t do a video tutorial. I’ll do a written tutorial right here, let me just assemble some assets for pretty screenshots :smiley:

Also, to sbnewsom, Getting different tracks to layer on top of each other and fading them in and out should be simple enough to implement into this system. I’ll work it into the tutorial.

Should be finished later today!

we wait with bated breath

Dynamic Music

[FONT=Arial Black]Tutorial: Dynamic Music

Alright, so for this tutorial, we are going to go over ‘dynamic music’

[FONT=Arial Black]The Assets

What you will need for this tutorial is a music track that has a beginning (Start), a loop track (LoopA), a transition (LoopA-BTransition), another loop track (LoopB) and an ending (Outro). Also, if you want to do layered ‘stems’ that can fade in and out of each other, each segment will have to be separated out.

audacitytrackoverview.png
(Unfortunately I will not provide a music track as the one I will use is commissioned for a game project.)

How the system works is when a trigger event fires (in this tutorial a trigger volume), the system will wait for the correct moment in the current loop track before transitioning into the transition track. When the transition track is finished, it will then switch to the second loop track. Slight variations will also apply to the intro, and the outro tracks as well.

From what I have seen, using simple delays doesn’t seem to work, especially when there are performance drops. Things that require precise timing, like triggering music that is synced up to it’s Beats Per Minute, won’t work using a simple delay.

Timeline nodes, however, operate on a millisecond time system, so you can use them to trigger transitions.

[FONT=Arial Black]The Blueprint
[FONT=Arial Black]Step 1

To start the music, place down a trigger volume and grab the ‘begin overlap’ node and put it into the level blueprint and hook it up to a ‘do once’ (in this tutorial, the music will not be triggered multiple times, therefore a ‘do once’ is required). If you are using multiple tracks, you will need to spawn all the stems at the same time, using a sequence and then using ‘spawn sound 2d’. They need to be spawned so we can reference them later to change the volume, therefore promote the ‘return values’ to variables after the sounds have been spawned.

Speaking of volume, we need two float variables per track: A specific volume float for that track (In this case: OrchStemStartVolume), and an overall volume float for the entire stem (Simply named (OrchStemVolume). The specific for that track float is used for turning off the track when it is time to transition. The overall volume float will be used for dynamically fading in and out whenever you want. Multiply both of these floats together and plug it into the ‘volume’ input for your ‘spawn sound 2d’ (you will need to click the little drop down arrow on the bottom of the node). In this example, I am only applying this to the orchestra stem (shortened to ‘orch stem’):

step1.png
(make sure default values for all the volume floats are set to 1)

[FONT=Arial Black]Step 2

To set these two volume variables, we need another trigger. Let us put down another trigger volume in the level and grab the ‘begin overlap’ and ‘end overlap’ and hook it up to a timeline, which will transition from 1 to 0 over the course of a second, and have it set the overall volume (OrchStemVolume). This is the only time the overall volume will be set, so later in the tutorial when it is mentioned to set a volume float, I will always be talking about the ‘specific volume float’.

99faae1bbd54b5975b8266d673b417dbbbbfbcae.png

[FONT=Arial Black]Step 3

Now, place a new timeline at the end of the ‘spawn sound 2d’ string. This timeline will determine where it will be appropriate to transition to the next segment of the music, so set the time accordingly. In my case, the intro track is 11.44 seconds, so set that to your timeline length. Since this isn’t a looping track, we can just drag off the ‘finished’ output of the timeline and plug that into a custom event. I called mine ‘Intro Finished’:

400b912749096e8bb217daae2acb0907e9fe3db8.png

[FONT=Arial Black]Step 4

So now, to get the dynamic volume working, we need to start another string. Because we always need to keep tabs on the volume, this has to be set from an event tick. Grab your sound 2d variable you made, and check to see if it is valid. If true, pass through to a ‘set volume multiplier’, and have the two volume floats you made, which are multiplied together, plug into the 'new volume multiplier

ddd68dcbee22c01d0c2931d93a46892aec2f07ad.png
(Keep in mind you will need to do this for each sound variable, so you will need a string for each one, hence the sequence at the beginning)

[FONT=Arial Black]Step 5

Now, back to the music string. Grab that custom event you made earlier. This is where the second segment of the music will trigger. Because of this, the first thing we need to do is disable the previous tracks. grab the specific volume float (OrchStemStartVolume in this case) and set it to 0. Then plug this into a ‘set volume multiplier’, referencing the previous tracks variables. After this is done, plug the output into a ‘destroy component’, again referencing the previous track variables. These three nodes are important, so I will call this cluster the ‘Volume Set Trio’:

7e98a2a6195d9dd99904aac080941120ad166713.png

[FONT=Arial Black]Step 6

The next step is similar to the second half of ‘step 1’. You need to use a sequence to trigger our 2 stems, this time it will be our ‘LoopA’ segment (make sure it is a loopable sound cue). Promote these to a variable, and grab the two volume floats and put them through a multiply and plug it into the volume multiplier. IMPORTANT: Make sure to create a new variable for the specific volume float track, in this case i named mine (OrchStemLoopAVolume)

819b44710be0ac9a4fca178e7b08c28dbf9dddf7.png

[FONT=Arial Black]Step 7

Create a new timeline. Since this is a loop, make sure the ‘loop’ checkbox on top is ticked. Set the length to the length of the timeline to the length of your ‘LoopA’ segment (in my case, 9.13 seconds). Now, if your track is capable of transitioning somewhere else besides the end, grab the time for each transition point, and have the timeline fire events at said times. Plug this event output into a new custom event, I named mine Loop1Transition:

c46759cbf133c53785c6e987233ff0033a27544b.png

ff3e036a04253c02474dd8447430ff2d5d739a3f.png

[FONT=Arial Black]Step 8

To trigger out of the ‘LoopA’ segment, place a trigger volume and grab the ‘begin overlap’. Since we need to wait for the ‘Loop1Transition’ custom event, we need to connect it to a gate, and have the ‘begin overlap’ open that gate. Since this is the ‘transition’ segment of the song, and not a ‘loop’, the following nodes are identical to the ‘intro’ music string, with the exception of the addition of the ‘Volume Set Trio’.

ccc1e9bf223758a3a37bb99cf44546174fece7d3.png
(Right click + ‘open image in new tab’ to see full size)

Okay, that is it for now! Hope you all enjoyed this tutorial!

Keep in mind to update that ‘set volume multiplier’ that is connected to event tick with our new variables!

step8-2.png

[FONT=Arial Black]Step 9
The rest of the nodes, which is the ‘LoopB’ segment, and the ‘Outro’ are identical to previous steps, I will simply post the end result of the blueprint so you can confirm your work.

http://s26.postimg.org/s0m66l4av/finalbp.png

(Right click + ‘open image in new tab’ to see full size)

Hi StevenWaltherMedia. Awesome Tutorial. Dynamic Music was partial inspiration behind MOODSAURUS: In-game Player Selected ‘Mood’ Jukebox in UDK. Your tutorial has rekindled my interest. Perhaps I’ll look into an implementation in UE4.

Awesome! Glad I could inspire some creativity ^^

This is great :slight_smile: looking forward to try it in our project!