The interface could not load. You can still read below. Retry
Random Containers: Add Variety to Your Sounds
When every shot plays the same sound effect, the repetition quickly becomes noticeable. A Random Container selects a sound from a group, adding variety to repeated actions.
In this tutorial, you will use four gunshot sounds to learn about weights, repeat limits, and random selection. You will then add four mechanical sound effects and trigger both layers with a single Action.
1.1 Create a Project and Import Four Gunshot Sounds#
Open Harken Hub, click Projects on the left, then click New Project in the upper-right corner.
Enter Container_Tutorial in Project Name. Click Location → Browse and choose where to save the project.
Click Create Project. In the confirmation dialog, check the project name, location, and Studio version. Make sure Template is set to create an empty project without a template, then click Create Project again.
Wait for Studio to open. In the Explorer → Assets → Layer section on the left, right-click, choose Create → Layer, and name it Container_Examples. All four tutorials in this series use this Layer.
Download the four gunshot WAV files for this tutorial (Weapon_Fire_01.wav–Weapon_Fire_04.wav).
Right-click, choose New Parent → Container, and name it Weapon_Fire.
The four Sounds become children of this Container. When you play Weapon_Fire, the Container determines which sound to play.
Select Weapon_Fire in Explorer. If Inspector is not visible on the right, first double-click Weapon_Fire to open Selection Editor. Find Mode under Inspector → Basic → Selection.
Mode determines how the Container selects and plays its children. In Harken Studio, Random Container, Sequence Container, Match Container, and Blend Container are four modes of the same Container object. Use Mode to switch between them.
This tutorial uses Random to select one of the four gunshot Sounds at random. The other three modes are covered in later tutorials.
Double-click Weapon_Fire to open Selection Editor. In the default layout, it is in the lower-middle area of the main window.
The Child table lists the four Sounds. Leave Weight at 50 for all four for now.
Return to Explorer, select Weapon_Fire, and click the Play button at the top to audition it. Wait for the sound to finish before clicking again. Repeat a few times, then press Ctrl+S to save the project.
During the audition, Blueprint shows which Sound is playing with a green outline. In the screenshot below, the Sound ending in _01 is playing. Blueprint is open by default; if you cannot find it, choose View → Blueprint at the top of the main window.
1.3 Adjust Sound Selection Probability with Weight#
Some variations should occur frequently, while others should be heard only occasionally. Use Weight to adjust their relative chances: a higher value makes a sound more likely to be selected, and a lower value makes it less likely. Weight does not change the sound's volume.
If a variation is especially distinctive and should not occur too often, lower its weight. The following steps use Weapon_Fire_04 as an example.
Double-click Weapon_Fire to open Selection Editor. In the Child table, find the Weight column and change Weapon_Fire_04 from 50 to 25. Press Enter to confirm. Leave the other three Sounds at 50.
Select Weapon_Fire in Explorer and click the Play button at the top a few times. Watch Blueprint to see which Sound receives the green outline on each trigger.
To exclude this sound from playback, temporarily set the Weight of Weapon_Fire_04 to 0.
Return to Explorer, select Weapon_Fire, and click the Play button several times in quick succession. Notice that Weapon_Fire_04 is the only Sound that is never selected.
Restore the Weight of Weapon_Fire_04 to 50.
When working with Weight, focus on the ratio between the weights, not any single value:
Set all four weights to 50, or all four to 100. Either way, the ratio is 1:1:1:1, giving each sound a 25% chance of selection. Over many triggers, the four sounds will be selected in roughly equal proportions.
Set one weight to 25 and the other three to 50. That sound is half as likely to be selected as any one of the others. Over many triggers, it will generally occur less often than each of the other sounds.
Set a sound's weight to 0. Its chance of selection is 0, so it will not play when the Container is triggered. Set its weight above 0 to include it in the selection again.
Use Min Repeat Gap to prevent consecutive shots from playing the same sound. Select Weapon_Fire and find Min Repeat Gap under Inspector → Basic → Selection.
Set Min Repeat Gap to 1.
Select Weapon_Fire and click the Play button at the top to audition several shots. Watch Blueprint to see which Sound is selected each time.
With Min Repeat Gap set to 1, the Container will not select the same Sound twice in a row. The next shot must use a different sound, but the shot after that can use the first sound again.
Different Min Repeat Gap values affect the next shot as follows:
Min Repeat Gap
How the next sound is selected
0
No restriction; the sound that just played can be selected again
1
Exclude the previous shot's sound; choose from the other three
2
Exclude the last two shots' sounds; choose from the other two
3
Exclude the last three shots' sounds; only one sound remains
Set Min Repeat Gap to 3, select Weapon_Fire, and click the Play button at the top to audition one shot at a time. The sounds used for the last three shots are excluded, leaving only one of the four available.
Once all four sounds have played, they will keep repeating in the same order. For example, if the first four shots are 01→03→02→04, the next four will also be 01→03→02→04.
Restore Min Repeat Gap to 1.
A value of 1 works well here: it avoids immediate repeats without making the sequence sound predictable.
Select Weapon_Fire and find Discipline under Inspector → Basic → Selection.
For a Random Container, Discipline determines the random selection method: Draw or Shuffle.
Draw makes a new random selection each time you trigger playback. One sound may repeat before all the others have played. For example, the first four shots might be 01→03→01→02: 01 plays twice, while 04 has not played yet.
Shuffle first puts the four sounds in a random order, then plays one per trigger. After all four have played once, it reshuffles them for the next round. For example, one round might be 03→01→04→02, followed by 04→02→03→01.
1.6 Choose Whether Playback History Is Shared with Memory Scope#
A Random Container remembers which sounds it has selected so it can determine which ones to exclude next. When multiple emitters use the same Container, Memory Scope determines whether each emitter keeps its own playback history or they all share one.
Select Weapon_Fire and find Memory Scope under Inspector → Basic → Selection. Open the dropdown to see the two options: Per Emitter and Global.
Note:Play Type determines whether a trigger plays one sound or a group of sounds. Leave it at Single for now. Memory Scope is only shown when Play Type is set to Single. The next section compares the two playback types.
Consider two characters firing weapons. Characters A and B each have an Emitter that plays their own sounds, but both use the Weapon_Fire Container. Assume Min Repeat Gap is set to 1, so the same Sound cannot be selected twice in a row.
Character A has just played Weapon_Fire_01, and character B has not fired yet:
Per Emitter: each emitter keeps its own history. A's history only affects A, so A cannot select Weapon_Fire_01 for the next shot. B has no history yet and can still select Weapon_Fire_01.
Global: emitters using the same Container share a history. A's Weapon_Fire_01 is added to the shared history. Whether A or B fires next, that shot cannot immediately select Weapon_Fire_01 again.
Choose Per Emitter when each character should select sounds independently. Choose Global when you also want to prevent immediate repeats between different characters.
This tutorial uses only one preview emitter in Studio, so leave Memory Scope at Per Emitter.
Select Weapon_Fire in Explorer and find Play Type under Inspector → Basic → Selection.
Play Type determines whether clicking Play once plays a single sound or a group of sounds in succession.
Single: each click of the Play button at the top selects and plays one sound.
Queue: one click of the Play button at the top plays the group of sounds one after another.
The earlier auditions used Single. Next, listen to the difference between the two playback types.
Set Play Type to Queue.
Return to Explorer, select Weapon_Fire, and click the Play button at the top just once. You should hear all four gunshot sounds.
Select Weapon_Fire and find Loop under Inspector → Basic → Playback. Its default value is 1. Change Loop to 2.
Return to Explorer, select Weapon_Fire, and again click the Play button at the top just once. Listen for the difference: after all four sounds have played, the whole group plays a second time before stopping. A single click now plays two complete rounds of gunshots.
Play Type vs. Loop: With Play Type set to Queue, clicking Play once plays the entire group of sounds in succession. Loop determines how many times the group plays.
With Loop at 1, the group plays once. Set Loop to 2, and the same single click plays the group twice.
Restore Loop to 1.
Restore Play Type to Single. Leave Discipline at Draw, Min Repeat Gap at 1, and Memory Scope at Per Emitter, then press Ctrl+S to save.
The main gunshot layer provides the impact and tail, while the mechanical layer adds the detail of the weapon's moving parts. Keeping them separate lets you adjust each layer's random selection rules and level independently.
Download and extract the archive above, then drag the four mechanical sound effects onto the Container_Examples Layer.
In Explorer, select these four Sounds, right-click, choose New Parent → Container, and name it Weapon_Mech.
Under Inspector → Basic → Selection, set Min Repeat Gap to 1 for the Weapon_Mech Container.
Select Weapon_Mech in Explorer and click the Play button at the top a few times to audition it.
When you have finished auditioning, press Ctrl+S to save the project.
Do not put the gunshot and mechanical Sounds into a single Random Container. Each trigger would select only one sound, so you would hear either the gunshot or the mechanical detail, rather than both layers together.
Playing Weapon_Fire alone gives you the main gunshot layer; playing Weapon_Mech alone gives you the mechanical detail. To hear both together, create an Action with two Play steps. Playing this Action will then start both layers.
Right-click Weapon_Fire in Explorer and choose New Action → Play. An Action named Play_Weapon_Fire is created automatically.
Select this Action and check its existing Play step under Inspector → Basic → Step. Target points to Weapon_Fire; leave Delay at 0 s.
Click + at the bottom of the Step table and choose Play.
The Step table now contains two Play steps. Keep Play_Weapon_Fire displayed in Inspector. In Explorer, click and hold Weapon_Mech, then drag it into the second row's Target reference field and release. Check that Target shows Weapon_Mech, leave Delay at 0 s, and press Ctrl+S to save.
Select Play_Weapon_Fire in Explorer and click the Play button at the top a few times to audition it. If you only hear one layer, check the Target of each Play step and make sure it points to the correct object.
Target specifies which object a step plays. The two rows point to Weapon_Fire and Weapon_Mech respectively, so the gunshot and mechanical layers each select a sound at random.
Delay is the time between the playback trigger and the start of a step, measured in seconds. With both rows set to 0 s, they start together; the second row does not wait for the first to finish.
A Random Container chooses what to play from a set of sound variations. In this chapter, one container holds four gunshot sounds, so triggering the same firing action can produce different sounds.
Selection probability: To hear one variation less often, give it a lower Weight than the others. This changes how likely it is to play, not its volume.
Repeat spacing: To avoid hearing the same sound on two shots in a row, set Min Repeat Gap to 1. At least one other shot must play before that sound can be selected again.
Selection method: Use Draw for a fresh random pick each time. Use Shuffle to play each sound once before reshuffling for the next round.
Sounds per trigger: Choose Single to play one gunshot per trigger, or Queue to play a group of sounds in succession from a single trigger.
Playback history: When several characters use the same container, Memory Scope determines whether each emitter keeps its own playback history or they all share one.
Layered playback: Put the main gunshot and the mechanical detail in separate Random Containers to adjust each layer’s selection rules and volume independently. Trigger both layers together with one Action.