nanoMMO

MMORPG skill and gate sounds made from code in C++

Each skill in our C++ MMORPG gets a sound made from the fx it already lists, from a whoosh of the blade to thunder, and each land a chord for when we arrive.

Watch on YouTube

Our MMORPG's skills get their sounds, made by the raylib client from numbers, without a single sound file. Each kind of fx a skill lists, from a trail to lightning, has a sound of its own, built from noise, tones and filters, with a cold colour ringing higher than a warm one, so a new skill built from them comes with its sound. Going through a gate rises two octaves as the world fades, and each land greets us with a chord: major, minor or diminished. This is episode 56 of a series about building an MMORPG from scratch in C++, with the focus on the engineering around the game.

Topics: Sound

The code

Each step on screen is a tag in the game's repository. The code at the end of the episode is ep056/end.

  1. 1:40ep056/step-1A sound for each fxBrowseChanges
  2. 26:13ep056/step-2GatesBrowseChanges

Transcript

Intro

0:00 Hello, and welcome back to episode fifty-six, where we're going to give the skills their sounds, made from the fx they already list, and give the gates a sound of their own. Let's begin with a listen to what the game sounds like once we're done.

0:14 By the end of the episode, each swing and each skill makes a sound, built from the fx we see. The lightning buzzes, and the thunder rolls after it.

0:27 You'll find more about the project on its website. Our code is open source, with its GitHub repository linked from there, and there's a page for each episode, with the code at each of its steps.

Last time

0:38 Now, before the skills get their sounds, let's quickly go over what we did last time. The client got a small synthesizer: seeded noise, a state variable filter that can sweep, sine waves that glide, and envelopes, with a tool to listen to what it makes. From those, it makes a step for each kind of ground, from grass to water, a few takes of each. In the game, a step plays when the walk puts a foot down, louder nearby, from the side the walker is on, and not the take that played last. And the settings got an Effects slider, for how loud the effects are.

Today

1:14 Today, we're going to put the synthesizer to work on the skills and the gates. Each kind of fx a skill lists gets a sound of its own, so a skill sounds like what we see, and a new skill built from those fx sounds right from the start. Then the game plays each cast, from where the caster stands, and going through a gate gets a rush up, and a chord for the land we come out in. All right, let's get started, with a sound for each kind of fx.

A sound for each fx

1:41 Each kind of fx our skills list is going to get a sound of its own, made from the synth's noise, filter, sine waves and envelopes. A skill plays several of those at once, so the synth needs one more function first. In its header file, we declare limit, which rounds off the loudest parts, so that a mix doesn't go past one, where the speaker can't follow it, and it crackles. In the synth, limit goes through the samples, and puts each one through the hyperbolic tangent. For small values, the hyperbolic tangent gives back almost what it's given, so zero point two comes out at about zero point two. As they grow, it bends over towards one without reaching it: one comes out at zero point seven six, and two at zero point nine six. So when several fx land together and their sum goes past one, the peaks are rounded off smoothly. Without it, anything past one would be cut flat on its way to the speaker, and those flat tops, with a sharp corner at each end, are what we hear as crackle. In foley's header file, we include the header that protobuf generates from our skills proto, for a skill's look and its fx, as each sound is made from what the skills file already lists. Coldness says how cold an fx's colour is, from minus one for red to one for blue: a cold one rings higher, and a warm one lower. Then comes the sound of one of a skill's fx, from when it starts, made from a seed, as the steps are. And the sound of a whole skill, which is what the game plays, takes whether the caster has a monster picked. It holds all the sounds of a skill's fx, each at its time: those at the target with a monster picked, as the fx are drawn. Now in foley, where the sounds are made, we include algorithm, for clamp, min and max, array, for short lists whose length is fixed, and numbers, for pi, as in the synth. The new helpers go in the unnamed namespace, starting with pi, as a float. Swell is a shape over a sound, where t goes from zero at its start to one at its end. It goes up from nothing to its top at peak, a share of the way through, and back down to nothing at one. Before the peak, it's the first quarter of a sine wave, which climbs from zero to one, and after it, a quarter of a cosine, which comes back down from one to zero. Then we square it, with the max keeping it at zero past the end, where the cosine would turn negative. Squared, the curve stays near nothing for longer at each end, and puts its loudness around the peak, so a sound shaped by it seems to come in from a distance and go past. Whoosh takes the noise, how long it lasts, the two frequencies it moves between, and where its peak is. It's air pushed aside: noise in a band that moves from one frequency towards the other as it swells, and back as it fades. A blade swung past your ear sounds brighter and louder as it comes closest, and duller as it goes away, and moving the band with the loudness gives us that. Its q is one point four, a fairly wide band, so it hisses like air, without settling on a pitch. For each sample, we take the swell at that share of the way through, and move the band by it, by ratio, as the tone glides, so at the top of the swell, it's at the other frequency. The noise goes through the filter, and we keep the band, divided by its q, as we did for the steps' bands, and scaled by the swell. Level gives the peak that a sound is normalised to at the end, from the kind of fx it's for. So it's how loud the loudest moment of each kind of fx is: the light's chord stays under the rest, and the shake's boom and the bolt are the loudest. It switches on the kind, and a held note sounds louder than a crack that peaks as high, as it stays up there for its whole length. Cases stacked on each other share the line under them, so the glow and the motes, which are notes, get zero point two. Shards get zero point three five, and sparks zero point four five. The trail, the ring, the spikes and the wave get a half, and the bolt and the shake get zero point seven. Much of their sound is low, and our ears are far less sensitive down there, so a boom needs a higher peak to sound as loud as a ping. The default is for any number the enum doesn't name, as a proto enum can hold those too. Coldness reads the fx's colour, which the skills file holds as a byte each of red, green, blue and alpha, in that order. Shifted right by twenty-four bits, red is the lowest byte, a bitwise and with hex f f keeps that byte and nothing above it, and over two hundred and fifty-five, it runs from zero to one. Blue sits two bytes lower, so it's shifted by eight. Cold is blue less red, so pure blue is one, pure red is minus one, and white or green, with as much red as blue, is zero. So fire comes out warm, and ice and lightning cold, the way we'd already think of their colours. Now the sound of one fx, which starts with noise from its seed, so a take made again comes out as it was. The span is how long the fx lasts, in seconds, and its size is in metres, with a missing one, which proto reads as zero, counted as a metre. Then how cold its colour is, which gives the fx a note: two hundred and twenty hertz, the A below middle C, times two to the power of the coldness. Going up an octave doubles a frequency, so a blue fx is an octave higher, and a red one an octave lower, from a hundred and ten hertz for red to four hundred and forty for blue. The count is how many sparks, motes, shards or spikes it throws, and twelve when it doesn't say. Then we switch on its kind, and each kind gets a recipe of its own, built from what we see it do. A trail is the ribbon behind the blade, so it gets a whoosh, a tenth of a second longer than the fx, as the ribbon lingers. Its band sweeps from three hundred hertz up to two thousand, at its loudest forty percent of the way through, and back down. That's the blade cutting the air, and a long trail, like Whirlwind's spin, makes a long whoosh, while a quick thrust makes a short one. Here's Whirlwind's long whoosh, and then Thrust's short one. A glow is a ball of light, which makes no sound of its own, so it gets something soft that sits under the rest. Its case gets braces, as it declares variables, and C++ won't let the next case jump past their initialisation. Its sound is half a second longer than the light, to ring out: a chord that swells and fades with the light, the note, its fifth and its octave, each played twice a little apart, so that they beat. That's six voices, each an oscillator, as each keeps its own phase. Their ratios to the note are constexpr, worked out as the code compiles. A fifth is one and a half times the note, the interval that blends best after the octave, which is twice it. Leaving out the third, which would make the chord major or minor, gives one that's neither happy nor sad, so it fits any skill. Each voice has a twin a few thousandths higher. Two sines that close drift in and out of step, so their sum swells and fades at the difference between them, and that's called beating. Four thousandths of two hundred and twenty hertz is under one a second, so the chord shimmers slowly, like two strings a little out of tune. For each sample, we add up the six voices, and shape the chord with an envelope that rises over forty percent of the light's span, and falls away at that pace, as the light grows and dims. Then we fade out its last few milliseconds, so the cut doesn't click. Second Wind's green glow, which lasts a little over a second, sounds like this. A ring is a wave along the ground, spreading out to its size. Its low note is eighty hertz over the square root of its size, clamped between thirty-five and ninety hertz. A bigger drum booms lower, and so does a bigger ring, so Kick's ring of one point six metres sits at about sixty hertz, and Earthsplitter's four metres at forty. So it's a thump, deeper for a bigger ring, and air rushing out along the ground. The thump is a tone that falls an octave, from twice the low note down to it. A sine whose pitch drops fast is how drum machines make their kick drums, and it reads as a hit with some weight behind it. The rush lasts as long as the ring. For each sample, t is its time in seconds. Over the span, the band of noise falls from two and a half thousand hertz to three hundred, as the ring spreads away from us, and sounds further away are duller. Its envelope scales with the span: up over the first twentieth of it, then down by two thirds each thirty-five hundredths of it. And it goes into the sound at a half, under the thump. Kick's small ring gives a short thump, and Earthsplitter's big one booms lower. Sparks fly out and fall, and short bursts of noise are the obvious way to make them. However, a few dozen bursts at once hiss like static on an old TV, so ours are built from tones, which ring instead. There are up to twenty-four, each spark a bright ping, high and short, like metal on metal, most of them as they fly off. A partial is one of the sine waves a sound is made of, and two partials that aren't whole multiples of each other ring like metal, where one alone would whistle. A ping comes somewhere in the first sixty percent of the span. The product of two random numbers between zero and one leans towards zero, so most of them come early, as the sparks burst out. Each is between two and a half and five thousand hertz, dies away over ten to thirty milliseconds, and gets a loudness of its own. Its first partial is a tone that sags by three percent as it fades. A string or a voice has its partials at whole multiples of the lowest, which our ear hears as a single pitch. A struck bar of metal has its second partial at about two point seven six times its first, as in a glockenspiel, so that's where the second tone goes, quieter, and dying away twice as fast. Some sparks fly off the monster we picked, and where they fly off someone, a blow landed: a low note that drops fast, like a drum. It falls from a hundred and sixty hertz to fifty, and goes in at three times a ping's top gain, so the thud of the hit leads, with the pings over it. Here are Strike's sparks, flying off a monster it hits. Motes are specks of light, rising and swirling, so they get notes, a bit like wind chimes. The scale holds the major pentatonic, as ratios to the note: one, nine eighths, five quarters, three halves, five thirds, and two, the octave. It has no two notes a semitone apart, which is where clashes come from, so any of them can ring together, and random picks from it sound pleasant. So, a note for each speck, from a scale without clashing notes, two octaves above the colour's, and rising as they do. There are up to thirty-two notes, each four times the fx's note, which is two octaves up, times a step picked at random. Five point nine nine keeps the index under six, inside the array. They come over the first eighty percent of the span. A random number to the power of zero point seven leans towards one, so they come a little thicker later on. Each is a soft tone that rises by three percent as it fades, like the speck it goes with. Second Wind's forty green motes ring out like this. A shake moves the camera, as if the ground jumped under us. So its boom is a tone falling from sixty hertz to thirty-two, down among a piano's lowest notes, and lasting a little longer than the shake. It's felt as much as heard: a boom below the notes, and a rumble. The rumble is noise under a hundred hertz, dying away over half the shake. Laptop speakers barely play this low, while on headphones it gives a slam its weight. Here's Earthsplitter's shake, which is best heard through a pair of headphones. Shards are pieces thrown up from where a skill lands. They start with a click, a crack as the ground breaks, and then the pieces coming back down: ice rings like glass, and earth knocks. For each piece, up to thirty-two of them, we pick when it lands. That's somewhere between forty and ninety-five percent of the way through, around when the ones on screen come down. A colour with clearly more blue than red is ice, and each piece is a high tone, between two and a half and six thousand hertz, which holds its pitch and rings for a few dozen milliseconds, like glass. Anything warmer is earth, a knock between four and nine hundred hertz, which sags by nearly a third and is gone in fifteen milliseconds, as a clod on hard ground doesn't ring. Earthsplitter throws up twenty-four pieces of earth, which come down like this. Spikes come out of the ground in a ring that spreads out, and they're built from tones too, for the reason the sparks are. Under them, a deep tone sinks from fifty-five hertz to forty, swelling in over the first fifteen percent of the span. The ground heaves, with a rumble below the notes, and bursts open spike by spike as the ring goes out: each a thunk, a low note that drops fast, and a short knock above it. And ice rings like glass, too, as it did for the shards. The rumble is noise under ninety hertz, which swells and fades with the tone. There are up to twenty-four spikes, spread evenly over the first thirty-five percent of the span, each nudged by up to twenty milliseconds. The fx brings them up that way, the nearest first and the furthest a third of the way through, so the sound spreads with the ring. Each spike is a thunk, from a hundred and fifty to two hundred and twenty hertz, which falls towards a third of its pitch and is mostly gone in a few dozen milliseconds. On top of it goes a knock, from seven hundred to twelve hundred hertz, over in eight milliseconds, the snap of the ground as it breaks. Frost Nova's spikes are cold, so each gets a glassy ring on top as well, between two and four thousand hertz, ringing for longer than a shard's, and quieter. Earthsplitter's spikes come up first, and then Frost Nova's, with their glassy ring. A bolt is lightning, which Stormcaller calls down twice. It starts with the click, and its sound is a crack, the buzz of the bolt, which jumps from one pitch to another, and thunder rolling after it. The buzz lasts as long as the bolt, and goes through two filters, a high pass and a low pass, which we'll come to. It keeps its own phase, its pitch and its level, and a count of samples until its next jump. When the count runs out, the next jump is eight to twenty-five milliseconds away, the pitch jumps somewhere between fifty and a hundred and sixty hertz, and the level somewhere between zero point three and one. Mains hum is fifty or sixty hertz, so that range sounds electric, and the jumps make it flicker, like the bolt on screen, which finds a new path each flicker. The phase moves on by a share of a turn, as in the oscillator, and wraps round at one. Instead of a sine, we use the phase as it is: twice it, less one, climbs from minus one to one and drops back each turn, which is a sawtooth wave. A sine is a single partial, while a sawtooth has all the whole multiples, each quieter than the last, and that's what makes it buzz. So the raw sound is a sawtooth, which is rich in overtones, and some noise, between four hundred hertz and five thousand. The high pass takes out what's under four hundred hertz, the buzz's lowest partials, which leaves the low end to the thunder, while the overtones above keep the buzz. The low pass takes the harshest part off the top. It comes in over three milliseconds and dies away over most of the bolt. The buzz goes in at a half, and the thunder is noise under a hundred and twenty hertz, for over a second and a half. It comes in thirty milliseconds after the crack, which is how long sound takes to cover ten metres, and at a gain of one point six, the highest in the bolt, it rolls on after the bolt has gone. So Stormcaller's bolt cracks, buzzes and rolls on like this. A wave is the crescent of fire that Searing Arc throws, and its roar lasts a fifth of a second longer than the crescent. Its sound is fire roaring past, and popping. The roar gets a filter of its own, and for each sample, it swells to its top thirty percent of the way through. It's noise through a low pass that opens from four hundred hertz to two thousand as it swells, so it's brighter as it gets louder, like a fire caught by a gust. The roar goes in at one point two, and the pops are a crackle, about sixty clicks a second at its top, each ringing around fifteen hundred hertz, the way burning wood spits. And here's the roar of Searing Arc's fiery crescent. A kind without a recipe is left silent, and last, each sound is normalised to its kind's level, so how loud it is comes from its kind, whatever its count or its size. Then comes the sound of a whole skill, from all its fx. We go through the skill's fx, and one at the target is left out when no monster is picked, as the fx leave it out on screen. So a swing at nothing makes a whoosh, without the sparks and the thud of a blow that didn't land. For each of the others, we make its sound with a seed of its own, the skill's seed times thirty-one, plus the fx's index, so two sparks in one skill don't share their noise. We mix it in at the moment the fx starts, in seconds, so each sound starts with the fx we see. Then the limit rounds off whatever piles up past one, as in Earthsplitter, whose ring, spikes, shards, sparks and shake all start at eight hundred and eighty milliseconds. So a skill we add to the skills file, made of fx we already have, comes with its sound. Here's all of Earthsplitter at once, its trail, ring, spikes, shards, sparks and shake.

19:23 Each skill has a sound now, so the game needs to know when a player starts one. In the soundscape's header file, we include utility, for the pair. A small class, casts, watches the figures for that, a frame at a time. Which players started a skill since the last update: another skill, or the one before again, as their time in it starts over. That second case is Strike, swung again and again. It stays one skill, but the animator starts it over at each new cast, so the time goes back to zero. It does that for a figure it sees for the first time too, so a player who walks into view mid-skill is heard from the start, in step with what we see. Update takes the figures the renderer animates, and gives back the players who started one, with where each stands, to hear it from. Between updates, the class keeps a map: each player's skill, and their time in it, by their id. The players' ids are enough here, as monsters and NPCs, which count their ids from one as well, stay out of it. In the soundscape, update makes a single pass over the figures, once a frame. It starts with an empty list, for the casts that started, and a new map of who's in a skill, as of this update. Monsters and NPCs use no skills, and a player in any other motion isn't casting, so they're all skipped. A player in a skill goes into the new map, with the skill's id and their time in it. Then we look for them in the map from the last update. A cast is fresh when they weren't in a skill last time, when the skill is another one, or when their time in it went back. That's how the fx tell one cast from the next, so the sound and the fx agree on when a cast begins. Each fresh cast goes on the list, with its figure, so we know where the caster stands. Last, the new map is moved into the old one's place. A player who stopped casting isn't in it, so their next skill counts as fresh, whichever it is. In the soundboard's header file, we include cstdint, for the skills' ids, utility, for a pair, and the skills' header from our content, for the skill table. Takes of each step, and of each skill: three takes of each skill, where steps get eight. We hear a skill far less often than a step, and its sound runs one to three seconds, where a step is over in a fraction of one. The constructor takes the skill table too, to make each skill's sound from its fx. The style guide asks for explicit on a constructor that takes a single argument, so with two, it goes. Then skill, to play one of them: the skill's sound, by the skill's id, with the fx at the target if a monster was picked. So, as in foley, Strike swung at the air is a whoosh without a hit, as its fx show none. The skills' takes are kept by a pair: by the skill's id, and whether a monster was picked. A map orders pairs by their first value, then their second, so a pair works as its key with nothing more to write. And a single variety picks the takes for all the skills. In the soundboard, steps vary more than skills, as we hear far more of them. A skill's pitch moves by up to four percent either way, half as far as a step's, and it's up to a tenth quieter, where a step can lose almost a third. A step we hear over a hundred times a minute needs a lot of variety before the repeats stop standing out. A skill's sound is part of how we tell which skill it was, so it stays nearer to how it was made. The constructor sets up the skills' variety with a seed of one, in its initialiser list, as a variety has no default constructor to fall back on. Then it goes through the skills, by id. A skill without fx would have nothing to make a sound from, so it's skipped, and stays silent. The others are made twice, without a target and with one. A range for over a braced list goes through the values in it, here false, then true. Each way gets its three takes, kept under the pair of the skill's id and the target, which the braces build. A take is the skill's sound with a seed of its own, from one to three, with or without the fx at the target. A skill with none there, such as Earthsplitter, comes out alike both ways. Each take loads as a clip on two voices. Voices let a take start again while it's still ringing, and as the variety picks another take each time, two are enough, where the steps have four. Skill gets the target as well as the skill's id, and finds the takes under that pair. When there are any, play picks the next take with the skills' variety, as it does for a step. In the client's main, the soundboard now makes the steps and the skills, as the game starts, and the casts sit next to the footsteps. The soundboard is made with the content's skills, which main has read already. Each frame, once the steps are played, the casts look at the figures the renderer animates. For each new cast, the soundboard plays its skill's sound, with the target's fx when the caster has a monster picked. It's heard from where the caster stands, the way a step is. Our own casts are right where we stand, so they play at full volume, from both sides. In our tool, we include the characters' header, for the content folder's path, and the content, to read the skills from. The entries take the skill table now, and after the grounds, each skill gets an entry under its name, in the order of their ids. We copy out the skill's look, the client's part of it, with its fx, and the entry's lambda keeps that copy, under the skill's name. As cast at a monster, so that its fx at the target sound too: in the tool, we want to hear all of each skill. So the lambda makes the skill's sound from its copy, with the target set to true, and with the seed it's given, so each press of Space makes a new take. In main, the tool first reads the content, as the game does, and stops with the reason if it can't. The entries come from its skills, so let's build the tool, and listen to them.

25:20 In our tool, the skills come after the grounds now, each made from its fx. Strike, on Space, is a whoosh of the blade, then the hit. Earthsplitter slams the ground, which rumbles and breaks open. Frost Nova's colours are cold, so its notes are high, and its spikes ring like ice. Searing Arc roars out, like the fire it throws. And Stormcaller buzzes twice, and the thunder rolls after it.

25:56 In the game, each swing plays Strike's sound, from where arthur stands, while the skeletons step around us. The skills sound like their fx, at the moment each fx starts.

Gates

26:13 Last come the gates, and going through one, I'd like a sound that rises as the screen covers the world, and a chord from the land we come out in. In foley's header file, how a land sounds: what each of its surfaces is underfoot, and the chord that greets a player who comes into it, in hertz. A chord is a few notes played together, and ours have three, each a frequency, the number of times a second its wave goes round. In Western music, an octave is split into twelve semitones, each about six percent higher than the one below. In the order of the lands: first the Meadows, where we start, in C major. A major chord is a note, the one four semitones up, and the one seven up. Their frequencies sit at about four, five and six to each other, so their waves line up often, and the chord sounds bright and at rest. The Ashlands, through one of the Meadows' two gates, are in A minor. A minor chord lowers the middle note by a semitone, which sounds darker. And the Crypt is on a diminished chord, which doesn't settle. A diminished chord stacks two gaps of three semitones, so its outer notes are six apart, which our ears hear as tense, wanting to move on. The Meadows' C major is an octave above middle C, from five hundred and twenty-three hertz up, so it's bright. The Ashlands' A minor starts at two hundred and twenty hertz, more than an octave lower. And the Crypt's is the lowest, on G, B flat and D flat. Then departure, for going through a gate: a rush up, as the screen covers the world. And arrival, for coming out into a land: its chord, struck like bells. It takes the land, not a seed, so a land sounds alike each time we arrive in it. In foley, after the skills' sounds, the bells go in an unnamed namespace, as nothing outside foley needs them. Like the sparks' pings, a bell is made of partials, and a small struct describes each of them. The partials of a struck metal bar, as a glockenspiel's: their frequencies over the note's, how loud each is, and how long each rings. They aren't whole multiples, which is why it shimmers where a string doesn't. A string's partials line up again on each cycle, while a bar's don't, so its wave doesn't quite repeat, and that shimmer over the note is what makes it sound like metal. So a partial has its ratio to the note, its gain, and its decay, in seconds. Our bell has five of them, and the note is at full gain, losing about two thirds of its loudness each one point two seconds. The octave comes in at half, and then the bar's own, at two point seven six, five point four and eight point nine three times the note, each quieter and shorter than the last. The high partials die away first, so the bell starts bright, and mellows as it rings. Bell makes one, for so many seconds, at a note. For each partial, it mixes in a tone that starts and ends at the partial's frequency, so it holds its pitch. Its attack is two milliseconds, as a bell is struck, and its decay is the partial's. All of them go in at the start, each at its partial's gain. Now the departure, with noise from its seed, and a length of one second. It has three oscillators, as voices, a filter for the air, and the phase of a wobble, in turns. For each sample, t is how far through we are, from zero to one. The note starts at a hundred and sixty hertz, and two to the power of two t takes it to six hundred and forty by the end. A power of two climbs by an equal ratio each moment, which our ears hear as a steady climb in pitch. The note goes two octaves up, wobbling faster and faster. The wobble goes four times a second at the start, and eighteen by the end. We add its rate to its phase each sample, as the oscillator does, so the rate can change without the wobble jumping. Tremolo is the musicians' word for a wobble in loudness, and ours is a sine of that phase, which swings the loudness between zero point four and one. The tone is two voices on the note, one of them seven tenths of a percent sharp, and a third at half volume, a fifth above, at one and a half times the note. Like the glow's twins, the two voices on the note beat, from about once a second to four and a half times by the end, which makes the pair sound thick, like a chorus. The air is white noise through the filter's band, which climbs four octaves, from three hundred hertz to nearly five thousand. It's divided by the q, to keep it at a steady loudness, as the steps' hiss does, and it sounds like air rushing past faster and faster. Rise is t squared, so the sound starts from nothing and builds slowly, then quickly near the end, as a swell. Past eighty-five percent of the way, fall brings it down by about two thirds in each fifty milliseconds, so the rush ends in a quick drop, without a cut. Each sample is the wobbling tone under the air, both shaped by the rise and the fall. Then it fades out, and normalize brings its loudest moment to zero point five five. Going through a gate, then, sounds like this. The arrival looks up the land's sound, and starts an empty mix. The chord's notes are struck one after the other, low to high, over the root an octave down. Each note is a bell three seconds long, sixty milliseconds after the one below it, the way a guitar strums a chord. Spread out like that, each bell is heard starting on its own, before the three ring together. Under the bells, the root an octave down, at half its frequency, is a plain tone of two seconds, which swells in over a hundred and fifty milliseconds. The noise is seeded by the land, for a whoosh of air, which falls from five thousand hertz to eight hundred as it swells. It picks up near where the departure's air left off, and brings it back down. Normalize brings the arrival to the departure's level. Here are the three lands: the Meadows' bright C major, the Ashlands' darker A minor, and the Crypt's tense chord. In the soundscape's header file, a class decides when those two play. When a gate's sounds play, from the loading screen. The departure plays as its cover goes up over the world we were in, and the arrival as it lifts off the land we came to, which is also how we enter the world. Its update gives a cue, like the jukebox does for the music: nothing, the departure or the arrival. It takes whether the loading screen's cover is up, or going up, and whether we're in a world that's built. And it keeps both of them from the last frame. In the soundscape, the passage's update starts from no cue at all. The departure plays when the cover starts going up, and we were in the world the frame before. On the frame a gate takes us, our world is already the new land's, which isn't built yet, so in world is false, and it's the last frame's that tells us we were in one. The arrival plays when the cover starts to lift, and we're in the world now. Then both are kept for the next frame. Logging in, the cover goes up before we're in any world, so there's no departure, and the arrival plays as it lifts. In the soundboard's header file, departure plays the gate's rush, and arrival plays a land's chord: into the land, by its place in the lands. The board keeps a clip of the departure, and one arrival for each land. In the soundboard, we include cstddef, for size t. The constructor makes the departure with a seed of one, as a clip on a single voice, as we go through one gate at a time. Inside the soundboard, departure names its own method, so the function from foley gets nanommo's namespace in front, as step does. Then it makes an arrival for each land, on a single voice too. Departure plays at the effects' volume, in the middle, at its own pitch. It's our own passage, without a place in the world to come from, so it doesn't go through hear, the way a step does. Arrival checks that the land is one we made a clip for, and plays it, in the middle too. In the client's main, the soundboard now makes the steps, the skills and the gates as the game starts, and a passage sits next to the casts. Each frame, after the music, the passage gets whether the loading screen covers the world, and whether we're in it. On a departure, the soundboard plays it, and on an arrival, it plays the chord of the land we've just built. When there's no cue, which is most frames, it plays nothing. In our tool, we include the lands' header, for their names. After the skills comes going through a gate, with a new take for each seed. Then, for each of the three lands, comes an entry for arriving in it, under the land's name from the lands' header. Its lambda keeps the land, and its seed has no name, as an arrival doesn't take one. An unnamed parameter is how C++ says it goes unused. So, let's go and listen to them in the game.

35:09 As we log in, the Meadows greet us with their chord, and the gate into the Ashlands is ten metres to the north. In the Ashlands, the chord is minor, and lower. Here, the steps crunch on ash, and back through their gate, the Meadows come back in major.

Wrap-up

35:34 So, today, each kind of fx got a sound of its own, from a whoosh to thunder, where a cold colour rings higher than a warm one, and a skill's sound is its fx's sounds at their times. In the game, each new cast plays a take of its skill's sound, with the target's fx when a monster is picked, as they're drawn. Going through a gate rises two octaves, and each land greets us with a chord of its own, major, minor or diminished.

Playing it

36:45 Tell me in the comments which sound you'd like to hear next, or anything else you'd like to see. And if you want to follow along with the series, subscribe to the channel. I hope you find this useful, and thanks for watching.