# Dan's Dynamic Music Exploration (UE4/Game Engine/Etc.)



## dannthr (Jun 30, 2014)

Ahoy, ahoy musical cats and dogs,

If you were not already aware, one of my more specific areas of interest is with games and interactive audio. I really like the idea that my audience can interact with my music and that somehow their actions can change my music--that it responds to their actions and that either they are in control of its movement or that the music moves with them.

So, in February the Unreal Engine 4 released to the public/subscribers. The Unreal Engine 4, for the uninitiated, is a game engine, which essentially is a software framework upon which games can be built. As a framework, it allows for a wide variety of systems to be designed and implemented and my hope as a subscriber is to expand my insight into the engine itself (having previous experience with UDK/UE3, the last version of the engine) as well as put it through some paces with regards to music as the previous version's visual design interface had serious timing problems.

The Unreal Engine has a visual scripting interface called BluePrints. In Unreal Engine 3 and the Unreal Development Kit (the previous version), the engine sported a less robust visual scripting interface called Kismet which was plagued with critical timing issues.

One of the first things I was excited about with UE4 (Unreal Engine 4) was the assertion that the timing problems with Kismet had been sorted out in BluePrints--so I was really excited to try creating some interactive music with BluePrints.

The first thing I did was take an old piece originally designed to loop indefinitely and set it up to loop until a key was pressed:



Basically:

[Introduction segment] => [Main Segment] => [Is Spacebar Pressed?]

[No] => [Loop Back Segment] => [Main Segment] etc..
[Yes] => [Loop End Segment]

So that was interesting, though there was a small timing issue on the BPs in the simulation setup.

To assist in creating a context for me to build more specific interactive cues--and to explore some ideas I have about Interactive Orchestration--I then decided to try and build a little level that would offer some opportunities--so I built this little dungeon-y level (no audio, just the level I built):



Then I composed a short 8 bar loop, my premise was that I wanted music that dynamically adjusted based on Player Character Movement--I felt that under certain orchestrational rules, you could create natural movement between parallel layers of music--here's the first 2-tier version with a preliminary run through of the development environment, and a demonstration of how the systems were built:



This one is simple:

[Main Loop A - Ambient] => [Main Loop B - Ambient] => Loop Back to A
- Crossfade Between ----------- Crossfade Between 
[Main Loop A - Active--] => [Main Loop B - Active---] => Loop Back to A

You can see the crossfade data splaying down the left side of the viewport during game-play--this shows the precise balance between the base-layer and the high activity layer as influenced by the character movement.

One of the more interesting things I had to design here was an interpolation system that would dynamically fade in and out the active layer.

However I realized that the two versions of the loop were too dramatically different--so I opted to create an intermediary layer and learned how to send the information more cleanly to the User Interface (as measured by percents).

You'll also note that the fade-in time is much shorter than the fade-out time for the layers and that the active layer doesn't kick in until the medium layer is at 100%.

I also wrote an introduction segment.



I'd love to hear what you guys think--obviously, the hope here is that the music movement and transitions are musical sounding and I hope to expound on some thoughts I have about trying to make a crossfade not feel as much like a crossfade but feel more like natural orchestral/instrumental movement.

Cheers,


----------



## mscottweber (Jul 1, 2014)

Dan, very cool!

It all sounds very smooth and fluid, especially the last video with the medium layer added. I agree that the fade out should be slower than the fade in, but it almost felt too slow to me. In the context of a game, though, it might feel perfect.


----------



## Jdiggity1 (Jul 1, 2014)

Dan, you have introduced me to my next hobby. Thank you! (i think?)


----------



## benmode (Jul 2, 2014)

This is ace. Just the kind of thing I wanna start learning. Thanks for sharing


----------

