1 /*
2 BStone: A Source port of
3 Blake Stone: Aliens of Gold and Blake Stone: Planet Strike
4 
5 Copyright (c) 1992-2013 Apogee Entertainment, LLC
6 Copyright (c) 2013-2015 Boris I. Bendovsky (bibendovsky@hotmail.com)
7 
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the
20 Free Software Foundation, Inc.,
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 */
23 
24 
25 //
26 //      ID Engine
27 //      ID_SD.h - Sound Manager Header
28 //      Version for Wolfenstein
29 //      By Jason Blochowiak
30 //
31 
32 
33 #ifndef BSTONE_ID_SD_INCLUDED
34 #define BSTONE_ID_SD_INCLUDED
35 
36 
37 #include <cstdint>
38 #include "bstone_audio_mixer.h"
39 
40 
41 struct objtype;
42 struct doorobj_t;
43 
44 
45 struct SoundCommon {
46     uint32_t length;
47     uint16_t priority;
48 }; // SoundCommon
49 
50 struct Instrument {
51     uint8_t mChar;
52     uint8_t cChar;
53     uint8_t mScale;
54     uint8_t cScale;
55     uint8_t mAttack;
56     uint8_t cAttack;
57     uint8_t mSus;
58     uint8_t cSus;
59     uint8_t mWave;
60     uint8_t cWave;
61     uint8_t nConn;
62 
63     // These are only for Muse - these bytes are really unused
64     uint8_t voice;
65     uint8_t mode;
66     uint8_t unused[3];
67 }; // Instrument
68 
69 struct MusicGroup {
70     uint16_t length;
71     uint16_t values[1];
72 }; // MusicGroup
73 
74 
75 // Global variables
76 extern bool sd_has_audio;
77 extern bool sd_is_sound_enabled;
78 extern bool sd_is_music_enabled;
79 extern int16_t DigiMap[];
80 extern std::atomic<uint32_t> TimeCount; // Global time in ticks
81 
82 extern bool sqActive;
83 extern bool sqPlayedOnce;
84 
85 // Function prototypes
86 void SD_Startup();
87 void SD_Shutdown();
88 bool SD_PlaySound(
89     int sound);
90 void SD_StopSound();
91 void SD_WaitSoundDone();
92 void SD_StartMusic(
93     int index);
94 void SD_MusicOn();
95 void SD_MusicOff();
96 
97 bool SD_MusicPlaying();
98 
99 bool SD_EnableSound(
100     bool enable);
101 
102 bool SD_EnableMusic(
103     bool enable);
104 
105 bool SD_SoundPlaying();
106 
107 
108 // BBi
109 const int sd_min_volume = 0;
110 const int sd_max_volume = 20;
111 const int sd_default_sfx_volume = 10;
112 const int sd_default_music_volume = 5;
113 
114 extern int sd_sfx_volume;
115 extern int sd_music_volume;
116 
117 void sd_play_sound(
118     int sound_index,
119     const void* actor,
120     bstone::ActorType actor_type,
121     bstone::ActorChannel actor_channel);
122 
123 void sd_play_actor_sound(
124     int sound_index,
125     const objtype* actor,
126     bstone::ActorChannel actor_channel);
127 
128 void sd_play_player_sound(
129     int sound_index,
130     bstone::ActorChannel actor_channel);
131 
132 void sd_play_door_sound(
133     int sound_index,
134     const doorobj_t* door);
135 
136 void sd_play_wall_sound(
137     int sound_index);
138 
139 void sd_update_positions();
140 
141 bool sd_is_player_channel_playing(
142     bstone::ActorChannel channel);
143 
144 void sd_set_sfx_volume(
145     int volume);
146 
147 void sd_set_music_volume(
148     int volume);
149 
150 void sd_mute(
151     bool mute);
152 // BBi
153 
154 
155 #endif // BSTONE_ID_SD_INCLUDED
156