forked from OpenLoco/OpenLoco
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Audio.h
155 lines (129 loc) · 3.57 KB
/
Audio.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#pragma once
#include "Location.hpp"
#include "Types.hpp"
#include <OpenLoco/Engine/Map.hpp>
#include <optional>
#include <string>
#include <tuple>
#include <vector>
namespace OpenLoco::Vehicles
{
struct Vehicle2or6;
}
namespace OpenLoco::Environment
{
enum class PathId : uint8_t;
}
namespace OpenLoco::Audio
{
// TODO: This should only be a byte needs to be split off from sound object
enum class SoundId : uint16_t
{
clickDown = 0,
clickUp = 1,
clickPress = 2,
construct = 3,
demolish = 4,
income = 5,
crash = 6,
water = 7,
splash1 = 8,
splash2 = 9,
waypoint = 10,
notification = 11,
openWindow = 12,
applause_1 = 13,
error = 14,
unk_15 = 15,
unk_16 = 16,
demolishTree = 17,
demolishBuilding = 18,
unk_19 = 19,
vehiclePickup = 20,
constructShip = 21,
ticker = 22,
applause2 = 23,
newsOooh = 24,
newsAwww = 25,
breakdown1 = 26,
breakdown2 = 27,
breakdown3 = 28,
breakdown4 = 29,
breakdown5 = 30,
breakdown6 = 31,
null = 0xFF
};
enum class ChannelId
{
music,
unk_1,
ambient,
title_deprecated,
vehicle_0, // * 10
};
constexpr int32_t kNumReservedChannels = 4 + 10;
using MusicId = uint8_t;
struct MusicInfo
{
Environment::PathId pathId;
string_id titleId;
uint16_t startYear;
uint16_t endYear;
};
#pragma pack(push, 1)
struct WAVEFORMATEX
{
int16_t wFormatTag;
int16_t nChannels;
int32_t nSamplesPerSec;
int32_t nAvgBytesPerSec;
int16_t nBlockAlign;
int16_t wBitsPerSample;
int16_t cbSize;
};
#pragma pack(pop)
void initialiseDSound();
void disposeDSound();
void close();
const std::vector<std::string>& getDevices();
const char* getCurrentDeviceName();
size_t getCurrentDevice();
void setDevice(size_t index);
std::optional<uint32_t> getSoundSample(SoundId id);
bool shouldSoundLoop(SoundId id);
void toggleSound();
void pauseSound();
void unpauseSound();
void playSound(Vehicles::Vehicle2or6* t);
void playSound(SoundId id, const Map::Pos3& loc);
// FOR HOOKS ONLY DO NOT USE THIS FUNCTION FOR OPENLOCO CODE
// INSTEAD USE playSound(SoundId id, const Map::Pos3& loc) OR playSound(SoundId id, int32_t pan)
void playSound(SoundId id, const Map::Pos3& loc, int32_t pan);
void playSound(SoundId id, int32_t pan);
void playSound(SoundId id, const Map::Pos3& loc, int32_t volume, int32_t frequency);
void updateSounds();
void setBgmVolume(int32_t volume);
void updateVehicleNoise();
void stopVehicleNoise();
void stopVehicleNoise(EntityId head);
void updateAmbientNoise();
void stopAmbientNoise();
void revalidateCurrentTrack();
void resetMusic();
void playBackgroundMusic();
void stopMusic();
bool playMusic(Environment::PathId sample, int32_t volume, bool loop);
void resetSoundObjects();
bool isAudioEnabled();
const MusicInfo* getMusicInfo(MusicId track);
constexpr int32_t kNumMusicTracks = 29;
constexpr bool isObjectSoundId(SoundId id)
{
return static_cast<int32_t>(id) & 0x8000;
}
constexpr SoundId makeObjectSoundId(SoundObjectId_t id)
{
return static_cast<SoundId>((static_cast<int32_t>(id) | 0x8000));
}
int32_t calculatePan(const coord_t coord, const int32_t screenSize);
}