nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
foley.h
Go to the documentation of this file.
1#ifndef NANOMMO_CLIENT_FOLEY_H_
2#define NANOMMO_CLIENT_FOLEY_H_
3
4#include <array>
5#include <cstdint>
6
7#include "client/synth.h"
8#include "content/skills.pb.h"
9#include "terrain/lands.h"
10#include "terrain/terrain.h"
11
12namespace nanommo {
13
14/// What a foot comes down on, which is how the step sounds.
16
20
21/// How a land sounds: what each of its surfaces is underfoot, and the chord
22/// that greets a player who comes into it, in hertz.
23struct LandSound {
28 std::array<float, 3> chord;
29};
30
31/// In the order of the lands: the Meadows in C major, the Ashlands in A
32/// minor, and the Crypt on a diminished chord, which doesn't settle.
33constexpr std::array<LandSound, 3> kLandSounds = {{
34 {.sand = Ground::kSand,
35 .grass = Ground::kGrass,
36 .rock = Ground::kRock,
37 .snow = Ground::kSnow,
38 .chord = {523.25f, 659.26f, 783.99f}},
39 {.sand = Ground::kAsh,
40 .grass = Ground::kAsh,
41 .rock = Ground::kRock,
42 .snow = Ground::kAsh,
43 .chord = {220.0f, 261.63f, 329.63f}},
44 {.sand = Ground::kStone,
45 .grass = Ground::kStone,
46 .rock = Ground::kStone,
47 .snow = Ground::kStone,
48 .chord = {196.0f, 233.08f, 277.18f}},
49}};
50static_assert(kLandSounds.size() == kLands.size(), "each land needs its sound");
51
52/// What's underfoot there: the water we wade in, or the land's surface.
53Ground GroundAt(const Terrain& terrain, int land, float x, float z);
54
55/// One footstep: the heel, then the rest of the foot. Each seed makes one a
56/// little different from the others.
57Samples Step(Ground ground, uint32_t seed);
58
59/// How cold the fx's colour is, from -1 for red to 1 for blue: a cold one
60/// rings higher, and a warm one lower.
61float Coldness(uint32_t color);
62
63/// The sound of one of a skill's fx, from when it starts.
64Samples FxSound(const skills::Fx& fx, uint32_t seed);
65
66/// All the sounds of a skill's fx, each at its time: those at the target
67/// with a monster picked, as the fx are drawn.
68Samples SkillSound(const skills::Look& look, uint32_t seed, bool target);
69
70/// Going through a gate: a rush up, as the screen covers the world.
71Samples Departure(uint32_t seed);
72
73/// Coming out into a land: its chord, struck like bells.
74Samples Arrival(int land);
75
76} // namespace nanommo
77
78#endif // NANOMMO_CLIENT_FOLEY_H_
Definition chat.cc:9
std::vector< float > Samples
One channel of sound, at kRate.
Definition synth.h:14
Samples FxSound(const skills::Fx &fx, uint32_t seed)
The sound of one of a skill's fx, from when it starts.
Definition foley.cc:308
Ground GroundAt(const Terrain &terrain, int land, float x, float z)
What's underfoot there: the water we wade in, or the land's surface.
Definition foley.cc:97
Samples SkillSound(const skills::Look &look, uint32_t seed, bool target)
Definition foley.cc:540
Place Arrival(const Gate &gate, float yaw)
Definition lands.cc:43
constexpr std::array< Land, 3 > kLands
Definition lands.h:31
Ground
What a foot comes down on, which is how the step sounds.
Definition foley.h:15
Samples Step(Ground ground, uint32_t seed)
Definition foley.cc:122
constexpr std::array< Ground, 7 > kGrounds
Definition foley.h:17
float Coldness(uint32_t color)
Definition foley.cc:302
constexpr std::array< LandSound, 3 > kLandSounds
Definition foley.h:33
Samples Departure(uint32_t seed)
Going through a gate: a rush up, as the screen covers the world.
Definition foley.cc:583
std::array< float, 3 > chord
Definition foley.h:28