MetaSounds Quick Start Guide

Follow this Quick Start guide to go over how to create a procedural music system with MetaSounds.

Windows
MacOS
Linux

Goals

In this Quick Start guide, you will learn how to create a basic procedural music system using MetaSounds. You will also learn how to modify the MetaSound parameters with Blueprints to change the music at runtime.

Objectives

  • Create a basic procedural music system with a MetaSound.

  • Create a Blueprint that changes several parameters of the MetaSound at runtime.

1 - Required Setup

  1. Click Settings > Plugins to open the Plugins Menu.

    image alt text

  2. Go to the Audio section and select Enabled for the MetaSound plugin. Accept the warning and restart the editor.

    image alt text

  3. In the Content Browser, right-click and select Sounds > MetaSound to create a new MetaSound asset. Name the asset MS_ProceduralMusic.

    image alt text

    image alt text

  4. Double-click the MS_ProceduralMusic MetaSound to open it.

Section Results

You enabled the MetaSound plugin and created your first MetaSound. You are now ready to use the MetaSound Editor.

2 - Using the MetaSound Editor

Introducing the Editor

The MetaSound Editor is where MetaSounds are created, modified, and previewed. MetaSounds are converted to C++ code when they are played.

All Audio Inputs are evaluated live, meaning changes to their values are reflected immediately as the MetaSound plays in the editor. Any changes to the MetaSound topology will require the MetaSound to be replayed from the beginning to hear the changes.

MetaSound Editor Overview

image alt text

Section

Description

1 - Toolbar

This toolbar contains the following high-level controls for the MetaSound:2

  • Save - Saves the current MetaSound asset.

  • Browse - Navigates to the current MetaSound in the Content Browser.

  • Play / Stop - Plays or stops the current MetaSound.

  • General - Opens the General Settings panel in the Inspector. This is where you can modify the default playback behavior of the MetaSound in the audio engine.

  • MetaSound - Opens the MetaSound settings in the Inspector. This is where you can modify the audio rendering details for the MetaSound.

2 - Inputs and Outputs

This section contains the inputs and outputs of the MetaSound. Inputs are evaluated live and can be modified externally.

3 - Inspector

This section changes based on what is selected in the MetaSound Editor, similarly to the Details Panel in other editors. It also contains the available options based on what is selected.

4 - MetaSound Graph

This section contains the nodes that form the MetaSound DSP topology. Upon creation, each MetaSound contains the following nodes:

  • On Play - Similar to Event On Begin Play in Blueprint scripting, this node is the default input trigger that is called when the MetaSound starts playing.

  • On Finished - This node is the output trigger that is called when the MetaSound finishes playing. It is optionally triggered for one-shot sounds.

  • Output - The audio output of the MetaSound. It defaults to Mono output. The Output Channel format can be adjusted in the MetaSound settings.

5 - Meter

A VU meter connected to the MetaSound output. It shows the amplitude of each audio channel (or the same for a mono output) with 300-millisecond attack and release times (standard for VU meters).

General Settings Panel

General Settings show the common settings available for any sound source in Unreal Engine. You can modify the MetaSound properties, such as Sound, Attenuation, Submix, Modulation, and Concurrency settings.

MetaSound Settings Panel

The MetaSound Settings show settings related to the current MetaSound. Here you can specify the Author and Description of the MetaSound. You can also specify the Output Format of the MetaSound, which includes Mono and Stereo.

In the full release of Unreal Engine 5, MetaSounds will expose settings for audio rendering block size and sample rate. Audio designers will have the option to include major and minor version numbers for each MetaSound to further streamline the workflow.

The MetaSound Graph

The MetaSound Graph is composed of various nodes and pins, and is analogous to Sound Cues, Blueprints, and the Material Editor Graph. There are some important differences in MetaSounds which should be understood by audio designers.

MetaSounds Are a Data Flow Graph

MetaSound is not a programming language, nor is there a programming-language-interpreted bytecode layer. The nodes are written in unmanaged C++ and are directly executed in C++.

The graph data flows from left to right with the need for output pins connected to input pins. MetaSounds do not have an Event Graph concept, as the graph is always flowing.

MetaSounds Are Acyclical

MetaSounds are a Data Flow graph that do not contain cycles. In other words, it's not possible to connect the output pin of a node to another node's input pin if that creates a circular loop in the graph.

To achieve cyclic behavior in Early Access, you can use the Send and Receive nodes. These nodes write data to a data register which is read in the next audio render block. This type of connection does not technically create a cycle as the data is read to and written from different rendering blocks.

More convenient methods for writing and accessing data are currently planned to be added as part of Unreal Engine 5's full release.

MetaSound Inputs and Outputs Are Shared by Reference

MetaSound pins pass data by read-only reference. This means that it is performant to have a Metasound output pin connect to any number of input pins on other nodes. Some MetaSound nodes may internally copy data around as needed, but it is not an inherent property of the MetaSound graph.

Similar Node Workflow

To add nodes to the MetaSound Graph, right-click the graph and select the appropriate node from the list. For Early Access, MetaSounds come with a set of nodes that provide audio designers with common functionality to create powerful and flexible MetaSounds.

For Unreal Engine 5's full release, MetaSounds will include more nodes to expand their functionality. New nodes can be easily created with third-party plugins using the MetaSound API. See the MetaSound C++ API for more information.

For a list of the most common nodes included with MetaSounds, see the MetaSounds Reference Guide.

Section Results

In this section you learned about the MetaSound Editor and how it is used to create MetaSounds. You also learned about the different sections of the editor and how to create new nodes in the MetaSound Graph.

You are now ready to create your first MetaSound Asset.

3 - Creating a Basic Procedural Music System

In this section you will create a basic music system where all audio, including melody and rhythm, is generated procedurally at runtime from a set of parameters.

  1. In the Content Browser, double-click the MS_ProceduralMusic MetaSound to open it.

  2. Drag from the Input node and search for and select Trigger Repeat.

    image alt text

  3. Right-click the MetaSound Graph and search for and select BPM To Seconds. On the BPM To Seconds node, set the Divisions of Whole Note value to 16. Connect the Seconds pin of the BPM To Seconds node to the Period pin of the Trigger Repeat node.

    image alt text

    image alt text

  4. Drag from the BPM pin of the BPM To Seconds node and select Promote to Graph Input. Name the input variable BPM.

    image alt text

  5. Drag from the RepeatOut pin of the Trigger Repeat node and search for and select Trigger Counter. Set the Reset Count value to 8. Create a comment box around this set of nodes and name it Tempo and Rhythm.

    image alt text

    image alt text

  6. Drag from the On Trigger pin of the Trigger Counter node and search for and select Random Get (Float:Array). Connect the On Reset pin of the Trigger Counter node to the Reset pin of the Random Get node.

    image alt text

  7. Right-click the MetaSound Graph and search for and select Scale to Note Array. Connect the Scale Array Out pin of the Scale to Note Array node to the In Array pin of the Random Get node. Drag from the Scale Degrees pin of the Scale to Note Array node and select Promote to Graph Input. Name the input variable Scale.

    image alt text

    image alt text

  8. Right-click in the MetaSound Graph and search for and select Random Int. Set the value of Max to 100000. Connect the Value pin of the Random Int node to the Seed pin of the Random Get node. Drag from the Next pin of the Random Int node and select Promote to Graph Input. Name the input variable New Melody.

    image alt text

    image alt text

  9. Drag from the Value pin of the Random Get node and search for and select Add Float. Set the value in the empty pin to 48. Create a comment box around this set of nodes and name it Melody Generation.

    image alt text

    image alt text

  10. Right-click in the MetaSound Graph and search for and select Sine. Right-click the MetaSound Graph and search for and select MIDI To Frequency (Float). Connect the Out Frequency pin of the MIDI To Frequency (Float) node to the Frequency pin of the Sine node. Connect the result of the previous Add node to the MIDI In pin of the MIDI To Frequency (Float) node.

    image alt text

    image alt text

  11. Repeat the steps above to add a second Sine and MIDI To Frequency (Float) nodes. Drag from the result pin of the previous Add node and search for and select Add Float. Connect the result of this node to the MIDI In pin of the MIDI To Frequency (Float) node.

    image alt text

  12. Drag from the empty pin of the Add node and select Promote to Graph Input. Name the input variable Detune. Set the default value of Detune to 6. Drag from the Audio pin at the top Sine node and search for and select Add Audio. Connect the Audio pin of the bottom Sine node to the empty pin of the Add Audio node. Create a comment box around this set of nodes and name it Synthesis - Sine.

    image alt text

  13. Repeat steps 10 to 12 to create the same set of nodes as before, but in this instance add Saw nodes instead of Sine nodes. You should now have 2 sets of nodes as seen below.

    image alt text

    image alt text

  14. Right-click the MetaSound Graph and search for and select Crossfade Audio 2. Connect the Audio pins of both Add Audio nodes to the In 0 and In 1 pins of the Crossfade node respectively. Drag from the Crossfade Value pin and select Promote to Graph Input. Name the input variable Crossfade. Create a comment box around this set of nodes and name it Crossfade.

    image alt text

    image alt text

  15. Drag from the Out pin of the Crossfade node and search for and select Ladder Filter. Right-click the MetaSound Graph and search for and select LFO. Set Frequency to 0.5, Min Value to 500, and Max Value to 5000. Connect the Out pin of the LFO node to the Cutoff Frequency pin of the Ladder Filter node. Create a comment box around this set of nodes and name it Filtering.

    image alt text

    image alt text

  16. Go back to the Random Get node and drag from the On Next pin and search for and select AD Envelope Audio. Set the Decay Time value to 0.1. Create a comment box around the node and name it Enveloping.

    image alt text

  17. Drag from the Out Envelope pin of the AD Envelope Audio node and search for and select Multiply Audio. Connect the Out pin of the Ladder Filter node to the empty Audio pin of the Multiply Audio node.

    image alt text

    image alt text

  18. Drag from the Audio pin of the Multiply Audio node and search for and select Delay. Set the Delay Time value to 0.02.

    image alt text

    image alt text

  19. Right-click the MetaSound Graph and search for and select Stereo Delay. Connect the Out pin of the Delay node to the In Left pin of the Stereo Delay node. Connect the Audio pin of the Multiply Audio node to the In Right pin of the Stereo Delay node.

    image alt text

  20. In the Stereo Delay node, set the Delay Mode to Ping Pong. Set the Delay Time to 0.2, Delay Ratio to 0.2, Dry Level to 0.7, Wet Level to 0.2, and Feedback to 0.4. Create a comment box around this set of nodes and name it Effects Processing.

    The effect created above is called "stereo widening." In this example, the delay creates the illusion that the original mono signal is a stereo signal.

    image alt text

  21. Click the MetaSound button on the Toolbar. Go to the Inspector and under the Meta Sound category, set Output Format to Stereo.

    image alt text

    image alt text

  22. Move the Output node to the edge of the MetaSound Graph and connect the Out Left pin of the Stereo Delay node to the Left Audio pin of the Output node. Connect the Out Right pin of the Stereo Delay node to the Right Audio pin of the Output node.

    image alt text

  23. Save the MetaSound and press Play to hear the music. While the music plays, change the value of the BPM input to see the changes be reflected in real time. You can also switch the value of the Crossfade input from 0 to 1, to see the effect.

Section Results

In this section you learned how to create a basic procedural music system using MetaSounds.

4 - Adding Blueprint Interactivity

In this section you will learn how to change MetaSound parameters with a Blueprint Actor at runtime.

The MetaSound Blueprint interface is under active development and is expected to change prior to Unreal Engine 5's full release.

  1. In the Content Browser, right-click and select Blueprint Class. Click the Actor class to create a new Blueprint. Name the Blueprint BP_MusicPlayer.

    image alt text

    image alt text

  2. Double-click the BP_MusicPlayer Blueprint to open it. In the Components panel, click the Add button and search for and select Box Collision. Name the collision box Trigger_BPM. Set the box collision Scale to X=5, Y=5, Z=1 and set its Location to X=0, Y=350, Z=0. Finally, scroll down to the Rendering section and Disable the Hidden in Game checkbox.

    image alt text

    image alt text

  3. Follow the previous step and add two more Box Collision components. Name the new components Trigger_Crossfade and Trigger_Melody. Set the Trigger_Crossfade Location to X=0, Y=0, Z=0, and set the Trigger_Melody Location to X=0, Y=-350, Z=0.

    image alt text image alt text

  4. Add three Text Render components to identify each Box Collision, as seen below.

    image alt text image alt text

  5. In the Components panel, click the Add button and search for and select Audio. Go to the Details panel and click on the Sound dropdown. Search for and select MS_ProceduralMusic.

    image alt text

    image alt text

  6. Select the Trigger_BPM component and go to the Details panel. Scroll down to the Events section and click the + buttons next to On Component Begin Overlap and On Component End Overlap. Repeat these steps for the Trigger_Crossfade and Trigger_Melody components.

    image alt text

  7. Go to the My Blueprint panel and click the + sign next to the Variables section to create a new variable. Name the variable NewBPM. Go to the Details panel and select Float from the Variable Type dropdown. Enable the Instance Editable checkbox as seen below. Compile and Save the Blueprint.

    image alt text

    image alt text

  8. With the NewBPM variable selected, go to the Details panel and scroll to the bottom. Set the default value for NewBPM to 110. Compile and Save the Blueprint.

    image alt text

  9. Duplicate the NewBPM variable and name the duplicate OriginalBPM. Set its default value to 90.

    image alt text

  10. Drag from the On Component Begin Overlap (Trigger_BPM) node and search for and select Do Once. Drag from the On Component End Overlap (Trigger_BPM) node and search for and select Sequence. Connect the Then 0 pin of the Sequence node to the Reset pin of the Do Once node.

    image alt text

  11. Drag the Audio component to the Event Graph to create a node. Drag from the Audio node and search for and select Get Parameter Interface. Drag from the Get Parameter Interface node and search for and select Set Float (Interface Call). Set the Name to BPM. Drag the NewBPM variable to the Event Graph and connect it to the Value pin of the Set Float node. Connect the Do Once node to the Set Float node.

    image alt text

  12. Drag the Audio component to the Event Graph to create a node. Drag from the Audio node and search for and select Get Parameter Interface. Drag from the Get Parameter Interface node and search for and select Set Float (Interface Call). Set the Name to BPM. Drag the OriginalBPM variable to the Event Graph and connect it to the Value pin of the Set Float node. Connect the Then 1 pin from the Sequence node to the Set Float node.

    image alt text

  13. Drag from the On Component Begin Overlap (Trigger_Crossfade) node and search for and select Do Once. Drag from the On Component End Overlap (Trigger_Crossfade) node and connect it to the Reset pin of the Do Once node.

    image alt text

  14. Drag the Audio component to the Event Graph to create a node. Drag from the Audio node and search for and select Get Parameter Interface. Drag from the Get Parameter Interface node and search for and select Set Float (Interface Call). Set the Name to Crossfade.

    image alt text

  15. Drag from the Value pin of the Set Float node and search for and select Select Float. Set the B value to 1.0. Drag from the Pick A pin and select Promote to variable.

    image alt text

    image alt text

  16. Drag the PickA variable to the Event Graph and select Set PickA. Drag the PickA variable to the Event Graph again and select Get PickA. Drag from the PickA node and search for and select Not Boolean. Connect the Not node to the PickA pin of the Set PickA node. Connect the Set Float node to the Set PickA node.

    image alt text

  17. Drag from the On Component Begin Overlap (Trigger_Melody) node and search for and select Do Once. Drag from the On Component End Overlap (Trigger_Melody) node and connect it to the Reset pin of the Do Once node.

    image alt text

  18. Drag the Audio component to the Event Graph to create a node. Drag from the Audio node and search for and select Get Parameter Interface. Drag from the Get Parameter Interface node and search for and select Trigger (Interface Call). Set the Name to New Melody. Compile and Save** the Blueprint.

    image alt text

  19. Drag the BP_MusicPlayer Blueprint into your Level and press Play to see the results. image alt text

Section Results

In this section you learned how to modify MetaSound parameters directly inside of a Blueprint Actor.