nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
soundboard.h
Go to the documentation of this file.
1#ifndef NANOMMO_CLIENT_SOUNDBOARD_H_
2#define NANOMMO_CLIENT_SOUNDBOARD_H_
3
4#include <cstdint>
5#include <map>
6#include <memory>
7#include <optional>
8#include <utility>
9#include <vector>
10
11#include "client/audio.h"
12#include "client/foley.h"
13#include "client/soundscape.h"
14#include "content/skills.h"
15
16namespace nanommo {
17
18/// The game's sounds, each made in a few takes as the game starts, and played
19/// a take at a time.
21 public:
22 /// Takes of each step, and of each skill.
23 static constexpr int kStepTakes = 8;
24 static constexpr int kSkillTakes = 3;
25
26 /// With a recording to go through a gate with, in place of the sound made
27 /// from numbers, if there's one.
28 Soundboard(const AudioDevice& device, const SkillTable& skills,
29 std::optional<Samples> departure = std::nullopt);
30
31 /// How loud the sounds are, from the settings, from 0 to 1.
32 void set_volume(float volume) { volume_ = volume; }
33
34 void Step(Ground ground, Heard heard);
35
36 /// The skill's sound, by the skill's id, with the fx at the target if a
37 /// monster was picked.
38 void Skill(uint32_t skill, bool target, Heard heard);
39
40 void Departure();
41
42 /// Into the land, by its place in the lands.
43 void Arrival(int land);
44
45 private:
46 using Takes = std::vector<std::unique_ptr<Clip>>;
47
48 void Play(const Takes& takes, Variety& variety, Heard heard);
49
50 float volume_ = 1.0f;
51 std::map<Ground, Takes> steps_;
52 std::map<Ground, Variety> step_varieties_;
53 /// By the skill's id, and whether a monster was picked.
54 std::map<std::pair<uint32_t, bool>, Takes> skills_;
55 Variety skill_variety_;
56 std::unique_ptr<Clip> departure_;
57 std::vector<std::unique_ptr<Clip>> arrivals_;
58};
59
60} // namespace nanommo
61
62#endif // NANOMMO_CLIENT_SOUNDBOARD_H_
static constexpr int kStepTakes
Takes of each step, and of each skill.
Definition soundboard.h:23
Soundboard(const AudioDevice &device, const SkillTable &skills, std::optional< Samples > departure=std::nullopt)
Definition soundboard.cc:23
void set_volume(float volume)
How loud the sounds are, from the settings, from 0 to 1.
Definition soundboard.h:32
static constexpr int kSkillTakes
Definition soundboard.h:24
void Arrival(int land)
Into the land, by its place in the lands.
Definition soundboard.cc:86
void Skill(uint32_t skill, bool target, Heard heard)
Definition soundboard.cc:77
void Step(Ground ground, Heard heard)
Definition soundboard.cc:72
Definition chat.cc:9
Ground
What a foot comes down on, which is how the step sounds.
Definition foley.h:15