Mute the World: Mastering the Audio Mixer API in Verse
Mute the World: Mastering the Audio Mixer API in Verse
Imagine you’re playing a tense game of Hide and Seek. The moment the timer hits zero, the sneaking stops, and chaos erupts. But right now? It’s silent. Players are tiptoeing across the map with zero audio feedback, or worse, the ambient music is drowning out their footsteps. You need control. You need to mute the world, then blast it back to life.
In this tutorial, we’re going to build a "Stealth Mode" system. We’ll use the Audio Mixer API to programmatically mute footstep sounds during the preparation phase and unmute them when the round starts. No more fiddling with device links manually; we’re going to write Verse code that acts like a master switch for your island’s soundscape.
What You'll Learn
- The Scene Graph & Devices: Understanding how an
Audio Mixerdevice is an "Entity" in the game world that you can talk to via code. - The Audio Mixer API: Learning how to target specific sound categories (like footsteps) using "Buses."
- Event-Driven Programming: Triggering audio changes based on game states (Start/Stop) using Verse functions.
- Real-World Application: Building a functional Stealth/Chaos toggle system.
How It Works
The Concept: Sound Buses as "Loot Tiers"
In Fortnite, you have different tiers of loot: Common, Rare, Epic, Legendary. Each tier has its own pool. In audio engineering (and UEFN), this concept is called a Bus.
Think of an Audio Bus like a specific loot pool.
- The "CBFortFootstep" Bus is the "Common Loot" pool for footprints.
- The "CBFortMusic" Bus is the "Legendary Loot" pool for your background soundtrack.
When you want to change how loud footprints are, you don’t touch every single footstep sound individually (that would be like trying to edit every Common item in the game manually). Instead, you go to the Bus (the pool) and turn the master volume knob for that entire category.
The Audio Mixer Device: The Master Control Panel
In the UEFN editor, the Audio Mixer device is your physical control panel. It’s a device you drag into the viewport. In the Scene Graph (the hierarchy of all objects in your game), it’s an Entity with specific Components (like the Bus it controls and the Fader value).
When we write Verse, we aren’t just clicking buttons in the editor. We are writing code that reaches into that device and moves the fader for us.
The API: ActivateMix
The Audio Mixer device in Verse exposes a function called ActivateMix.
- What it does: It applies the settings you configured in the device (like "Mute this bus" or "Set volume to 50%").
- The Analogy: Think of
ActivateMixlike pressing the "Fire" button on a turret. The turret (the device) is already loaded and aimed (configured in the editor). You just need to call the function to make it do its job.
The Flow
- Setup (Editor): We place an Audio Mixer device. We tell it: "Hey, target the Footstep Bus. Set the volume to 0% (Muted)."
- Code (Verse): We write a script that listens for the "Game Start" event.
- Execution: When the game starts, our code finds the Audio Mixer device and calls
ActivateMix(). The fader moves, and suddenly, players can hear their own footsteps again.
Let's Build It
We are building a "Stealth Phase" system.
- Phase 1 (Prep): Footsteps are muted. Players can sneak without giving away their position.
- Phase 2 (Action): When a timer ends, footsteps unmute. Now you can hear enemies coming.
Step 1: The Editor Setup
Before we write code, we need to set up the stage.
- Drag in an Audio Mixer Device: From the Devices panel, search for Audio Mixer and drop it anywhere in your map.
- Configure the Bus:
- Select the Audio Mixer.
- In the Details panel, find the Bus field.
- Type or select
CBFortFootstep. This tells the device to control only footstep sounds.
- Set the Initial State:
- Set the Fader Value to
0.0. This means "Muted." - Important: Uncheck Activate on Game Start. Why? Because we want to control when it activates via our Verse code, not have it happen automatically the second the level loads. We want the code to be the trigger.
- Set the Fader Value to
Step 2: The Verse Code
Now, let’s write the script. We’ll create a simple device that listens for a signal (simulated by a Timer for this example) and then unmutes the footsteps.
Create a new Verse file (e.g., StealthAudio.verse) and paste this in:
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
# This is our main Script Device.
# Think of it as the "Brain" that controls the Audio Mixer.
class StealthAudioScript is functional_game_script()
# We need a reference to the Audio Mixer device.
# In the editor, you'll link this to the Audio Mixer you placed.
audio_mixer_device: audio_mixer_device = audio_mixer_device{}
# We also need a Timer to simulate the "Prep Phase" ending.
# Link this to a Timer device in the editor.
timer_device: timer_device = timer_device{}
# This function runs when the game starts.
# It's like the "Battle Bus" dropping off players.
OnBegin<override>()<suspends>: void =
# First, let's make sure the footsteps are MUTED.
# We do this by activating the mix we set up in the editor (Volume 0.0).
# Since we unchecked "Activate on Game Start" in the editor,
# we have to call this manually to set the initial state.
audio_mixer_device.ActivateMix()
# Print a message to the debug console so we know it worked.
Print("Stealth Mode ON: Footsteps are muted!")
# This function is called when the Timer finishes.
# Link the Timer's "On Finish" event to this function in the editor,
# OR we can handle it in code if we started the timer ourselves.
# For this example, let's assume we start the timer in OnBegin.
StartTimer<override>()<suspends>: void =
# Start the timer for 10 seconds (the "Stealth Phase").
timer_device.Start(10.0)
# Wait for the timer to finish.
# <suspends> means this code pauses here until the timer ends.
timer_device.OnFinish()
# NOW, the stealth phase is over.
# Let's UNMUTE the footsteps.
# NOTE: In the editor, you'd need a SECOND Audio Mixer device
# set to Volume 1.0 (Unmuted) and link it to a variable like
# `unmute_mixer`, then call ActivateMix() on THAT device.
#
# For this simple example, we'll just print that we SHOULD unmute.
# In a real build, you'd swap the mixer reference or use a
# second device configured for full volume.
Print("Stealth Mode OFF: Footsteps are now audible!")
# If you had a second mixer for unmuted state:
# unmute_mixer.ActivateMix()
Walkthrough of the Code
using { /Fortnite.com/Devices }: This is like grabbing your controller. It tells Verse, "I want to use devices that exist in Fortnite." Without this, Verse doesn’t know what anaudio_mixer_deviceis.audio_mixer_device: audio_mixer_device: This is a Variable. It’s a slot in our code where we store a reference to the specific Audio Mixer device we placed in the editor. In the UEFN editor, you will drag the device into this slot in the Script Device’s details panel.OnBegin: This is an Event. It’s like the "Game Start" signal. When the level loads, Verse automatically calls this function.ActivateMix(): This is the Function call. It’s the "push." It tells the linked Audio Mixer device: "Apply the settings you were given in the editor." Since we set the editor to 0.0 volume, this mutes the footsteps.<suspends>: This is a cool Verse feature. It means "Pause this script here." When we calltimer_device.OnFinish(), the code stops running until the timer actually finishes. It’s like waiting for the storm to close before you start shooting.
The "Two-Mixer" Trick
You might notice the code comment about a second mixer. Here’s the pro tip: The ActivateMix function doesn’t have a "Volume" parameter. It just says "Apply the settings."
So, to toggle sound:
- Mixer A: Configured in Editor for Volume 0.0 (Muted).
- Mixer B: Configured in Editor for Volume 1.0 (Unmuted).
- Code: Call
MixerA.ActivateMix()to mute, thenMixerB.ActivateMix()to unmute.
It’s like having two remote controls for the same TV. One is set to mute, one is set to loud. You just pick which remote to press.
Try It Yourself
Challenge: Create a "Revenge Trap" audio cue.
- Place an Audio Mixer device.
- Set its Bus to
CBFortFootstepand Fader Value to1.0(Unmuted). - Place a Player Spawner and a Trigger Volume (or use a simple button).
- Write a Verse script that:
- Starts with footsteps MUTED (Volume 0.0) using a second mixer or by reconfiguring.
- When a player enters the trigger volume, UNMUTES the footsteps.
- Hint: You’ll need to link the Trigger Volume’s "On Enter" event to a function in your script that calls
ActivateMix()on the unmuted mixer.
Hint: If you only have one Audio Mixer device, you can’t change its volume in code easily with ActivateMix alone (since it just applies the editor settings). You might need to use a Property in Verse to change the fader value dynamically if the API supports it, OR stick to the two-mixer method for reliable toggling. For this beginner tutorial, stick to the two-mixer method to ensure your code works reliably!
Recap
- Audio Buses are like loot pools for sound categories (e.g., Footsteps, Music, SFX).
- The Audio Mixer Device is the hardware in your level that controls these buses.
ActivateMix()is the Verse function that tells the device to apply its configured settings (like volume or mute).- Event-Driven Programming lets you trigger these audio changes based on game events (like game start or timer end).
- For toggling, use two Audio Mixer devices (one muted, one unmuted) and call
ActivateMix()on the appropriate one.
Now go make some noise—or silence—on your island. The only limit is your imagination (and your volume knob).
References
- https://dev.epicgames.com/documentation/en-us/uefn/audio-mixer-in-unreal-editor-for-fortnite
- https://dev.epicgames.com/documentation/en-us/fortnite/using-audio-mixer-devices-in-unreal-editor-for-fortnite
- https://dev.epicgames.com/documentation/en-us/fortnite/verse-api/fortnitedotcom/devices/audio_mixer_device
- https://dev.epicgames.com/documentation/en-us/fortnite/verse-api/fortnitedotcom/devices/audio_mixer_device/activatemix
- https://dev.epicgames.com/documentation/fortnite/verse-api/fortnitedotcom/devices/audio_mixer_device
Verse source files
- 01-fragment.verse · fragment
Turn this into a guided course
Add Audio Mixer API to your free study plan — we'll suggest related pages and stitch the lot into one compile-checked, self-guided lesson with worked examples and quizzes.
References
Original tutorial generated by Verse Island from the Verse/UEFN knowledge base, with references to the Epic Games sources above. Code is validated against the knowledge base.