nanoMMO

Weather effects and ambient sound in a C++ MMORPG

Our C++ MMORPG's film tool shoots the weather over a player's shoulder, while fire falls on the lava, fireflies come out after dusk and the rain, the thunder and the crickets get their sound, first made from numbers and then, for the rain and the fire, recorded.

Watch on YouTube

Fire rain, snow, fireflies and the sound of the weather in our MMORPG, in C++ with raylib. The film tool gets the sky the server would send and a camera over a player's shoulder, and films thirteen quiet shots of the lands. Rain turns to snow above the snow line, ash and fire fall over the Ashlands' lava, the fire glowing past white so it blooms, and fireflies, wisps and lava sparks live in cells of the ground, so they stay put as the camera moves. The weather's sound is made from numbers, in loops folded so they go round without a seam and fed to an audio stream a buffer at a time, with thunder that comes after the flash at the speed of sound. The rain made from numbers sounded like glass beads, so the rain and the fire become recordings, kept out of git. This is episode 86 of a series about building an MMORPG from scratch in C++, with the focus on the engineering around the game.

Topics: Graphics, Sound

The code

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

  1. 1:49ep086/step-1A sky for a filmBrowseChanges
  2. 15:26ep086/step-2Snow, ash and fireBrowseChanges
  3. 23:44ep086/step-3What glowsBrowseChanges
  4. 30:20ep086/step-4Sound from numbersBrowseChanges
  5. 54:38ep086/step-5Real recordingsBrowseChanges

Transcript

Intro

0:17 Hi, and welcome to episode eighty-six, the second of our two weather episodes, where fire falls on the Ashlands, fireflies come out over the Meadows after dusk, and all of it gets its sound. The crickets you just heard are made from numbers by the game as it starts, while the rain and the fire are recordings.

0:34 The game is open source, and its code is on GitHub, linked from the series' website, which has a page for each episode, with its code at each of its steps.

Last time

0:42 Last time, the server started working out each land's sky from the wall clock alone, the time of day, the weather and the wind, so each server that runs a land agrees, and there's nothing to save. The client blends each land's day into a dawn, a dusk and a night, with the sun going round and stars coming out. The settings' Sky page went, leaving a switch for day and night and one for the weather. Rain falls in the Meadows, each drop worked out from the clock, and the ground gets wet, and a storm throws lightning that lights up the sky for a moment.

Today

1:12 So, today, the film tool gets the sky the server would send, and a camera that looks over a player's shoulder. Above the snow line, the rain turns to snow, and the Ashlands get ash and fire falling from the sky. Then what glows in the dark, with fireflies over the Meadows, wisps in the Crypt and sparks off the lava. The weather gets its sound, made from numbers like our footsteps in episode fifty-five, with thunder that comes after its flash. For the rain and the fire, we then play recordings, as the rain made from numbers didn't sound like rain to me. And along the way, we film the quiet shots you saw at the start.

A sky for a film

1:50 First, the top CMake file takes the game's version to zero point eighty-six, for this episode's code. A film has no server to send it a sky, so in the film's proto file, a shot's sky gets fields to say what the server would. Day is the time of day the shot starts at, from nought at midnight to nought point seven five at sunset. It's optional, so a shot that sets neither a time of day nor a weather keeps its land's own look, as the trailer's shots do. Days is how fast the day goes by, in days a second of the film, so one sixtieth is a whole day in a minute, for a time-lapse. The weather goes by its name, rain or storm or fire, as a string, so a shot reads well in its text file. Strength is how much of it there is as the shot starts, and strength to is how much as it ends, for rain that stops in the middle of a shot. Wetness starts the ground wet, still soaked after the rain, say, instead of as dry as the weather would leave it. And the wind, in metres a second along x and z, which a shot can leave to a light breeze, or to the gale a storm brings. Then a camera of a new kind, the shoulder. It's behind a player and a little above, looking past them at something far off, for someone who stands and watches the rain. Player is whom we look over, by their id in the shot, and they turn to face what we look at. Look is that point, far off, which they're watching. Back and back end are how far behind them the camera is as the shot starts and as it ends, which is the drift. Up is its height above their feet, and side moves it to their right, or to their left when it's below zero. Then its lens, in degrees from top to bottom, with a wider one for a tall picture, as a short's frame is narrow. Keeping all of this in the shot's text file means a new shot is a few lines and no code. A shot gets its shoulder, and the game's music under it. Music is how loud, from nought, which is none, to one, as loud as the game plays it at full volume, and the weather's shots use about a third. And music from is how far into the track it starts, in seconds. Last, the film as a whole says whether it wants cel shading's bands and outlines. A player can turn those on in the settings, but the game starts without them, so a film does too, unless it asks. I think a short that looks like nothing you'd see in the game would be selling something else. The trailer keeps its cartoon look, though, so at the top of its file, it asks for the bands of light and the outlines.

4:21 In film, which reads a shot from its text file and checks it before anything is drawn, a shot needs a camera of some kind: keys, an orbit, or now a shoulder. The error for a shot without any of them names all three. And a shoulder has to name a player the shot has, or reading the film fails, with an error that names the shot. None of goes through the shot's players, with a lambda that compares each one's id with the shoulder's player. That's a lot better than a camera that quietly looks over nobody's shoulder at the middle of the land. Further down, in an unnamed namespace, watcher finds that player in the shot by their id, or gives a null pointer. Over shoulder works the camera out from how far through the shot we are, as a share from nought to one, whether the picture is tall, and the land's terrain. It starts from the player's feet, where the shot places them on the ground, and the point we look at. Forward is the way from the feet to that point, flat along the ground, as a unit vector. Right is forward turned a quarter of the way round, which is their right as they face what they watch. Back goes from the start's distance to the end's along the shot, with raylib's lerp, which is the slow drift in that you can see here. The eye is that far behind the feet, moved out to the side, and up by the shoulder's height. The lens is the tall one for a tall picture, when the shot has one, then the shot's, then our usual one, and lens makes a raylib camera from the eye, the point and the angle. Camera at goes over the shoulder when a shot has one, with the shot's easing on the share, so the drift can set off and stop gently. Last, on the stage, a player who stands still and is the one we look over turns to face the point. Their yaw is atan two of the way there, and a spot on the stage keeps the ground's z in its y, which is why the second one reads at y. So they look where we look, and we see the back of their head, as you would standing behind a friend.

6:16 Now the renderer, which since last episode works its atmosphere out again each frame, from the sky the server sent. So a film can't set the fog once at the start and expect it to stay. In the renderer's header file, we bring in functional, for std function. The film's old way in to the atmosphere goes, and in its place, set adjust takes a function that changes the atmosphere each frame, after the time of day and the weather have had their say. That's how a film's own fog, sun or light goes on top. Atmosphere gives the atmosphere as the last frame drew it, to read, and weather hands out what falls from the sky and the lightning, whose bolts the thunder is going to follow, later in the episode. The renderer keeps the adjust, next to the sky and what's showing. In the renderer, animate used to work the atmosphere out when the server had sent a sky, and leave it alone otherwise. Now, without a sky, it starts from the land's own look, and with one, from the atmosphere under that sky. So a film without a time of day still gets a fresh atmosphere each frame. The wetness and the lightning's flash go in either way, now that there's always an atmosphere to put them in. Then, if there's an adjust, it changes what we've got, last. In the weather's header file, two setters come in, for the films. Set seed decides where the lightning strikes and how often, so a film's bolts strike where they did the last time it was filmed. And set wetness soaks the ground from the first frame, for a film that begins after the rain. The seed starts at one, for the game, and in the weather, each bolt's hash takes the seed along with the count of bolts struck so far.

7:56 Now the film tool's main file, where each shot is filmed. Its usage gets two new commands, peaks and shores, which we'll come to at the end. We bring in array, functional and optional from the standard library, our audio header, for where the music is, and daylight, for what's showing. In the options, cel becomes an optional, which holds a value or nothing. Before, cel shading was on unless the command line turned it off, as the trailer wanted it. Without a word on the command line, the film decides, and cel equals nought or one still wins over it. Mix used to put the shot's sounds into two channels of silence it made. Now it takes the two channels as a bed of sound that plays all along, the music, and later on the weather, and makes them as long as the shot, with silence after whatever is there. Add music lays the game's music into that bed, and takes the left and the right by reference, as it adds into them. It loads the track the client plays, as a raylib wave, and without it, as in a fresh clone, where the music isn't in git, it says so, and the shot goes without. Wave format converts it to our rate, as thirty-two bit floats, in two channels, and load wave samples gives us them, a sample of each channel in turn. Start is where in the track the shot begins. It fades in over two seconds, and out over three, at the end of the shot. For each sample, the fade is the smallest of one, how far into the fade in we are, and how far from the end. The gain is that, times how loud the shot wants the music, and the left and right samples go into the bed. Then raylib's samples and the wave are unloaded, as raylib allocated them for us. In shoot, cel is the option's value, or false without one, though by now, main has settled it from cel equals or from the film. The renderer's cel shading comes from it, and so do the graphics settings further down. The shot's own settings used to go on the atmosphere once, at the start. Now they go in a lambda for set adjust, which holds the shot by reference. Its parameter is the atmosphere, called sky here, as it's the film's sky we're changing. A lambda keeps the shot's settings in the film tool, so the renderer doesn't need to know what a shot is. The fog's near and far distances go in when the shot sets them, the sun's direction when it has one, and the light scales the sunlight and the ambient light, colour by colour, as before. And so does how cloudy it is, when the shot says, all of it over the time of day and the weather, each frame. Skied says whether the shot has a time of day or a weather, so that it gets a sky as the server would send it, with the day going on as fast as the shot says. Weather is the proto's enum, and it starts as clear, for a shot with a time of day and no weather of its own. The weather's name goes through the proto's parse function, with weather and an underscore in front, and a name it doesn't know stops the shot with an error. I'd much prefer that to a clear sky I'd spot an hour into filming. Sky at is the sky at a moment of the film, as the server would send it. The day starts where the shot says, or at noon, and moves on by its days a second, wrapped round past midnight by f mod. Share is how far through the shot we are, and the strength goes from the start's to the end's along it, when the shot has an end. A storm or a firestorm is a gale, so the wind along x is the shot's when it sets one, or in a gale, five metres a second, and otherwise a light breeze of about a metre. Each of these nested conditions reads from the top, the shot's own value first, then the gale's, and the breeze's last. Along z, it's two in a gale, and half a metre otherwise. What's showing is day and night when the shot has a day, and the weather. The shot's seed is a hash of its name, from std hash, which the weather takes, so the lightning strikes where it did the last time we filmed the shot. I like that a lot, as a film that comes out the way it did last time is much easier to fix up. A shot with a wetness soaks the ground to start with. Then come the bed's two channels, empty for now. In the loop over the frames, a shot with a sky hands the renderer the sky at this moment, and animate moves on after it, so the atmosphere it works out is this frame's, and not the last one's. Once the frames are all drawn, a shot with music lays it into the bed, and the sounds go over it, moved in, as mix takes its channels by value. Last, heights, for those two commands, which list places to stand a player and look out from. Finding a shot's spot by flying a camera around is slow, so I wanted a list. It checks the land's name first, and says so when there's no such land. Then it takes the land's terrain, as a shot does, and a small struct, place, for a spot's x, z and height, and a vector of them. It walks the land in steps of two metres, up to four from its edge, taking the ground's height at each spot, and skipping places nobody can stand. By the sea is dry ground between nought point four and two and a half metres up, with water six metres away on one of the four sides, which any of checks over an array of the four directions. Peaks keeps them all, and shores keeps those by the sea. They're sorted highest first, with ranges' sort and a lambda that puts the higher of two places in front. A place goes on the kept list when none of the places already on it are within twenty-five metres, up to a dozen, so we don't get twelve spots on one hilltop. Each is printed with its land, x, z and height, one a line, with std cout. In main, peaks and shores, with a land's name, go to heights, and once the film is read, cel comes from the film, when the command line didn't set it.

13:35 Then the shots, in a new film file, weather, with thirteen quiet shots of the lands under their skies, and someone standing in each, with the camera over their shoulder. Each is a handful of lines: its land, fifty seconds, its sky, the player, where the camera looks, and the music under it. Among the Meadows' shots, there's rain at sunset on the west coast, a storm coming in off the sea, fireflies after dusk, snow up on the highest peak, and a whole day in a minute. In the Ashlands, fire falls into the lava, and ash falls at night, and in the Crypt, it's night all the time, over its glowing water.

14:10 To find the snow's spot, we build the game at this step and run the film tool's new peaks command for the Meadows. It reads the land and prints, without a window, so it runs in the test image, and dash dash no deps leaves out the databases. The film tool and the renderer have changed, so the build takes a little while first. The highest place is at x minus seventy-four, z minus a hundred and thirty-two, twenty-three metres up, which is where the snow shot stands.

14:38 At this step, the rain at sunset films with last episode's rain and the evening's light, from the sky the film hands the renderer. What we hear is the game's music, which the shot lays under its picture, and none of the rain yet.

14:53 And the storm at dusk has its lightning, striking where it struck the last time we filmed it, though there's nothing to hear yet when it does.

Snow, ash and fire

15:06 Up on the highest peak, where the ground is white, the rain falls as it does down by the sea, and up here, I'd expect it to be snowing.

15:16 And in the Ashlands, the film hands over a firestorm, as the server would, but the client has nothing to draw for it yet, so the sky over the lava stays as it was.

15:27 In the weather's header file, what falls now has flakes and embers as well as drops, each worked out from the clock alone, and draw glows joins draw falling, for what burns. In the weather, each kind of thing that falls has a fall, from last episode, with its count, its box and its speed. Now it gets one more field, how far it swings from side to side as it falls, in metres. Each fall is written with designated initialisers, the dot names, so each number says what it is, and rain doesn't sway at all. Snow is up to eighteen hundred flakes, in a box as big as the rain's, falling at one point four metres a second, which is slow and pretty, and swaying thirty-five centimetres. Embers are up to nine hundred, from a much bigger box, sixty-four metres across and forty-five high, as fire falls from a long way up, at eight metres a second. Ash is seventeen hundred grey flakes, a little slower than snow and swaying more. Each kind has a salt of its own, so the hash gives each its own places. The snow line is nineteen metres up, where the Meadows' ground turns white, and above it, rain falls as snow. An ember's sparks last nought point four five seconds after it lands. In falling, each one gets a phase of its own from its hash, so they don't all sway together. The sway is a sine of the clock along x, and a cosine along z, at slightly different speeds, so a flake wanders round in a loose loop, and not along a line. The sway goes on top of where the wind blows it, on the place it's at now. Then comes glow, which is how a spark is drawn. One that comes nearly up to the lens fades away, from three metres off to one point two, so a spark that flies at the camera doesn't fill the picture. Like the streak, a glow goes into the batch we're already drawing, so it adds no draw call of its own. It's eight slices round the middle, like a pie's. The rim's colour is the glow's colour with an alpha of nought. A small lambda, rim, gives the point a turn of the way round the rim, along the camera's right and up, so the circle always faces us. Each slice has a corner in the middle, in full colour, and two on the rim. In the additive pass, the alpha scales the light, so it's full in the middle and nothing at the rim, soft and round, as a firefly's light is. Eight slices are enough for a glow this small, and they keep each one to twenty-four corners in the batch. Facing's corners are the middle, plus or minus half its size each way, and quad draws it from those four. So each flake is a square facing the eye, its sides along the camera's right and up, and that's plenty for a flake a few centimetres across. In draw, setting the shader's added flag to nought moves up, next to the blend mode it goes with. After what falls, the blend mode goes additive, and added goes to one, which the shader reads as adding the light on, as it did for the lightning. That's where what burns is drawn, added onto whatever is behind it, so it glows. Then we flush raylib's batch before the lightning, as the lightning changes the shader's fog, and the batch is drawn with whatever the fog is when it's flushed. Draw falling is where the drops were drawn, and in it, we work out the camera's forward, the way it looks, as a unit vector. Right comes from a cross product with the camera's top, and the last of the three, up, is square to both of them, for the flakes to face us. A raindrop that would land above the snow line is skipped, and so is its splash, as it would land on snow. Then the snow, with as many flakes as the rain is strong, white with a touch of blue, and lit by the sky like the rain. Flakes blow at six tenths of the wind, and a flake that would land below the snow line is skipped, so the rain and the snow share the sky, each on its side of nineteen metres. Each flake is a square about four centimetres across, and it fades away near the lens, as the drops have since last episode, so one falling right past the camera doesn't cross the picture. In the Ashlands, ash falls with its weather's strength, and with fire too, at under half of it, as a firestorm is full of ash. Ash is grey, lit by the sky like the rest, and blows at eight tenths of the wind, as a flake of ash is light. Ash tumbles, so each flake grows and shrinks with a sine, as if it were turning in the air. It's a cheap trick, but it reads as tumbling. Each ash flake fades near the lens too, like the snow. And then comes draw glows, for what burns in the sky. It starts as draw falling does, with the terrain and the camera's forward, the way it looks, as a unit vector, which it needs for the other two. Then, as there, right comes from a cross product of forward with the camera's top, and up is square to both of them, since the sparks are round glows that face the eye too. Then comes the weather's strength, clamped between nought and one, and the wind. For now, it has the Ashlands' fire and nothing else, and the next step fills it with more. In a firestorm, fire falls from the sky, and as many embers fall as the fire is strong, down at their speed and along the wind. Each one's place comes from falling, as the drops' and the flakes' do. Each is a streak about a metre and a third long, faded near the lens like the flakes, white-hot at its head, going red and clear at its tail. It glows four and a half times brighter than white, and as our bloom spreads whatever is brighter than white, each ember gets its halo for free. For a moment after it lands, while t, the time since, is under the sparks' life, if it landed in the lava, a ring of orange light spreads from where it fell. The ring's radius grows from fifteen centimetres to over a metre during the sparks' life, fading as it goes. Four sparks fly out, a quarter of the way round from each other, give or take, from a hash of the ember's number, so each ember throws its sparks its own way. They go up and back down in an arc, with the square of the time in it, as anything thrown has. Each is a small round glow that fades as the sparks die.

21:25 The sky changes with the weather too, in the daylight's overcast, from last episode, where the rain greyed it. Ash turns the sky towards a warm grey, at the brightness of the time of day, brings the fog in to six tenths of the way, and weakens the sun's light by up to two fifths. Grey cloud covers the sky, the sun's disc dims, and the stars go in. Fire lights the smoke from below, whatever the time of day, so the sky goes towards a deep orange red. These colours don't scale with the day's brightness, which is why it's red at midnight too. The light on everything warms up, the clouds go red and cover the sky, and the stars go in too. Next, a quick test that a firestorm does that, in the daylight's tests, which get the Ashlands' place in the lands, one, next to the Meadows' and the Crypt's. It lights the smoke red from below in a firestorm. The test makes two atmospheres with atmosphere under, which is what the renderer calls each frame. We take the Ashlands' sky at midnight, clear, and then in a firestorm. We expect the fire's to be brighter than the night's, by brightness, a helper the tests have, which adds up a colour's red, green and blue. And it's red, with more than twice as much red as green. The clouds cover all of it, and there are no stars.

22:41 We build the game at this step and run the daylight's tests, which need neither the databases nor a window, and grep keeps the lines of the tests that passed. The weather and the daylight have changed, so the client builds again first. They all pass, and the firestorm's sky is red, and brighter than the night's.

22:59 Back up on the peak at this step, it snows, and each flake sways as it comes down, slowly, at a little over a metre a second.

23:09 In the Ashlands, fire falls into the lava, each ember a streak from white to red, blooming as it glows past white.

23:18 Where one lands in the lava, a ring of light spreads, and its sparks fly out in an arc, with grey ash falling in between.

What glows

23:27 After dusk in the middle of the Meadows, the night is pretty, with its stars, but nothing moves on the ground, and I'd like a few lights down there.

23:37 And the Crypt's night is as still, under its mist, over the glowing water.

23:45 What glows comes out as it gets dark, so that comes first, in the daylight's header file. Darkness says how dark it is at a time of day, from nought all day to one all night, going between the two at dawn and dusk. In daylight, before noon it's one, less a smooth step from nought point one eight to nought point three, which is the dawn. After noon, it's a smooth step from nought point seven to nought point eight two, which is the dusk. The client's looks from last episode are full night before nought point one eight and after nought point eight two, so the fireflies come out with the night. In the renderer, animate hands the weather a copy of the sky now, called shown, which is the server's sky as before. Before any sky has come, or with day and night switched off, it's noon for what glows. So a player who turned the night off sees the land's day, and no fireflies in it.

24:37 In the weather's header file, the weather draws what glows in the dark now, as well as what falls, and in this step, that's the fireflies over the Meadows, the wisps in the Crypt and the sparks off the lava. The land decides what glows there, as it does what falls, and with the weather switched off, nothing glows either, so the switch takes the fireflies away with the rain. In the weather, we bring in the daylight's header, for darkness, and the lands, to know which land is a dungeon. What glows doesn't fall, so it gets a struct of its own, a swarm. Each lives on the ground around the camera, which is cut into square cells. So a swarm has the cell's side, in metres, how far out from the camera it goes, and the share of the cells that have one, at most. Fireflies live in cells of two and a half metres, out to forty, in up to six in ten of them. Wisps are sparser, in cells of six metres, and the sparks off the lava are in cells of three. Each has a salt of its own, like the kinds that fall. In draw glows, we take how dark it is now. Swarm is a lambda that goes over each cell near the camera, with the share that's out now, and calls a draw function for each cell that has one. Its last parameter is auto, which makes the lambda a template, so each kind can hand it a lambda of its own. The cells run from the reach on one side of the middle to the reach on the other, along x and along z, from the floor of each edge over the cell's size. For fireflies, that's thirty-three cells along each side, about a thousand cells, each a hash and a compare, which costs next to nothing. Each cell's hash comes from its two numbers, each times a large prime, mixed together and with the swarm's salt. The hash says whether the cell has one, and where in the cell it is, and the draw function gets the hash, the place, and the ground's height there. This is the bit of the episode I like most. Nothing is kept between frames, and as the camera moves, the cells it reaches are worked out again from their numbers, so a firefly stays where it is in the world. If we'd scattered them around the camera instead, they'd slide along with it. In the Meadows, fireflies come out as the light goes, over the grass, and rain or a storm keeps the fireflies down, and wet is true in either. Out is the share of the fireflies that's out now, which is the darkness, times one less twice the rain's strength, so there are none at all once the rain is half as strong as it gets. None fly over the water or up the mountain, and each has two phases of its own, from its hash. It wanders along a few slow sine waves, two at different speeds along x and two along z, so it doesn't keep tracing one loop. It goes about a metre each way, from knee height to above our heads, bobbing up and down. Each blinks at a speed of its own, from its hash, with its phase a keeping it apart from its neighbours, and the blink is a sine, with the half below nought cut off, then cubed. Cubing keeps it near nought most of the time and makes its peak short and soft, which is how a firefly blinks. Each is a yellow-green glow, half as bright as white when it's off, and up to eight and a half times when it's on, so it blooms. In a dungeon, which is the Crypt, pale wisps drift all the time, whatever the time of day. They keep over the ground and off the water. They drift slowly, a couple of metres each way, a metre to over three above the ground, bobbing a little. Each pulses gently, between about a third and full, more slowly than a firefly blinks, and it's a bigger, pale blue glow, at four times white when it pulses fullest. In the Ashlands, sparks rise off the lava, a third as many by day as by night. They start where the ground is under the lava, each rising at its own speed, up to five metres, then from the bottom again, as wrap takes it round. Each drifts downwind, further the higher it gets, and fades as it climbs, so it's gone by the time it's five metres up.

28:37 Then a quick test of darkness, in the daylight's tests, that it's dark at night and light all day. Midnight is fully dark, noon isn't dark at all, late in the night it's dark again, and at sunrise, it's in between, a little dark and a little light.

28:52 We run the daylight's tests at this step, with the new one, and again without the databases. The image builds the client once more, as the weather, the renderer and the daylight have all changed. They pass, and darkness is dark at night and light at noon.

29:08 Back in the middle of the Meadows after dusk, the fireflies are out, each wandering and blinking in its own time, and they stay put in the world as the camera drifts in.

29:19 In the Crypt, pale wisps drift over the shore, pulsing slowly in the mist.

29:27 And at night in the Ashlands, ash falls, and sparks rise off the lava on the wind, about three times as many as by day.

Sound from numbers

29:37 So far, the storm's lightning flashes over the sea without a sound of its own, and all we hear is the game's music.

29:47 So the weather's sound is going to be made from numbers as the game starts, like our footsteps. Rain, wind, fire, lava and crickets are each a loop of eight seconds, folded so it goes round without a seam. Each is as loud as the hearing says, from the land, the sky, and whether the sea is near. They play on a stream the game fills a twentieth of a second at a time. Birds, owls and drips come now and then, and each bolt's thunder comes as long after its flash as sound takes to get to us. And the films mix all of it under their shots.

30:20 The weather's sound gets a header file of its own, ambience, which brings in array, c std def, c std int, span and vector, then our synth, from episode fifty-five, and the protocol, for the sky. Hearing is how loud each of the weather's sounds and the time of day's should be, from nothing to full. Rain is drops on the ground and the leaves, and a downpour is more of them, harder, in a storm. Water is drops on the sea, when we're by it. Then the wind, fire falling, crackling and hissing where it lands, the lava bubbling, then crickets, birds and owls, and water dripping off the stone in the Crypt. Hearing of works that out from the land, its sky, whether there's water near, and whether the weather is switched on. Off, the weather goes quiet, and the rest keeps to the time of day. Splitting it out like this means we can test what's heard where without playing a sound, which I'm quite happy with. Then ambience, the sound: a few loops made as the game starts, which play all the time, each as loud as it should be, and birds, owls, drips and thunder now and then, made as they come. It's made from a seed, and the constructor is explicit, as it takes a single argument. Fill mixes the next stretch of sound into the two channels it's handed, filling them to the end, while each loop's level glides towards what the hearing wants. A span is a view of floats that someone else owns, which is what an audio stream's buffer is going to be. Thunder starts the thunder of a bolt so many metres away, from a side, from minus one on the left to one on the right. Thunder doesn't play straight away, so it waits on a list, which we'll see in a moment. Privately, the beds are the loops, by name, with k beds at the end as their count. A loop is its two channels of samples and how loud it is now, and a voice is a sound that plays once, after a wait, from one side. It keeps its samples, how far it's played, how long it still has to wait, how loud it is, and its pan. Call starts one of those voices, after a wait. The ambience keeps a noise, for its randomness, its beds, how far it's played, the voices playing, and when the next bird, owl and drip are due. Last, outside the class, thunder sound makes a bolt's thunder, a crack when it's near, then a long low roll.

32:34 Now the ambience's source file, which is where the sounds are made. We bring in algorithm, c math, c std def, c std int, span and utility. Then the daylight's header, for how dark it is, which decides the night's sounds, and the lands, for which of them is a dungeon. Tau is a whole turn in radians, two pi, as our tones go round in turns. Each loop is eight seconds long, and fades from its end into its start over half a second, so it goes round without a seam. Eight seconds is long enough that you don't hear the rain repeat, and short enough to make quickly. Glide is how fast a loop moves to a new level, about two thirds of the way in a second and a half, so the rain swells in as it starts, and doesn't switch on. And sound comes three hundred and forty-three metres a second, so thunder comes after the flash. That's the speed in air at about twenty degrees, which is close enough for a storm. Looped is how a loop goes round without a seam. It takes the sound by value, as it's going to change it and hand it back. Length is the loop's eight seconds in samples, and seam is the half second, in samples too. Resize makes the sound that long plus the seam, padding it with silence if it's short, so the sound carries on half a second past the loop's end. Its first half second fades in, while the half second past its end fades out over it, and that extra bit is cut off. So when the loop wraps from its last sample to its first, the first is mostly the sound that came straight after the last, and there's no click or jump, which I find a really neat trick. Silence is a loop's worth of nothing, plus the seam, to make each sound into. Drop is the building block for the rain, a short tone that dies away, added in at a sample. It lasts five times its decay, when it's down to under one percent of where it started, so cutting it there doesn't click. Its pitch can rise as it plays, which is what a drop on water does, and we keep the phase as we go, so a changing pitch doesn't click, and it dies away exponentially, by about two thirds each decay. The gain sets how loud the drop starts, before it dies away. Drop adds into a sound it's handed, which is how many drops share a loop. Rain is many drops, each a short tick of its own pitch, over a soft low bed. We keep away from a hiss of noise for it, which sounds like a television left on. There are as many drops as it rains a second, times the loop's length, each at a random moment, and a random loudness, at sixteen hundred to sixty-eight hundred hertz, dying away in one and a half to six milliseconds. The loudness is squared, so most drops are quiet, and a few are close. Under them, a little noise through a low pass at seven hundred hertz is the body of the rain, the part further off. Drops on water ring up in pitch, as each traps a bubble of air under the surface. It's built like the rain, a hundred and forty drops a second, at random moments and loudnesses, squared again so the loud ones are rare, and these are lower, rising by seventy percent as they ring, and longer. Each is quieter too, as the sea is further off. The wind is noise through a band that wanders up and down, swelling and dying away, which makes a whoosh as slow as a breath. The band is a band pass filter, one of our state variable filters from episode fifty-five. Two random phases, a and b, start the wander at different places in each channel, and the wander is two sines, one going round once a loop, and the other twice. Both turn a whole number of times in a loop, so the wind goes round smoothly as well. The band moves around four hundred and twenty hertz, and the swell rises and falls with the two sines, at nine tenths of the filter's output. Fire falling is crackles in little bursts, with a hiss now and then. A high pass filter, high, makes the clicks, and it's kept from one click to the next. There are nine bursts a second, times the loop's length with its seam, like the rain's drops. Each starts at a random moment, with two to eight clicks in it. Each click comes four to forty milliseconds after the one before, which is what makes it sound like crackling, and not like a steady tick. Each click is a millisecond or two of noise through a high pass at twenty-five hundred hertz, at a random loudness, fading out over its length, so it's a little snap. Then two and a half hisses a second, where it lands, each a quarter of a second long, at a random moment. Hertz is picked for each, between four and a half and seven thousand, and band is a filter of its own for it. Each hiss's loop goes over its quarter second. Our envelope from episode fifty-five gives it a rise of ten milliseconds and a decay of seventy, so it puffs in and dies away, and a deep rumble under all of it, below ninety hertz. Lava is slow, low bubbles, with a rumble under them. Its first bubble comes somewhere in the first half second, and they go on while there's loop left. Each is a tone of a hundred and ten to a hundred and ninety hertz, with its phase starting at nought at the bubble's first sample, and its pitch drops as it bursts. It falls by more than half over its first hundred and fifty milliseconds, and keeping the phase makes that fall smooth, so it sounds like a deep bloop. They come a third of a second to a second and a bit apart, over a rumble lower still, at sixty hertz, low passed noise again, as for the fire. Crickets are a few of them, four, each made in a loop of its own over the whole loop's length. Each has a pitch of its own between four thousand and fifty-two hundred hertz, chirping about once a second, in its own time. Each also has a loudness of its own. Its chirps go on through the whole loop, each up to a tenth sooner or later than the beat, so they don't tick like a clock. A chirp is three quick pulses of that tone, forty-five milliseconds apart. Start is where each pulse begins, in samples, and t is the time into it, and each pulse is twenty milliseconds long, shaped by half a sine, so it doesn't click. The crickets surprised me most, as three pulses of a sine wave turned out to be all it takes. A bird is a call now and then, and not a loop: a few quick notes, each sliding from one pitch to another, with a little trill. Its samples start empty, and at is where the next note goes, from nought. There are two to five notes, above a low pitch of its own, between twenty-two hundred and thirty-two hundred hertz, so each bird keeps to a voice of its own. From and to are each up to seventy percent above that low pitch, and lasts is how long the note is, sixty to a hundred and sixty milliseconds. The note's pitch goes in a straight line from one to the other, with a little trill on it, a hundred and twenty hertz each way, thirty-two times a second, and the note is shaped by half a sine. It's mixed into the call where the call has got to, with mix from episode fifty-five, which makes the call longer as it goes, and the next note comes after a short gap. An owl, far off, gives one low call, then two close together, three low notes of these lengths, between three hundred and thirty and four hundred hertz. Each is shaped by a sine squared, which swells and fades more gently than half a sine, as an owl's call does, each falling a little. Each has a touch of the octave above it, and a longer gap after the first note, nearly half a second, and a short one after the second, which is the rhythm of it. Drip is the last of the sounds that come now and then, and the simplest. A drip off the stone is a plink, a quarter of a second made with drop, at a pitch between thirteen hundred and twenty-six hundred hertz, falling by a quarter as it rings. Then come its echoes off the Crypt's walls, three times, each quieter, a sixth of a second apart. Clamp nought one keeps a level between nought and one. Then the thunder, four to six and a half seconds of it. Near, under two hundred and twenty metres, it cracks first, as the air splits. High is a high pass filter, and the crack is a burst of noise through it at nine hundred hertz. That's the first three tenths of a second, rising in two milliseconds and dying away in sixty, which is about as sharp as a sound gets. Then it rolls, as low noise that gets darker as it goes, swelling a few times as the sound comes back off the clouds and the hills. Low is a low pass filter for it, and a is a random phase for the swells. The filter's cutoff falls from a hundred and fifty hertz to fifty-five over the thunder, and the swells go up and down at seven tenths of a turn a second. Its envelope rises over fifteen hundredths of a second and decays over a third of the thunder's length, so most of it is a long tail. And fade out brings its end down to nothing, without a click. Hearing of says what we hear, and how loud. With the weather switched off, its strength is nought, and the kind of weather is clear, and the darkness, from the last step, decides the night's sounds. In a dungeon, there are drips, and a little wind, more of it in the mist, and it returns, as a dungeon has none of the rest. The Ashlands have their lava bubbling at a little over half, all the time, fire as strong as the firestorm, and a wind that picks up with the ash and the fire. In the Meadows, storm is true in a storm, as the rain and the wind go by it. Rain and storms both rain, a storm is a downpour on top, and by the water, it falls on the sea too. There's a little wind at all times, more in the rain, and a lot in a storm. Dry is how far from raining it is, as the crickets, the owls and the birds go quiet in the rain. The crickets and the owls come out in the dark, and the birds sing by day, most of all in the morning, around nought point three two, just after sunrise. The constructor makes the loops, from s, the seed times thirty-one, so two ambiences with seeds next to each other don't share a loop's seed. We give each channel from a seed of its own, so the left and the right are different rain, which makes it wide, all round us. Rain is four hundred and twenty drops a second, and a downpour is twenty-six hundred, each softer, with more body. Then the water, and the wind, each from two seeds of their own, then the fire, with two more, the lava, with the two after that, and last of all the crickets, two channels each. That's fourteen loops of eight seconds, about twenty megabytes of floats, made once. Call puts a voice on the list, with its wait in samples, starting at its beginning. Thunder makes a thunder for the distance, from a seed that changes each time, so no two rolls sound alike, quieter the further off it is, and waiting the metres over three hundred and forty-three, in seconds. So a bolt three hundred and forty-three metres away rumbles a second after its flash. I love this bit of physics, as you can count the seconds between a flash and its thunder and know how far away the storm is. Fill is where it all plays, a buffer at a time. How loud each loop should be is the hearing's level times a level of the loop's own, which sets the mix. Glide is how much of the gap a level closes each sample, and frames is the shorter of the two spans' sizes, so neither channel is written past its end. Then at is where we've got to in the loops, wrapped round their length. For each sample and each loop, the level moves that much of the way towards what it should be, which glides it there smoothly, and a loop that's quiet enough is skipped, which saves the work. The rest are added into the left and the right, at where we've got to, wrapped round the loop. That's the loops, and the rest of fill is the calls. Now and then is a lambda for the calls, and seconds is how long this buffer lasts. When their level is too quiet, it does nothing, and otherwise, it counts down the time to the next one. When one is due, it makes a new one, as loud as the level says, from somewhere to our left or right, and the next is due after about that many seconds, sooner the louder the level. So birds sing a couple of seconds apart in the morning, an owl calls about twice a minute at night, and the Crypt drips, with a couple of seconds between its drips. Each voice playing waits out its wait, sample by sample, and stops with a break at the end of its samples. Otherwise it plays, panned by turning the far side down. The ones that have finished come off the list, with std erase if, from C++ twenty.

44:48 The client plays its sounds as clips, made once and played many times. The weather goes on and on, so it needs another kind of sound, a stream, which we make as it plays. In the audio header file, we bring in functional and span. A stream hands raylib two channels a buffer at a time, for as long as the sound goes on. Open makes one, and takes the audio device, so there can't be a stream before there's a device, which raylib needs. It owns raylib's stream, so it can't be copied. Feed fills the two channels again for each buffer raylib has used up. It takes a std function by const reference, so main can hand it a lambda that knows the ambience. raylib needs it each frame, as the music track's update does. Set volume takes a volume from nothing to full. Its constructor is private and explicit, so streams come from open. Privately, it keeps raylib's audio stream, the left, the right, and both of them together. In audio, we bring in algorithm, c std def, functional and span. A buffer is two thousand and forty-eight samples a channel, which is about a twentieth of a second at our rate. I went with that so a change in the weather comes through quickly. Open sets raylib's buffer size to that, loads a stream at our rate, as floats, in two channels, and makes room for the samples, then starts it playing. The destructor unloads the stream, as a clip's unloads its sound. Feed is a while loop, as raylib can have more than one buffer waiting. It goes round while raylib has a buffer that's played out and wants filling. It clears the two channels, has the function add the sound into them, and then goes through the samples one at a time. It lays them out a sample of each channel in turn, which is how raylib takes them. Then update audio stream hands the buffer over to raylib. And set volume is raylib's, on the stream.

46:44 Now to hook it all up, and the thunder has to know where each bolt struck. So in the weather's header file, where the lightning is, we add a bolt, which is where it struck, and take bolts gives the bolts that struck since the last time it was asked, once each. The weather keeps them in a vector until they're taken. In the weather, we bring in utility, and each new strike goes on the list, at the ground where it hits. Take bolts hands the list over and leaves an empty one, which std exchange does in one go. In the graphics settings, the weather switch now covers the snow, the fire and the fireflies, all of what this episode makes fall and glow. And with it off, the weather's sounds go quiet too, while the time of day's stay. The client's CMake file gets ambience and its tests. In the client's main, we bring in c time, span and ambience. The ambience and its stream are unique pointers, as there are none without an audio device, and between them, they play the weather and the time of day all the time. And hearing is what we hear now, which each frame updates. Once the audio device is open, we make the ambience, seeded by the time, so the rain sounds a little different from one run to the next, and open its stream. Each frame in the world, by water is whether there's sea where we stand, or eight metres off to any side. It's a loop over five offsets, written as pairs, with structured bindings for d x and d z, from the terrain's height there. We take the sky the server sent, at noon if day and night are off, and work out what we hear, with the weather switch. For each bolt that struck, its thunder starts, from its distance to us, panned to its side, as our footsteps are. After the music, out of the world, on the login screen, say, we hear nothing, so the loops glide down to quiet. It's as loud as the Effects slider, and we feed the stream, with a lambda that has the ambience fill each buffer with what we hear now. The film tool mixes the weather's sound under its shots too, so it brings in span and the ambience, and its mix goes over the weather now, as well as the music. A shot's ambience takes the shot's seed, so its rain and its birds come out as they did the last time. The rest goes at the end of each frame, once its picture has been read back, and while it's writing a video, as a still has no sound. Each frame, when it's writing a video and the shot has a sky, it hears from where the camera looks, as a film hears the game's other sounds. Each bolt's thunder starts from its distance to there, and by water is worked out as the client does, at the ears and eight metres to each side. From is where the bed has got to, and the bed grows to the end of this frame, in samples, with resize filling both channels with silence, which the ambience fills with what's heard under the sky at this moment. A film is drawn much slower than real time, but its sound goes by the film's frames, so the two line up.

49:37 Now, a few quick tests of what we hear, in a test file of their own, which brings in our header, algorithm, c math, c std def, span and vector, the synth, Google Test and the protocol. Then the Meadows', the Ashlands' and the Crypt's places in the lands, as constants. At makes a sky at a time of day, with a weather and its strength, setting the three fields on a protocol sky. Listen fills so many seconds of sound from an ambience. It works out how many frames that is, makes two channels of silence that long, has the ambience fill them, and puts the right channel on the end of the left, so a loudness covers both. Loudness is the root of the mean of the squares, which is how loud a sound is on average. It adds up the squares in a double, divides by how many there are, or by one for an empty span, so it doesn't divide by zero, and takes the square root. The first test is that each land hears its own weather. Using declarations let us write weather fire and weather rain on their own. Rain at nought point eight in the Meadows, at noon, away from the sea and with the weather on, is rain at nought point eight, without any on the water, and no fire. By the sea, that rain falls on the water too, at nought point eight. The client works out by water from the terrain, and here the test hands it in, which is the point of keeping hearing of a plain function. Then a firestorm at nought point six in the Ashlands, at noon, is fire at nought point six, and not rain, with the lava bubbling under it. The Crypt drips whatever the weather, even in a rain it doesn't get. And with the weather turned off, which is the last argument, the Meadows' rain is quiet. The second is birds by day, and crickets and owls by night. We take the Meadows' clear sky at nought point three five, in the morning, and at midnight, each with the weather on and away from the sea. In the morning, the birds sing and the crickets don't, and at midnight, it's the other way round, with the owls. And none of them sing out in a downpour, in a storm at full strength at midnight, as the dry share is nought, and it takes the crickets with it. With nothing to hear, a second of it is silence. The empty braces make a hearing that's all noughts, and its loudness comes out at nought. The rain fades in, instead of all at once. We listen to rain at full, keeping the first tenth of a second, then four seconds more, which we don't look at, and a second after that. The first tenth is under a quarter as loud as that last second, as the level glides up from nothing. Then a test of the physics, that the thunder comes as long after the flash as sound takes to come. A bolt three hundred and forty-three metres away, straight ahead, is a second away. Its thunder is silent for the first nought point nine five seconds, and heard in the second after. And the last test is that thunder is louder nearby. Two thunders from one seed, a hundred and four hundred metres away, and moment is a tenth of a second, in samples. Near, at a hundred metres, has its crack, and far doesn't. In its first tenth of a second, a bolt a hundred metres off, which cracks, is louder than one four hundred metres off.

52:45 We run the ambience's tests at this step, without the databases, as the ambience is arithmetic and needs no audio device either. There's a new source file and a new test file, so the image builds the client's library and its tests again first. All six pass, and the thunder of a bolt three hundred and forty-three metres away comes a second after it.

53:07 The rain at sunset has the rain made from numbers under the music this time, with the wind, and the drops on the sea, as the camera looks out over the water.

53:20 In the storm, the downpour is thousands of drops a second, and the wind is up. Keep an eye on the lightning, and listen for the thunder after each flash.

53:31 The flash reaches us at the speed of light, which is as good as at once, and its thunder at the speed of sound. So the further off a bolt strikes, the longer the thunder takes, and a near one cracks before it rolls.

53:46 After dusk, the crickets are out with the fireflies, each chirping in its own time, and now and then, an owl calls, far off.

53:58 In the Crypt, water drips off the stone, each drip echoing off the walls, over a low wind in the mist.

54:08 And in the Ashlands, the fire crackles and hisses as it falls, over the lava's bubbles.

Real recordings

54:17 The crickets and the thunder made from numbers sound right to me, but listen to the rain again. Each drop is a clean little tone, and hundreds of them a second sound like glass beads poured onto a table, not rain. Real rain is drops on leaves and grass and puddles, each a messy little splash, and I think a few hundred clean tones a second can't get near that.

54:39 So for the rain, and the fire while we're at it, we're going to play recordings from Pixabay, a site of free sounds, where the game's music comes from as well. Pixabay's licence lets us use them in the game, but not hand out the files on their own. So they stay out of git, like the music, and the ignore file leaves out the sound files in the assets' sounds folder. A fresh clone, or the game in a browser, doesn't have them, so the sound made from numbers stays, and plays wherever there's no recording. In the client's CMake file, the build copies the sounds folder next to the client, as it does the music. In the ambience's header file, use rain takes a recording of rain, its two channels as long as each other, and plays it in place of the rain made from numbers. It loops, its end fading into its start, and plays as loud as the loop it replaces. Use fire does that for the fire, from a recording of fire crackling, and use gust takes a gust of wind, which blows now and then over the wind made from numbers, more often the windier it is. Each loop goes round at its own length now, so a minute of recording and eight seconds made from numbers can play side by side. Recorded makes a recording into a loop to play in place of a bed, and says false if there's nothing in it. It's const, as it reads the beds, and changes the recording it's handed. And the ambience keeps when the next gust is due, and the gust. In ambience, fold is looped for a sound of any length. It fades the sound's last moment into its first, and cuts it off, unless it's too short to fold, at under twice the seam. Length is what's left once the seam is folded in, and the loop over the seam blends the start with what's past the end, as looped does. R M S is a sound's loudness, as the root of its mean square, with the sum in a double, as a minute of squares added up in a float would lose the small ones. It's nought for an empty sound, so nothing divides by zero. From is a sound from a later place in it, wrapping round to its start, to play beside it as another part of the rain. It copies the samples, starting at a place and wrapping round with the remainder. Recorded takes both channels by reference, changing them in place. It cuts them to the shorter one's length, and takes the seam, half a second in samples, as for the loops. Then it folds each, and takes the loudness of the loop it replaces, as the average of its two channels' loudness, and of the recording, which it works out just like that, from the average of its own two channels. The recording is turned up or down by their ratio, so it's as loud as the sound we mixed the rest against, whatever level it was recorded at. So the levels we picked in fill still hold. Use fire takes its channels by value, and if recorded says there's something in them, moves them into the fire's bed, so nothing is copied. Use gust makes the gust as long as its shorter channel, and each sample is the average of the two, as it blows past from the middle. There's one gust, so it's a single channel, panned when it plays. Peak, from our synth, is its loudest sample, and if it has any sound at all, normalise brings its loudest moment to a half, about the wind's, and then it fades out its end. Use rain returns if there's nothing in the recording, and otherwise puts it in the rain's bed. A downpour is more of it, from a third of the way into the minute, which from gives us, as third is a third of the recording's length, in samples, and the rain on the sea from two thirds. Played over each other, they're different stretches of rain, so a storm is more rain, and not one stretch of it twice over. In fill, each loop wraps at its own length now, so where we've played to counts on, and each loop takes its own remainder of it. And when there's a recorded gust, it blows now and then, about six seconds apart over the wind's level, which is about once a minute on a calm day, and a few seconds apart in a storm. Its lambda hands back the recording, where the others make a new call each time.

58:38 The recordings are loaded in audio, and in its header file, we bring in optional and utility. Sounds folder is where the recordings are, beside the music. Load stereo gives a sound file's two channels at our rate, or nothing, if there's no such file. It needs no audio device, which matters for the film tool, as it has none. Load mono does that with its two channels as one. Then a forward declaration of ambience, as this header doesn't need all of ambience's, and use recordings gives the ambience the recordings in the sounds folder, of the rain, the fire and a gust of wind, for each that's there. In audio, we bring in optional, utility and the ambience's header. Load mono gives nothing when load stereo does, and otherwise makes one channel as long as the two, each sample the average of theirs. Use recordings tries each file in the sounds folder in turn, the rain, the fire and the gust, with an if that has an initialiser, which keeps each recording inside its own branch. Each is moved into the ambience, as a minute of stereo samples is about twenty megabytes of floats, which we don't want to copy. The fire goes to use fire, and the gust to use gust, which takes it by reference, as it mixes it down to one. The sounds folder is next to the client, as the music's is. Load stereo checks that the file is there, and loads it as a raylib wave, which decodes the Ogg Vorbis for us. It converts it to our rate, as floats in two channels, as the film's music does. Load wave samples gives them interleaved, as raylib keeps them, and a loop takes them apart into the left and the right, as many as the wave's frame count. Then it unloads raylib's samples and the wave, and returns the two channels. In the client's main, the soundboard gets a recording of a teleport for going through a gate, if there is one, and the ambience gets real rain, fire and wind. The film tool does that for its shots too. In the soundboard's header file, the constructor gets a third parameter, a recording to go through a gate with, in place of the sound made from numbers. It brings in optional for it, and it's an optional departure, the sound of going through a gate, which is none by default, so the code that makes a soundboard without one stays as it was. In the soundboard, which brings in optional and utility, the constructor's signature changes to match the header, and it makes the departure from numbers as before, and keeps it for its loudness. Given a recording that isn't silent, it brings the recording's loudest moment to the made one's, and plays the recording in its place.

1:01:05 Now, a couple of quick tests that a recording plays as loud as what it replaces. Recorded rain plays as loud as the rain it makes. We listen to the rain made from numbers for six seconds, so it's glided all the way up, and take how loud the next two seconds are. Then comes a stand-in for a recording, made in the test. It's five seconds of noise from a noise of its own, at a half in each channel, which a loop fills sample by sample. That's about ten times louder than our rain, and five seconds long where our loops are eight. Then a second ambience, recorded, from seed seven too, uses it as its rain. We listen to it for six seconds too, and take the next two seconds' loudness. Listened to like the first, it comes out within a quarter of the made rain's loudness. The fire's test is its twin, with a quiet recording this time, so it has to be turned up. It listens to the fire made from numbers for six seconds, and takes two seconds of it. Then it makes a five second stand-in from a noise of its own, two channels of it, filled sample by sample in a loop as before, at a twentieth in each channel, a tenth of the rain stand-in's level. And a second ambience uses that as its fire. Listened to like the made fire, it comes out within a quarter of its loudness. And a gust blows now and then, in the wind, and not without it. The gust is a second of samples, made in the test like the stand-ins before it, so the test doesn't need a recording. A loop fills it with a sine, a tone that's easy to pick out over a quiet wind. Calm and windy are two ambiences from seed seven, and both get the gust. Over a minute, a strong wind should have more gusts in it than no wind at all. Calm listens to a minute without any wind, and windy to a minute of wind at full. The minute without wind is silent, as the gusts blow in the wind and nowhere else. And the windy minute should be louder at its loudest than the wind without the gusts, so plain, a third ambience without a gust, listens to a minute of the wind alone. It's from seed seven as well, so the gust is all that sets the two apart. With max element, which finds the biggest in a range, the loudest sample with the gusts has to beat the loudest without them by more than nought point two, where one is full.

1:03:21 We run the three new tests at this step, again without the databases. They make their stand-ins in the test, so they don't depend on the recordings being there, and the image builds the client again first. All three pass: both recordings play as loud as what they replace, and the gusts blow in the wind.

1:03:39 And the rain at sunset now plays the recording. To my ears, that's rain, finally, and with the game's music under it, it's the kind of thing I could leave on in the background while I work.

1:03:54 The fire is a recording now too, crackling as it falls into the lava, and now and then, a gust of wind blows past.

Wrap-up

1:04:05 Today, the film tool started handing the renderer a sky as the server would, with a camera over a player's shoulder and the game's music under each shot. Above nineteen metres, the rain falls as snow, and the Ashlands get ash, and fire that glows past white so it blooms. Fireflies, wisps and the lava's sparks live in cells of the ground, so they stay put as the camera moves. The weather's sound is loops made from numbers, folded so they go round without a seam, on a stream we feed a buffer at a time, with thunder that comes as long after its flash as sound takes. And where there are recordings, the rain and the fire play from them in place of the numbers, as loud as what they replace, with gusts of wind now and then.

Playing it

1:05:37 Tell me in the comments which of the quiet shots you liked best, or what you'd like to see next. And if you want to follow along with the series, subscribe to the channel. I hope you find this useful, and thanks for watching.