Luanti 5.15.0-dev
 
Loading...
Searching...
No Matches
sound_spec.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5#pragma once
6
7#include <string>
9
18{
19 SoundSpec(std::string_view name = "", float gain = 1.0f,
20 bool loop = false, float fade = 0.0f, float pitch = 1.0f,
21 float start_time = 0.0f) :
23 loop(loop)
24 {
25 }
26
27 bool exists() const { return !name.empty(); }
28
29 // Serialize/Deserialize a `SimpleSoundSpec`.
30 void serializeSimple(std::ostream &os, u16 protocol_version) const;
31 void deSerializeSimple(std::istream &is, u16 protocol_version);
32
33 // Name of the sound-group
34 std::string name;
35 float gain = 1.0f;
36 float fade = 0.0f;
37 float pitch = 1.0f;
38 float start_time = 0.0f;
39 bool loop = false;
40 // If true, a local fallback (ie. from the user's sound pack) is used if the
41 // sound-group does not exist.
42 bool use_local_fallback = true;
43};
44
45
46// The order must not be changed. This is sent over the network.
47enum class SoundLocation : u8 {
48 Local,
50 Object
51};
SoundLocation
Definition sound_spec.h:47
Describes the sound information for playback.
Definition sound_spec.h:18
std::string name
Definition sound_spec.h:34
bool use_local_fallback
Definition sound_spec.h:42
bool loop
Definition sound_spec.h:39
void deSerializeSimple(std::istream &is, u16 protocol_version)
Definition sound_spec.cpp:17
float gain
Definition sound_spec.h:35
bool exists() const
Definition sound_spec.h:27
void serializeSimple(std::ostream &os, u16 protocol_version) const
Definition sound_spec.cpp:9
SoundSpec(std::string_view name="", float gain=1.0f, bool loop=false, float fade=0.0f, float pitch=1.0f, float start_time=0.0f)
Definition sound_spec.h:19
float start_time
Definition sound_spec.h:38
float pitch
Definition sound_spec.h:37
float fade
Definition sound_spec.h:36