23#ifndef CORSIX_TH_TH_SOUND_H_
24#define CORSIX_TH_TH_SOUND_H_
55 struct sound_dat_sound_info {
56 std::array<char, 18> sound_name;
61 std::vector<uint8_t> data;
62 std::vector<sound_dat_sound_info> sound_files;
155 static void on_channel_finished(
int iChannel);
161 int playing_channel_for_handle(uint32_t
handle);
167 double camera_radius;
168 double master_volume;
169 double sound_effect_volume;
170 int positionless_volume;
171 bool sound_effects_enabled;
175 std::array<uint32_t, number_of_channels> channels{};
176 uint32_t next_playing_track_handle{0};
183 std::recursive_mutex channel_mutex{};
Utility class for accessing Theme Hospital's SOUND-0.DAT.
Definition th_sound.h:35
size_t get_number_of_sounds() const
Returns the number of sounds present in the archive.
Definition th_sound.cpp:90
size_t get_sound_duration(size_t iIndex)
Gets the duration (in milliseconds) of the sound at a given index.
Definition th_sound.cpp:116
SDL_RWops * load_sound(size_t iIndex)
Opens the sound at a given index into an SDL_RWops structure.
Definition th_sound.cpp:192
const char * get_sound_name(size_t iIndex) const
Gets the name of the sound at a given index.
Definition th_sound.cpp:94
bool load_from_th_file(const uint8_t *pData, size_t iDataLength)
Definition th_sound.cpp:46
~sound_player()
Definition th_sound.cpp:226
bool is_playing(uint32_t handle)
Returns whether the sound matching the given handle is playing.
Definition th_sound.cpp:321
int reserve_channel()
Definition th_sound.cpp:333
static constexpr uint32_t null_handle
Definition th_sound.h:68
static sound_player * get_singleton()
Definition th_sound.cpp:240
sound_player(const sound_player &)=delete
static constexpr int number_of_channels
Definition th_sound.h:69
toggle_pause_result toggle_pause(uint32_t handle)
Definition th_sound.cpp:298
void release_channel(int iChannel)
Releases a previously reserved SDL_mixer channel.
Definition th_sound.cpp:349
uint32_t play_at(size_t iIndex, int iX, int iY, int loops)
Definition th_sound.cpp:273
void set_sound_effects_enabled(bool bOn)
Definition th_sound.cpp:329
void set_sound_effect_volume(double dVolume)
Sets the default volume for sound effects.
Definition th_sound.cpp:325
sound_player & operator=(const sound_player &)=delete
uint32_t play(size_t iIndex, double dVolume, int loops)
Definition th_sound.cpp:264
void set_camera(int iX, int iY, int iRadius)
Sets the position of the camera for play_at calculations.
Definition th_sound.cpp:366
toggle_pause_result
Definition th_sound.h:67
void populate_from(sound_archive *pArchive)
Definition th_sound.cpp:242
sound_player()
Definition th_sound.cpp:204
void stop(uint32_t handle)
Definition th_sound.cpp:312