From 0440c3deeae067da54bba0c807cc0588f491d55c Mon Sep 17 00:00:00 2001 From: Ted John Date: Wed, 29 Mar 2017 18:44:19 +0100 Subject: [PATCH] Clean up audio.cpp --- src/openrct2-dll/openrct2-dll.cpp | 3 +- src/openrct2-ui/UiContext.cpp | 2 +- src/openrct2-ui/audio/AudioContext.cpp | 34 +- src/openrct2-ui/audio/AudioContext.h | 5 +- src/openrct2/audio/AudioContext.h | 6 +- src/openrct2/audio/AudioMixer.cpp | 6 +- src/openrct2/audio/audio.cpp | 646 +++++++++--------- src/openrct2/audio/audio.h | 296 ++++---- src/openrct2/input.c | 4 +- src/openrct2/interface/window.c | 2 +- src/openrct2/management/news_item.c | 2 +- src/openrct2/peep/peep.c | 2 +- src/openrct2/ride/ride.h | 3 +- .../windows/editor_object_selection.c | 2 +- src/openrct2/windows/error.c | 2 +- src/openrct2/windows/new_ride.c | 2 +- src/openrct2/windows/news.c | 4 +- src/openrct2/windows/ride_construction.c | 4 +- src/openrct2/windows/scenery.c | 2 +- src/openrct2/windows/title_scenarioselect.c | 2 +- src/openrct2/windows/track_list.c | 2 +- 21 files changed, 536 insertions(+), 495 deletions(-) diff --git a/src/openrct2-dll/openrct2-dll.cpp b/src/openrct2-dll/openrct2-dll.cpp index 83ca557473..162e47d9c5 100644 --- a/src/openrct2-dll/openrct2-dll.cpp +++ b/src/openrct2-dll/openrct2-dll.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include using namespace OpenRCT2; @@ -47,7 +48,7 @@ DLLEXPORT int LaunchOpenRCT2(int argc, wchar_t * * argvW) IAudioContext * audioContext = CreateAudioContext(); IUiContext * uiContext = CreateUiContext(); - IContext * context = OpenRCT2::CreateContext(audioContext, uiContext); + IContext * context = CreateContext(audioContext, uiContext); int exitCode = context->RunOpenRCT2(argc, argv); diff --git a/src/openrct2-ui/UiContext.cpp b/src/openrct2-ui/UiContext.cpp index 021ccfe29a..caf3c2a2cc 100644 --- a/src/openrct2-ui/UiContext.cpp +++ b/src/openrct2-ui/UiContext.cpp @@ -89,7 +89,7 @@ public: ~UiContext() override { CloseWindow(); - SDL_Quit(); + SDL_QuitSubSystem(SDL_INIT_VIDEO); } // Window diff --git a/src/openrct2-ui/audio/AudioContext.cpp b/src/openrct2-ui/audio/AudioContext.cpp index 3487732507..bf66fd90d8 100644 --- a/src/openrct2-ui/audio/AudioContext.cpp +++ b/src/openrct2-ui/audio/AudioContext.cpp @@ -14,7 +14,11 @@ *****************************************************************************/ #pragma endregion +#include +#include #include +#include +#include "../SDLException.h" #include "AudioContext.h" namespace OpenRCT2 { namespace Audio @@ -27,17 +31,43 @@ namespace OpenRCT2 { namespace Audio public: AudioContext() { + if (SDL_Init(SDL_INIT_AUDIO) < 0) + { + SDLException::Throw("SDL_Init(SDL_INIT_AUDIO)"); + } _audioMixer = AudioMixer::Create(); } + ~AudioContext() override + { + SDL_QuitSubSystem(SDL_INIT_AUDIO); + } + IAudioMixer * GetMixer() override { return _audioMixer; } - void SetOutputDevice(const char * deviceName) override + std::vector GetOutputDevices() override { - _audioMixer->Init(deviceName); + std::vector devices; + sint32 numDevices = SDL_GetNumAudioDevices(SDL_FALSE); + for (sint32 i = 0; i < numDevices; i++) + { + std::string deviceName = String::ToStd(SDL_GetAudioDeviceName(i, SDL_FALSE)); + devices.push_back(deviceName); + } + return devices; + } + + void SetOutputDevice(const std::string &deviceName) override + { + const char * szDeviceName = nullptr; + if (!deviceName.empty()) + { + szDeviceName = deviceName.c_str(); + } + _audioMixer->Init(szDeviceName); } IAudioSource * CreateStreamFromWAV(const std::string &path) override diff --git a/src/openrct2-ui/audio/AudioContext.h b/src/openrct2-ui/audio/AudioContext.h index 8f5e83bd35..38c2f917c1 100644 --- a/src/openrct2-ui/audio/AudioContext.h +++ b/src/openrct2-ui/audio/AudioContext.h @@ -12,7 +12,8 @@ typedef struct SpeexResamplerState_ SpeexResamplerState; namespace OpenRCT2 { namespace Audio { - struct AudioFormat; + struct AudioFormat; + interface IAudioContext; #pragma pack(push, 1) struct WaveFormat @@ -68,4 +69,6 @@ namespace OpenRCT2 { namespace Audio { IAudioMixer * Create(); } + + IAudioContext * CreateAudioContext(); } } diff --git a/src/openrct2/audio/AudioContext.h b/src/openrct2/audio/AudioContext.h index 45f5ad10d7..bf13391c00 100644 --- a/src/openrct2/audio/AudioContext.h +++ b/src/openrct2/audio/AudioContext.h @@ -17,6 +17,7 @@ #pragma once #include +#include #include "../common.h" namespace OpenRCT2 @@ -36,7 +37,8 @@ namespace OpenRCT2 virtual IAudioMixer * GetMixer() abstract; - virtual void SetOutputDevice(const char * deviceName) abstract; + virtual std::vector GetOutputDevices() abstract; + virtual void SetOutputDevice(const std::string &deviceName) abstract; virtual IAudioSource * CreateStreamFromWAV(const std::string &path) abstract; @@ -58,7 +60,5 @@ namespace OpenRCT2 virtual void StopTitleMusic() abstract; virtual void StopVehicleSounds() abstract; }; - - IAudioContext * CreateAudioContext(); } } diff --git a/src/openrct2/audio/AudioMixer.cpp b/src/openrct2/audio/AudioMixer.cpp index 7fcbe7355e..1a5d0b6ee3 100644 --- a/src/openrct2/audio/AudioMixer.cpp +++ b/src/openrct2/audio/AudioMixer.cpp @@ -41,7 +41,11 @@ static IAudioMixer * GetMixer() void Mixer_Init(const char * device) { IAudioContext * audioContext = GetContext()->GetAudioContext(); - audioContext->SetOutputDevice(device); + if (device == nullptr) + { + device = ""; + } + audioContext->SetOutputDevice(std::string(device)); } void * Mixer_Play_Effect(size_t id, sint32 loop, sint32 volume, float pan, double rate, sint32 deleteondone) diff --git a/src/openrct2/audio/audio.cpp b/src/openrct2/audio/audio.cpp index 8b034aab63..fa0f8babee 100644 --- a/src/openrct2/audio/audio.cpp +++ b/src/openrct2/audio/audio.cpp @@ -16,193 +16,197 @@ #include "../config/Config.h" #include "../Context.h" +#include "../core/Collections.hpp" #include "../core/File.h" #include "../core/FileStream.hpp" #include "../core/Memory.hpp" +#include "../core/String.hpp" #include "../core/Util.hpp" #include "../localisation/string_ids.h" #include "../OpenRCT2.h" #include "../ui/UiContext.h" +#include "audio.h" +#include "AudioContext.h" #include "AudioMixer.h" extern "C" { - #include "../interface/viewport.h" - #include "../intro.h" - #include "../localisation/language.h" - #include "../util/util.h" - #include "audio.h" + #include "../interface/viewport.h" + #include "../intro.h" + #include "../localisation/language.h" + #include "../ride/ride.h" + #include "../util/util.h" } -typedef struct rct_audio_params { - bool in_range; - sint32 volume; - sint32 pan; -} rct_audio_params; +using namespace OpenRCT2::Audio; -audio_device *gAudioDevices = NULL; -sint32 gAudioDeviceCount; -sint32 gAudioCurrentDevice = -1; -void *gCrowdSoundChannel = 0; -bool gGameSoundsOff = false; -void *gRainSoundChannel = 0; -rct_ride_music gRideMusicList[AUDIO_MAX_RIDE_MUSIC]; -rct_ride_music_params gRideMusicParamsList[6]; -rct_ride_music_params *gRideMusicParamsListEnd; -void *gTitleMusicChannel = 0; -rct_vehicle_sound gVehicleSoundList[AUDIO_MAX_VEHICLE_SOUNDS]; -rct_vehicle_sound_params gVehicleSoundParamsList[AUDIO_MAX_VEHICLE_SOUNDS]; -rct_vehicle_sound_params *gVehicleSoundParamsListEnd; -sint32 gVolumeAdjustZoom = 0; - -sint32 _volumeAdjust[SOUND_MAXID] = { - 0, // SOUND_LIFT_1 - 0, // SOUND_TRACK_FRICTION_1 - 0, // SOUND_LIFT_2 - 0, // SOUND_SCREAM_1 - 0, // SOUND_CLICK_1 - 0, // SOUND_CLICK_2 - 0, // SOUND_PLACE_ITEM - 0, // SOUND_SCREAM_2 - 0, // SOUND_SCREAM_3 - 0, // SOUND_SCREAM_4 - 0, // SOUND_SCREAM_5 - 0, // SOUND_SCREAM_6 - 0, // SOUND_LIFT_3 - -400, // SOUND_PURCHASE - 0, // SOUND_CRASH - 0, // SOUND_LAYING_OUT_WATER - 0, // SOUND_WATER_1 - 0, // SOUND_WATER_2 - 0, // SOUND_TRAIN_WHISTLE - 0, // SOUND_TRAIN_CHUGGING - -1000, // SOUND_WATER_SPLASH - 0, // SOUND_HAMMERING - -800, // SOUND_RIDE_LAUNCH_1 - -1700, // SOUND_RIDE_LAUNCH_2 - -700, // SOUND_COUGH_1 - -700, // SOUND_COUGH_2 - -700, // SOUND_COUGH_3 - -700, // SOUND_COUGH_4 - 0, // SOUND_RAIN_1 - 0, // SOUND_THUNDER_1 - 0, // SOUND_THUNDER_2 - 0, // SOUND_RAIN_2 - 0, // SOUND_RAIN_3 - 0, // SOUND_BALLOON_POP - -700, // SOUND_MECHANIC_FIX - 0, // SOUND_SCREAM_7 - -2500, // SOUND_TOILET_FLUSH original value: -1000 - 0, // SOUND_CLICK_3 - 0, // SOUND_QUACK - 0, // SOUND_NEWS_ITEM - 0, // SOUND_WINDOW_OPEN - -900, // SOUND_LAUGH_1 - -900, // SOUND_LAUGH_2 - -900, // SOUND_LAUGH_3 - 0, // SOUND_APPLAUSE - -600, // SOUND_HAUNTED_HOUSE_SCARE - -700, // SOUND_HAUNTED_HOUSE_SCREAM_1 - -700, // SOUND_HAUNTED_HOUSE_SCREAM_2 - -2550, // SOUND_48 - -2900, // SOUND_49 - 0, // SOUND_ERROR - -3400, // SOUND_51 - 0, // SOUND_LIFT_4 - 0, // SOUND_LIFT_5 - 0, // SOUND_TRACK_FRICTION_2 - 0, // SOUND_LIFT_6 - 0, // SOUND_LIFT_7 - 0, // SOUND_TRACK_FRICTION_3 - 0, // SOUND_SCREAM_8 - 0, // SOUND_TRAM - -2000, // SOUND_DOOR_OPEN - -2700, // SOUND_DOOR_CLOSE - -700 // SOUND_62 +struct AudioParams +{ + bool in_range; + sint32 volume; + sint32 pan; }; -rct_audio_params audio_get_params_from_location(sint32 soundId, const rct_xyz16 *location); -void audio_stop_channel(void **channel); +audio_device * gAudioDevices = nullptr; +sint32 gAudioDeviceCount; +sint32 gAudioCurrentDevice = -1; + +bool gGameSoundsOff = false; +sint32 gVolumeAdjustZoom = 0; + +void * gTitleMusicChannel = nullptr; +void * gRainSoundChannel = nullptr; + +rct_ride_music gRideMusicList[AUDIO_MAX_RIDE_MUSIC]; +rct_ride_music_params gRideMusicParamsList[6]; +rct_ride_music_params * gRideMusicParamsListEnd; + +rct_vehicle_sound gVehicleSoundList[AUDIO_MAX_VEHICLE_SOUNDS]; +rct_vehicle_sound_params gVehicleSoundParamsList[AUDIO_MAX_VEHICLE_SOUNDS]; +rct_vehicle_sound_params * gVehicleSoundParamsListEnd; + +static sint32 SoundVolumeAdjust[SOUND_MAXID] = +{ + 0, // SOUND_LIFT_1 + 0, // SOUND_TRACK_FRICTION_1 + 0, // SOUND_LIFT_2 + 0, // SOUND_SCREAM_1 + 0, // SOUND_CLICK_1 + 0, // SOUND_CLICK_2 + 0, // SOUND_PLACE_ITEM + 0, // SOUND_SCREAM_2 + 0, // SOUND_SCREAM_3 + 0, // SOUND_SCREAM_4 + 0, // SOUND_SCREAM_5 + 0, // SOUND_SCREAM_6 + 0, // SOUND_LIFT_3 + -400, // SOUND_PURCHASE + 0, // SOUND_CRASH + 0, // SOUND_LAYING_OUT_WATER + 0, // SOUND_WATER_1 + 0, // SOUND_WATER_2 + 0, // SOUND_TRAIN_WHISTLE + 0, // SOUND_TRAIN_CHUGGING + -1000, // SOUND_WATER_SPLASH + 0, // SOUND_HAMMERING + -800, // SOUND_RIDE_LAUNCH_1 + -1700, // SOUND_RIDE_LAUNCH_2 + -700, // SOUND_COUGH_1 + -700, // SOUND_COUGH_2 + -700, // SOUND_COUGH_3 + -700, // SOUND_COUGH_4 + 0, // SOUND_RAIN_1 + 0, // SOUND_THUNDER_1 + 0, // SOUND_THUNDER_2 + 0, // SOUND_RAIN_2 + 0, // SOUND_RAIN_3 + 0, // SOUND_BALLOON_POP + -700, // SOUND_MECHANIC_FIX + 0, // SOUND_SCREAM_7 + -2500, // SOUND_TOILET_FLUSH original value: -1000 + 0, // SOUND_CLICK_3 + 0, // SOUND_QUACK + 0, // SOUND_NEWS_ITEM + 0, // SOUND_WINDOW_OPEN + -900, // SOUND_LAUGH_1 + -900, // SOUND_LAUGH_2 + -900, // SOUND_LAUGH_3 + 0, // SOUND_APPLAUSE + -600, // SOUND_HAUNTED_HOUSE_SCARE + -700, // SOUND_HAUNTED_HOUSE_SCREAM_1 + -700, // SOUND_HAUNTED_HOUSE_SCREAM_2 + -2550, // SOUND_48 + -2900, // SOUND_49 + 0, // SOUND_ERROR + -3400, // SOUND_51 + 0, // SOUND_LIFT_4 + 0, // SOUND_LIFT_5 + 0, // SOUND_TRACK_FRICTION_2 + 0, // SOUND_LIFT_6 + 0, // SOUND_LIFT_7 + 0, // SOUND_TRACK_FRICTION_3 + 0, // SOUND_SCREAM_8 + 0, // SOUND_TRAM + -2000, // SOUND_DOOR_OPEN + -2700, // SOUND_DOOR_CLOSE + -700 // SOUND_62 +}; + +AudioParams audio_get_params_from_location(sint32 soundId, const rct_xyz16 *location); void audio_init() { - sint32 result = SDL_Init(SDL_INIT_AUDIO); - if (result < 0) { - log_error("SDL_Init %s", SDL_GetError()); - return; - } + if (str_is_null_or_empty(gConfigSound.device)) + { + Mixer_Init(NULL); + gAudioCurrentDevice = 0; + } + else + { + Mixer_Init(gConfigSound.device); - if (str_is_null_or_empty(gConfigSound.device)) { - Mixer_Init(NULL); - gAudioCurrentDevice = 0; - } else { - Mixer_Init(gConfigSound.device); - for (sint32 i = 0; i < gAudioDeviceCount; i++) { - if (strcmp(gAudioDevices[i].name, gConfigSound.device) == 0) { - gAudioCurrentDevice = i; - } - } - } -} - -void audio_quit() -{ - SDL_QuitSubSystem(SDL_INIT_AUDIO); + audio_populate_devices(); + for (sint32 i = 0; i < gAudioDeviceCount; i++) + { + if (String::Equals(gAudioDevices[i].name, gConfigSound.device)) + { + gAudioCurrentDevice = i; + } + } + } } void audio_populate_devices() { - if (gAudioDevices != NULL) - free(gAudioDevices); + if (gAudioDevices != nullptr) + { + Memory::Free(gAudioDevices); + gAudioDevices = nullptr; + } - gAudioDeviceCount = SDL_GetNumAudioDevices(SDL_FALSE); - if (gAudioDeviceCount <= 0) - return; + IAudioContext * audioContext = OpenRCT2::GetContext()->GetAudioContext(); + std::vector devices = audioContext->GetOutputDevices(); - audio_device * systemAudioDevices = Memory::AllocateArray(gAudioDeviceCount); - for (sint32 i = 0; i < gAudioDeviceCount; i++) { - const char *utf8Name = SDL_GetAudioDeviceName(i, SDL_FALSE); - if (utf8Name == NULL) - utf8Name = language_get_string(STR_OPTIONS_SOUND_VALUE_UNKNOWN); + // Replace blanks with localised unknown string + for (size_t i = 0; i < devices.size(); i++) + { + if (devices[i].empty()) + { + devices[i] = language_get_string(STR_OPTIONS_SOUND_VALUE_DEFAULT); + } + } - safe_strcpy(systemAudioDevices[i].name, utf8Name, AUDIO_DEVICE_NAME_SIZE); - } #ifndef __LINUX__ - gAudioDeviceCount++; - gAudioDevices = Memory::AllocateArray(gAudioDeviceCount); - safe_strcpy(gAudioDevices[0].name, language_get_string(STR_OPTIONS_SOUND_VALUE_DEFAULT), AUDIO_DEVICE_NAME_SIZE); - Memory::CopyArray(&gAudioDevices[1], systemAudioDevices, gAudioDeviceCount - 1); -#else - gAudioDevices = Memory::AllocateArray(gAudioDeviceCount); - Memory::CopyArray(gAudioDevices, systemAudioDevices, gAudioDeviceCount); -#endif // __LINUX__ + // The first device is always system default on Windows and macOS + std::string defaultDevice = language_get_string(STR_OPTIONS_SOUND_VALUE_DEFAULT); + devices.insert(devices.begin(), defaultDevice); +#endif - free(systemAudioDevices); -} - -sint32 audio_play_sound_panned(sint32 soundId, sint32 pan, sint16 x, sint16 y, sint16 z) -{ - if (pan == AUDIO_PLAY_AT_LOCATION) - return audio_play_sound_at_location(soundId, x, y, z); - - return audio_play_sound(soundId, 0, pan); + gAudioDeviceCount = (sint32)devices.size(); + gAudioDevices = Memory::AllocateArray(gAudioDeviceCount); + for (sint32 i = 0; i < gAudioDeviceCount; i++) + { + auto device = &gAudioDevices[i]; + String::Set(device->name, sizeof(device->name), devices[i].c_str()); + } } sint32 audio_play_sound_at_location(sint32 soundId, sint16 x, sint16 y, sint16 z) { - if (gGameSoundsOff) - return 0; + if (gGameSoundsOff) + return 0; - rct_xyz16 location; - location.x = x; - location.y = y; - location.z = z; + rct_xyz16 location; + location.x = x; + location.y = y; + location.z = z; - rct_audio_params params = audio_get_params_from_location(soundId, &location); - if (!params.in_range) - return soundId; - - return audio_play_sound(soundId, params.volume, params.pan); + AudioParams params = audio_get_params_from_location(soundId, &location); + if (params.in_range) + { + soundId = audio_play_sound(soundId, params.volume, params.pan); + } + return soundId; } /** @@ -211,229 +215,249 @@ sint32 audio_play_sound_at_location(sint32 soundId, sint16 x, sint16 y, sint16 z * @param location The location at which the sound effect is to be played. * @return The audio parameters to be used when playing this sound effect. */ -rct_audio_params audio_get_params_from_location(sint32 soundId, const rct_xyz16 *location) +AudioParams audio_get_params_from_location(sint32 soundId, const rct_xyz16 *location) { - sint32 volumeDown = 0; - rct_audio_params params; - params.in_range = true; - params.volume = 0; - params.pan = 0; + sint32 volumeDown = 0; + AudioParams params; + params.in_range = true; + params.volume = 0; + params.pan = 0; - rct_map_element *element = map_get_surface_element_at(location->x / 32, location->y / 32); - if (element && (element->base_height * 8) - 5 > location->z) - volumeDown = 10; + rct_map_element * element = map_get_surface_element_at(location->x >> 5, location->y >> 5); + if (element && (element->base_height * 8) - 5 > location->z) + { + volumeDown = 10; + } - uint8 rotation = get_current_rotation(); - rct_xy16 pos2 = coordinate_3d_to_2d(location, rotation); - rct_window *window = gWindowNextSlot; - while (true) { - window--; - if (window < g_window_list) - break; + uint8 rotation = get_current_rotation(); + rct_xy16 pos2 = coordinate_3d_to_2d(location, rotation); + rct_window * window = gWindowNextSlot; + while (true) + { + window--; + if (window < g_window_list) + { + break; + } - rct_viewport *viewport = window->viewport; - if (!viewport || !(viewport->flags & VIEWPORT_FLAG_SOUND_ON)) - continue; + rct_viewport * viewport = window->viewport; + if (viewport != nullptr && (viewport->flags & VIEWPORT_FLAG_SOUND_ON)) + { + sint16 vy = pos2.y - viewport->view_y; + sint16 vx = pos2.x - viewport->view_x; + params.pan = viewport->x + (vx >> viewport->zoom); + params.volume = SoundVolumeAdjust[soundId] + ((-1024 * viewport->zoom - 1) << volumeDown) + 1; - sint16 vy = pos2.y - viewport->view_y; - sint16 vx = pos2.x - viewport->view_x; - params.pan = viewport->x + (vx >> viewport->zoom); - params.volume = _volumeAdjust[soundId] + ((-1024 * viewport->zoom - 1) << volumeDown) + 1; + if (vy < 0 || vy >= viewport->view_height || vx < 0 || vx >= viewport->view_width || params.volume < -10000) + { + params.in_range = false; + return params; + } + } + } - if (vy < 0 || vy >= viewport->view_height || vx < 0 || vx >= viewport->view_width || params.volume < -10000) { - params.in_range = false; - return params; - } - } - - return params; + return params; } sint32 audio_play_sound(sint32 soundId, sint32 volume, sint32 pan) { - if (gGameSoundsOff) - return 0; + if (gGameSoundsOff) + return 0; - sint32 mixerPan = 0; - if (pan != AUDIO_PLAY_AT_CENTRE) { - sint32 x2 = pan << 16; - uint16 screenWidth = Math::Max(64, OpenRCT2::GetContext()->GetUiContext()->GetWidth()); - mixerPan = ((x2 / screenWidth) - 0x8000) >> 4; - } + sint32 mixerPan = 0; + if (pan != AUDIO_PLAY_AT_CENTRE) + { + sint32 x2 = pan << 16; + uint16 screenWidth = Math::Max(64, OpenRCT2::GetContext()->GetUiContext()->GetWidth()); + mixerPan = ((x2 / screenWidth) - 0x8000) >> 4; + } - Mixer_Play_Effect(soundId, MIXER_LOOP_NONE, DStoMixerVolume(volume), DStoMixerPan(mixerPan), 1, 1); - return 0; + Mixer_Play_Effect(soundId, MIXER_LOOP_NONE, DStoMixerVolume(volume), DStoMixerPan(mixerPan), 1, 1); + return 0; } void audio_start_title_music() { - if (gGameSoundsOff || !(gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) || gIntroState != INTRO_STATE_NONE) { - audio_stop_title_music(); - return; - } + if (gGameSoundsOff || !(gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) || gIntroState != INTRO_STATE_NONE) + { + audio_stop_title_music(); + return; + } - if (gTitleMusicChannel) - return; + if (gTitleMusicChannel != nullptr) + { + return; + } - sint32 pathId; - switch (gConfigSound.title_music) { - case 1: - pathId = PATH_ID_CSS50; - break; - case 2: - pathId = PATH_ID_CSS17; - break; - case 3: - if (util_rand() & 1) - pathId = PATH_ID_CSS50; - else - pathId = PATH_ID_CSS17; - break; - default: - return; - } + sint32 pathId; + switch (gConfigSound.title_music) { + case 1: + pathId = PATH_ID_CSS50; + break; + case 2: + pathId = PATH_ID_CSS17; + break; + case 3: + pathId = (util_rand() & 1) ? PATH_ID_CSS50 : + PATH_ID_CSS17; + break; + default: + return; + } - gTitleMusicChannel = Mixer_Play_Music(pathId, MIXER_LOOP_INFINITE, true); - if (gTitleMusicChannel != NULL) { - Mixer_Channel_SetGroup(gTitleMusicChannel, MIXER_GROUP_TITLE_MUSIC); - } + gTitleMusicChannel = Mixer_Play_Music(pathId, MIXER_LOOP_INFINITE, true); + if (gTitleMusicChannel != nullptr) + { + Mixer_Channel_SetGroup(gTitleMusicChannel, MIXER_GROUP_TITLE_MUSIC); + } } void audio_stop_ride_music() { - for (sint32 i = 0; i < AUDIO_MAX_RIDE_MUSIC; i++) { - rct_ride_music *rideMusic = &gRideMusicList[i]; - if (rideMusic->ride_id == (uint8)-1) - continue; - - if (rideMusic->sound_channel) - Mixer_Stop_Channel(rideMusic->sound_channel); - - rideMusic->ride_id = -1; - } + for (sint32 i = 0; i < AUDIO_MAX_RIDE_MUSIC; i++) + { + rct_ride_music * rideMusic = &gRideMusicList[i]; + if (rideMusic->ride_id != RIDE_ID_NULL) + { + rideMusic->ride_id = RIDE_ID_NULL; + if (rideMusic->sound_channel != nullptr) + { + Mixer_Stop_Channel(rideMusic->sound_channel); + } + } + } } void audio_stop_all_music_and_sounds() { - audio_stop_title_music(); - audio_stop_vehicle_sounds(); - audio_stop_ride_music(); - peep_stop_crowd_noise(); - audio_stop_rain_sound(); + audio_stop_title_music(); + audio_stop_vehicle_sounds(); + audio_stop_ride_music(); + peep_stop_crowd_noise(); + audio_stop_rain_sound(); } void audio_stop_title_music() { - audio_stop_channel(&gTitleMusicChannel); + if (gTitleMusicChannel != nullptr) + { + Mixer_Stop_Channel(gTitleMusicChannel); + gTitleMusicChannel = nullptr; + } } void audio_stop_rain_sound() { - audio_stop_channel(&gRainSoundChannel); -} - -/** -* Stops the specified audio channel from playing. -* @param channel The channel to stop. -*/ -void audio_stop_channel(void **channel) -{ - if (!*channel) - return; - - Mixer_Stop_Channel(*channel); - *channel = 0; + if (gRainSoundChannel != nullptr) + { + Mixer_Stop_Channel(gRainSoundChannel); + gRainSoundChannel = nullptr; + } } void audio_init_ride_sounds_and_info() { - sint32 deviceNum = 0; - audio_init_ride_sounds(deviceNum); + sint32 deviceNum = 0; + audio_init_ride_sounds(deviceNum); - for (size_t m = 0; m < Util::CountOf(gRideMusicInfoList); m++) { - rct_ride_music_info *rideMusicInfo = gRideMusicInfoList[m]; - const utf8 *path = get_file_path(rideMusicInfo->path_id); - if (File::Exists(path)) - { - try - { - auto fs = FileStream(path, FILE_MODE_OPEN); - uint32 head = fs.ReadValue(); - if (head == 0x78787878) { - rideMusicInfo->length = 0; - } - } - catch (const Exception &) - { - } - } - } + for (size_t m = 0; m < Util::CountOf(gRideMusicInfoList); m++) + { + rct_ride_music_info *rideMusicInfo = gRideMusicInfoList[m]; + const utf8 *path = get_file_path(rideMusicInfo->path_id); + if (File::Exists(path)) + { + try + { + auto fs = FileStream(path, FILE_MODE_OPEN); + uint32 head = fs.ReadValue(); + if (head == 0x78787878) + { + rideMusicInfo->length = 0; + } + } + catch (const Exception &) + { + } + } + } } void audio_init_ride_sounds(sint32 device) { - audio_close(); - for (sint32 i = 0; i < AUDIO_MAX_VEHICLE_SOUNDS; i++) { - rct_vehicle_sound *vehicleSound = &gVehicleSoundList[i]; - vehicleSound->id = -1; - } + audio_close(); + for (sint32 i = 0; i < AUDIO_MAX_VEHICLE_SOUNDS; i++) + { + rct_vehicle_sound * vehicleSound = &gVehicleSoundList[i]; + vehicleSound->id = 0xFFFF; + } - gAudioCurrentDevice = device; - config_save_default(); - for (sint32 i = 0; i < AUDIO_MAX_RIDE_MUSIC; i++) { - rct_ride_music *rideMusic = &gRideMusicList[i]; - rideMusic->ride_id = -1; - } + gAudioCurrentDevice = device; + config_save_default(); + for (sint32 i = 0; i < AUDIO_MAX_RIDE_MUSIC; i++) + { + rct_ride_music * rideMusic = &gRideMusicList[i]; + rideMusic->ride_id = RIDE_ID_NULL; + } } void audio_close() { - peep_stop_crowd_noise(); - audio_stop_title_music(); - audio_stop_ride_music(); - audio_stop_rain_sound(); - gAudioCurrentDevice = -1; + peep_stop_crowd_noise(); + audio_stop_title_music(); + audio_stop_ride_music(); + audio_stop_rain_sound(); + gAudioCurrentDevice = -1; } void audio_toggle_all_sounds() { - if (gGameSoundsOff) { - audio_unpause_sounds(); - } else { - audio_pause_sounds(); - } + gConfigSound.sound_enabled = !gConfigSound.sound_enabled; + if (gConfigSound.sound_enabled) + { + audio_unpause_sounds(); + } + else + { + audio_stop_title_music(); + audio_pause_sounds(); + } } void audio_pause_sounds() { - gGameSoundsOff = true; - audio_stop_vehicle_sounds(); - audio_stop_ride_music(); - peep_stop_crowd_noise(); - audio_stop_rain_sound(); + gGameSoundsOff = true; + audio_stop_vehicle_sounds(); + audio_stop_ride_music(); + peep_stop_crowd_noise(); + audio_stop_rain_sound(); } void audio_unpause_sounds() { - gGameSoundsOff = false; + gGameSoundsOff = false; } void audio_stop_vehicle_sounds() { - if (gOpenRCT2Headless || gAudioCurrentDevice == -1) - return; + if (gAudioCurrentDevice == -1) + { + return; + } - for (size_t i = 0; i < Util::CountOf(gVehicleSoundList); i++) { - rct_vehicle_sound *vehicleSound = &gVehicleSoundList[i]; - if (vehicleSound->id == 0xFFFF) - continue; - - if (vehicleSound->sound1_id != 0xFFFF) - Mixer_Stop_Channel(vehicleSound->sound1_channel); - - if (vehicleSound->sound2_id != 0xFFFF) - Mixer_Stop_Channel(vehicleSound->sound2_channel); - - vehicleSound->id = 0xFFFF; - } + for (size_t i = 0; i < Util::CountOf(gVehicleSoundList); i++) + { + rct_vehicle_sound * vehicleSound = &gVehicleSoundList[i]; + if (vehicleSound->id != 0xFFFF) + { + vehicleSound->id = 0xFFFF; + if (vehicleSound->sound1_id != 0xFFFF) + { + Mixer_Stop_Channel(vehicleSound->sound1_channel); + } + if (vehicleSound->sound2_id != 0xFFFF) + { + Mixer_Stop_Channel(vehicleSound->sound2_channel); + } + } + } } diff --git a/src/openrct2/audio/audio.h b/src/openrct2/audio/audio.h index 0e96de0265..537b33d324 100644 --- a/src/openrct2/audio/audio.h +++ b/src/openrct2/audio/audio.h @@ -17,167 +17,164 @@ #pragma once #include "../common.h" -#include "../world/sprite.h" #ifdef __cplusplus extern "C" { #endif -#define AUDIO_DEVICE_NAME_SIZE 256 -#define AUDIO_MAX_RIDE_MUSIC 2 -#define AUDIO_MAX_VEHICLE_SOUNDS 14 -#define NUM_DEFAULT_MUSIC_TRACKS 46 -#define AUDIO_PLAY_AT_CENTRE 0x8000 -#define AUDIO_PLAY_AT_LOCATION 0x8001 +#define AUDIO_DEVICE_NAME_SIZE 256 +#define AUDIO_MAX_RIDE_MUSIC 2 +#define AUDIO_MAX_VEHICLE_SOUNDS 14 +#define NUM_DEFAULT_MUSIC_TRACKS 46 +#define AUDIO_PLAY_AT_CENTRE 0x8000 +#define AUDIO_PLAY_AT_LOCATION 0x8001 -typedef struct audio_device { - char name[AUDIO_DEVICE_NAME_SIZE]; +typedef struct audio_device +{ + char name[AUDIO_DEVICE_NAME_SIZE]; } audio_device; -#pragma pack(push, 1) - -typedef struct rct_ride_music { - uint8 ride_id; - uint8 tune_id; - sint16 volume; - sint16 pan; - uint16 frequency; - void* sound_channel; +typedef struct rct_ride_music +{ + uint8 ride_id; + uint8 tune_id; + sint16 volume; + sint16 pan; + uint16 frequency; + void* sound_channel; } rct_ride_music; -#ifdef PLATFORM_32BIT -assert_struct_size(rct_ride_music, 12); -#endif -typedef struct rct_ride_music_info { - uint32 length; - uint32 offset; - uint8 path_id; - uint8 var_9; +typedef struct rct_ride_music_info +{ + uint32 length; + uint32 offset; + uint8 path_id; + uint8 var_9; } rct_ride_music_info; -assert_struct_size(rct_ride_music_info, 10); -typedef struct rct_ride_music_params { - uint8 ride_id; - uint8 tune_id; - sint32 offset; - sint16 volume; - sint16 pan; - uint16 frequency; +typedef struct rct_ride_music_params +{ + uint8 ride_id; + uint8 tune_id; + sint32 offset; + sint16 volume; + sint16 pan; + uint16 frequency; } rct_ride_music_params; -assert_struct_size(rct_ride_music_params, 12); -typedef struct rct_vehicle_sound { - uint16 id; - sint16 volume; - uint16 sound1_id; - sint16 sound1_volume; - sint16 sound1_pan; - uint16 sound1_freq; - uint16 sound2_id; - sint16 sound2_volume; - sint16 sound2_pan; - uint16 sound2_freq; - void* sound1_channel; - void* sound2_channel; +typedef struct rct_vehicle_sound +{ + uint16 id; + sint16 volume; + uint16 sound1_id; + sint16 sound1_volume; + sint16 sound1_pan; + uint16 sound1_freq; + uint16 sound2_id; + sint16 sound2_volume; + sint16 sound2_pan; + uint16 sound2_freq; + void* sound1_channel; + void* sound2_channel; } rct_vehicle_sound; -#ifdef PLATFORM_32BIT -assert_struct_size(rct_vehicle_sound, 28); -#endif -typedef struct rct_vehicle_sound_params { - uint16 id; - sint16 pan_x; - sint16 pan_y; - uint16 frequency; - sint16 volume; - uint16 var_A; +typedef struct rct_vehicle_sound_params +{ + uint16 id; + sint16 pan_x; + sint16 pan_y; + uint16 frequency; + sint16 volume; + uint16 var_A; } rct_vehicle_sound_params; -assert_struct_size(rct_vehicle_sound_params, 12); -#pragma pack(pop) - -typedef enum RCT2_SOUND { - SOUND_LIFT_1 = 0, - SOUND_TRACK_FRICTION_1 = 1, - SOUND_LIFT_2 = 2, - SOUND_SCREAM_1 = 3, - SOUND_CLICK_1 = 4, - SOUND_CLICK_2 = 5, - SOUND_PLACE_ITEM = 6, - SOUND_SCREAM_2 = 7, - SOUND_SCREAM_3 = 8, - SOUND_SCREAM_4 = 9, - SOUND_SCREAM_5 = 10, - SOUND_SCREAM_6 = 11, - SOUND_LIFT_3 = 12, - SOUND_PURCHASE = 13, - SOUND_CRASH = 14, - SOUND_LAYING_OUT_WATER = 15, - SOUND_WATER_1 = 16, - SOUND_WATER_2 = 17, - SOUND_TRAIN_WHISTLE = 18, - SOUND_TRAIN_CHUGGING = 19, - SOUND_WATER_SPLASH = 20, - SOUND_HAMMERING = 21, - SOUND_RIDE_LAUNCH_1 = 22, - SOUND_RIDE_LAUNCH_2 = 23, - SOUND_COUGH_1 = 24, - SOUND_COUGH_2 = 25, - SOUND_COUGH_3 = 26, - SOUND_COUGH_4 = 27, - SOUND_RAIN_1 = 28, - SOUND_THUNDER_1 = 29, - SOUND_THUNDER_2 = 30, - SOUND_RAIN_2 = 31, - SOUND_RAIN_3 = 32, - SOUND_BALLOON_POP = 33, - SOUND_MECHANIC_FIX = 34, - SOUND_SCREAM_7 = 35, - SOUND_TOILET_FLUSH = 36, - SOUND_CLICK_3 = 37, - SOUND_QUACK = 38, - SOUND_NEWS_ITEM = 39, - SOUND_WINDOW_OPEN = 40, - SOUND_LAUGH_1 = 41, - SOUND_LAUGH_2 = 42, - SOUND_LAUGH_3 = 43, - SOUND_APPLAUSE = 44, - SOUND_HAUNTED_HOUSE_SCARE = 45, - SOUND_HAUNTED_HOUSE_SCREAM_1 = 46, - SOUND_HAUNTED_HOUSE_SCREAM_2 = 47, - SOUND_48 = 48, - SOUND_49 = 49, - SOUND_ERROR = 50, - SOUND_51 = 51, - SOUND_LIFT_4 = 52, - SOUND_LIFT_5 = 53, - SOUND_TRACK_FRICTION_2 = 54, - SOUND_LIFT_6 = 55, - SOUND_LIFT_7 = 56, - SOUND_TRACK_FRICTION_3 = 57, - SOUND_SCREAM_8 = 58, - SOUND_TRAM = 59, - SOUND_DOOR_OPEN = 60, - SOUND_DOOR_CLOSE = 61, - SOUND_62 = 62, - SOUND_MAXID +typedef enum RCT2_SOUND +{ + SOUND_LIFT_1, + SOUND_TRACK_FRICTION_1, + SOUND_LIFT_2, + SOUND_SCREAM_1, + SOUND_CLICK_1, + SOUND_CLICK_2, + SOUND_PLACE_ITEM, + SOUND_SCREAM_2, + SOUND_SCREAM_3, + SOUND_SCREAM_4, + SOUND_SCREAM_5, + SOUND_SCREAM_6, + SOUND_LIFT_3, + SOUND_PURCHASE, + SOUND_CRASH, + SOUND_LAYING_OUT_WATER, + SOUND_WATER_1, + SOUND_WATER_2, + SOUND_TRAIN_WHISTLE, + SOUND_TRAIN_CHUGGING, + SOUND_WATER_SPLASH, + SOUND_HAMMERING, + SOUND_RIDE_LAUNCH_1, + SOUND_RIDE_LAUNCH_2, + SOUND_COUGH_1, + SOUND_COUGH_2, + SOUND_COUGH_3, + SOUND_COUGH_4, + SOUND_RAIN_1, + SOUND_THUNDER_1, + SOUND_THUNDER_2, + SOUND_RAIN_2, + SOUND_RAIN_3, + SOUND_BALLOON_POP, + SOUND_MECHANIC_FIX, + SOUND_SCREAM_7, + SOUND_TOILET_FLUSH, + SOUND_CLICK_3, + SOUND_QUACK, + SOUND_NEWS_ITEM, + SOUND_WINDOW_OPEN, + SOUND_LAUGH_1, + SOUND_LAUGH_2, + SOUND_LAUGH_3, + SOUND_APPLAUSE, + SOUND_HAUNTED_HOUSE_SCARE, + SOUND_HAUNTED_HOUSE_SCREAM_1, + SOUND_HAUNTED_HOUSE_SCREAM_2, + SOUND_48, + SOUND_49, + SOUND_ERROR, + SOUND_51, + SOUND_LIFT_4, + SOUND_LIFT_5, + SOUND_TRACK_FRICTION_2, + SOUND_LIFT_6, + SOUND_LIFT_7, + SOUND_TRACK_FRICTION_3, + SOUND_SCREAM_8, + SOUND_TRAM, + SOUND_DOOR_OPEN, + SOUND_DOOR_CLOSE, + SOUND_62, + SOUND_MAXID } RCT2_SOUND; -extern audio_device *gAudioDevices; -extern sint32 gAudioDeviceCount; -extern sint32 gAudioCurrentDevice; -extern bool gGameSoundsOff; -extern void *gRainSoundChannel; -extern rct_ride_music gRideMusicList[AUDIO_MAX_RIDE_MUSIC]; -extern rct_ride_music_info *gRideMusicInfoList[NUM_DEFAULT_MUSIC_TRACKS]; -extern rct_ride_music_params gRideMusicParamsList[6]; -extern rct_ride_music_params *gRideMusicParamsListEnd; -extern void *gTitleMusicChannel; -extern rct_vehicle_sound gVehicleSoundList[AUDIO_MAX_VEHICLE_SOUNDS]; -extern rct_vehicle_sound_params gVehicleSoundParamsList[AUDIO_MAX_VEHICLE_SOUNDS]; -extern rct_vehicle_sound_params *gVehicleSoundParamsListEnd; -extern sint32 gVolumeAdjustZoom; +extern audio_device * gAudioDevices; +extern sint32 gAudioDeviceCount; +extern sint32 gAudioCurrentDevice; + +extern bool gGameSoundsOff; +extern sint32 gVolumeAdjustZoom; + +extern void * gTitleMusicChannel; +extern void * gRainSoundChannel; + +extern rct_ride_music gRideMusicList[AUDIO_MAX_RIDE_MUSIC]; +extern rct_ride_music_info * gRideMusicInfoList[NUM_DEFAULT_MUSIC_TRACKS]; +extern rct_ride_music_params gRideMusicParamsList[6]; +extern rct_ride_music_params * gRideMusicParamsListEnd; + +extern rct_vehicle_sound gVehicleSoundList[AUDIO_MAX_VEHICLE_SOUNDS]; +extern rct_vehicle_sound_params gVehicleSoundParamsList[AUDIO_MAX_VEHICLE_SOUNDS]; +extern rct_vehicle_sound_params * gVehicleSoundParamsListEnd; /** * Deregisters the audio device. @@ -222,29 +219,10 @@ sint32 audio_play_sound(sint32 soundId, sint32 volume, sint32 pan); */ sint32 audio_play_sound_at_location(sint32 soundId, sint16 x, sint16 y, sint16 z); /** -* rct2: 0x006BB76E -* @deprecated Use audio_play_sound_at_location or audio_play_sound instead. -* Plays the specified sound effect at a location specified by the pan parameter. -* @param soundId (eax) The sound effect to play. -* @param pan (ebx) If set to AUDIO_PLAY_AT_LOCATION, play the sound at the specified location; if set to AUDIO_PLAY_AT_CENTRE, -* play the sound at the centre of the viewport; if set to anything else, use the value of pan as a relative position to the -* centre of the viewport. -* @param x (cx) The x coordinate of the location. -* @param y (dx) The y coordinate of the location. -* @param z (bp) The z coordinate of the location. -* @return 0 if the sound was not out of range; otherwise, soundId. -*/ -sint32 audio_play_sound_panned(sint32 soundId, sint32 pan, sint16 x, sint16 y, sint16 z); -/** * Populates the gAudioDevices array with the available audio devices. */ void audio_populate_devices(); /** -* Terminates the audio subsystem. -* This appears to be unused. -*/ -void audio_quit(); -/** * Starts playing the title music. * rct2: 0x006BD0F8 */ diff --git a/src/openrct2/input.c b/src/openrct2/input.c index 3a82b54037..2673b885bc 100644 --- a/src/openrct2/input.c +++ b/src/openrct2/input.c @@ -1017,7 +1017,7 @@ static void input_widget_left(sint32 x, sint32 y, rct_window *w, rct_widgetindex break; default: if (widget_is_enabled(w, widgetIndex) && !widget_is_disabled(w, widgetIndex)) { - audio_play_sound_panned(SOUND_CLICK_1, w->x + (widget->left + widget->right) / 2, 0, 0, 0); + audio_play_sound(SOUND_CLICK_1, 0, w->x + ((widget->left + widget->right) / 2)); // Set new cursor down widget gPressedWidget.window_classification = windowClass; @@ -1271,7 +1271,7 @@ void input_state_widget_pressed(sint32 x, sint32 y, sint32 state, rct_widgetinde break; sint32 mid_point_x = (widget->left + widget->right) / 2 + w->x; - audio_play_sound_panned(5, mid_point_x, 0, 0, 0); + audio_play_sound(SOUND_CLICK_2, 0, mid_point_x); if (cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != cursor_widgetIndex) break; diff --git a/src/openrct2/interface/window.c b/src/openrct2/interface/window.c index 75dfd10f12..97824b2a85 100644 --- a/src/openrct2/interface/window.c +++ b/src/openrct2/interface/window.c @@ -456,7 +456,7 @@ rct_window *window_create(sint32 x, sint32 y, sint32 width, sint32 height, rct_w // Play sounds and flash the window if (!(flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT))){ w->flags |= WF_WHITE_BORDER_MASK; - audio_play_sound_panned(SOUND_WINDOW_OPEN, x + (width / 2), 0, 0, 0); + audio_play_sound(SOUND_WINDOW_OPEN, 0, x + (width / 2)); } w->number = 0; diff --git a/src/openrct2/management/news_item.c b/src/openrct2/management/news_item.c index 6726b2821b..85ffbec1cd 100644 --- a/src/openrct2/management/news_item.c +++ b/src/openrct2/management/news_item.c @@ -98,7 +98,7 @@ static void news_item_tick_current() // Only play news item sound when in normal playing mode if (ticks == 1 && (gScreenFlags == SCREEN_FLAGS_PLAYING)) { // Play sound - audio_play_sound_panned(SOUND_NEWS_ITEM, context_get_width() / 2, 0, 0, 0); + audio_play_sound(SOUND_NEWS_ITEM, 0, context_get_width() / 2); } } diff --git a/src/openrct2/peep/peep.c b/src/openrct2/peep/peep.c index f4e9bc39a0..22769e79bd 100644 --- a/src/openrct2/peep/peep.c +++ b/src/openrct2/peep/peep.c @@ -7008,7 +7008,7 @@ void peep_applause() } // Play applause noise - audio_play_sound_panned(SOUND_APPLAUSE, context_get_width() / 2, 0, 0, 0); + audio_play_sound(SOUND_APPLAUSE, 0, context_get_width() / 2); } /** diff --git a/src/openrct2/ride/ride.h b/src/openrct2/ride/ride.h index 8909ac1c2c..605ba53df6 100644 --- a/src/openrct2/ride/ride.h +++ b/src/openrct2/ride/ride.h @@ -900,7 +900,8 @@ typedef struct rct_ride_properties { extern const rct_ride_properties RideProperties[RIDE_TYPE_COUNT]; -#define MAX_RIDES 255 +#define MAX_RIDES 255 +#define RIDE_ID_NULL 255 #define RIDE_MODE_COUNT 37 diff --git a/src/openrct2/windows/editor_object_selection.c b/src/openrct2/windows/editor_object_selection.c index dee737a89f..ab6dd26fa3 100644 --- a/src/openrct2/windows/editor_object_selection.c +++ b/src/openrct2/windows/editor_object_selection.c @@ -1004,7 +1004,7 @@ static void window_editor_object_selection_scroll_mousedown(rct_window *w, sint3 window_invalidate(w); const CursorState * state = context_get_cursor_state(); - audio_play_sound_panned(SOUND_CLICK_1, state->x, 0, 0, 0); + audio_play_sound(SOUND_CLICK_1, 0, state->x); if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) { diff --git a/src/openrct2/windows/error.c b/src/openrct2/windows/error.c index cc874b8693..3c980207db 100644 --- a/src/openrct2/windows/error.c +++ b/src/openrct2/windows/error.c @@ -139,7 +139,7 @@ void window_error_open(rct_string_id title, rct_string_id message) w->widgets = window_error_widgets; w->error.var_480 = 0; if (!gDisableErrorWindowSound) { - audio_play_sound_panned(SOUND_ERROR, 0, w->x + (w->width / 2), 0, 0); + audio_play_sound(SOUND_ERROR, 0, w->x + (w->width / 2)); } } diff --git a/src/openrct2/windows/new_ride.c b/src/openrct2/windows/new_ride.c index 2fdffcd9f6..7859426b9b 100644 --- a/src/openrct2/windows/new_ride.c +++ b/src/openrct2/windows/new_ride.c @@ -695,7 +695,7 @@ static void window_new_ride_scrollmousedown(rct_window *w, sint32 scrollIndex, s _windowNewRideHighlightedItem[_windowNewRideCurrentTab] = item; w->new_ride.selected_ride_id = item.ride_type_and_entry; - audio_play_sound_panned(SOUND_CLICK_1, w->x + (w->width / 2), 0, 0, 0); + audio_play_sound(SOUND_CLICK_1, 0, w->x + (w->width / 2)); w->new_ride.selected_ride_countdown = 8; window_invalidate(w); } diff --git a/src/openrct2/windows/news.c b/src/openrct2/windows/news.c index ac2cd2ad3d..eca56716b5 100644 --- a/src/openrct2/windows/news.c +++ b/src/openrct2/windows/news.c @@ -145,7 +145,7 @@ static void window_news_update(rct_window *w) return; window_invalidate(w); - audio_play_sound_panned(SOUND_CLICK_2, w->x + (w->width / 2), 0, 0, 0); + audio_play_sound(SOUND_CLICK_2, 0, w->x + (w->width / 2)); j = w->news.var_480; w->news.var_480 = -1; @@ -237,7 +237,7 @@ static void window_news_scrollmousedown(rct_window *w, sint32 scrollIndex, sint3 w->news.var_482 = buttonIndex; w->news.var_484 = 4; window_invalidate(w); - audio_play_sound_panned(SOUND_CLICK_1, w->x + (w->width / 2), 0, 0, 0); + audio_play_sound(SOUND_CLICK_1, 0, w->x + (w->width / 2)); } } diff --git a/src/openrct2/windows/ride_construction.c b/src/openrct2/windows/ride_construction.c index 5744c192c9..ed1432499b 100644 --- a/src/openrct2/windows/ride_construction.c +++ b/src/openrct2/windows/ride_construction.c @@ -3925,7 +3925,7 @@ void ride_construction_tooldown_construct(sint32 screenX, sint32 screenY) zAttempts == 0 || z < 0 ) { - audio_play_sound_panned(SOUND_ERROR, state->x, x, y, z); + audio_play_sound(SOUND_ERROR, 0, state->x); w = window_find_by_class(WC_RIDE_CONSTRUCTION); if (w != NULL){ tool_set(w, WIDX_CONSTRUCT, TOOL_CROSSHAIR); @@ -3997,7 +3997,7 @@ void ride_construction_tooldown_construct(sint32 screenX, sint32 screenY) _currentTrackAlternative = saveCurrentTrackAlternative; _currentTrackLiftHill = saveCurrentTrackLiftHill; - audio_play_sound_panned(SOUND_ERROR, state->x, x, y, z); + audio_play_sound(SOUND_ERROR, 0, state->x); break; } else if (zAttempts >= 0) { z += 16; diff --git a/src/openrct2/windows/scenery.c b/src/openrct2/windows/scenery.c index 4969baa6c2..2e11b4094c 100644 --- a/src/openrct2/windows/scenery.c +++ b/src/openrct2/windows/scenery.c @@ -843,7 +843,7 @@ void window_scenery_scrollmousedown(rct_window *w, sint32 scrollIndex, sint32 x, gWindowSceneryPaintEnabled &= 0xFE; gWindowSceneryEyedropperEnabled = false; - audio_play_sound_panned(4, (w->width >> 1) + w->x, 0, 0, 0); + audio_play_sound(4, 0, w->x + (w->width / 2)); w->scenery.hover_counter = -16; gSceneryPlaceCost = MONEY32_UNDEFINED; window_invalidate(w); diff --git a/src/openrct2/windows/title_scenarioselect.c b/src/openrct2/windows/title_scenarioselect.c index f9eb5c3b48..42b95539ee 100644 --- a/src/openrct2/windows/title_scenarioselect.c +++ b/src/openrct2/windows/title_scenarioselect.c @@ -286,7 +286,7 @@ static void window_scenarioselect_scrollmousedown(rct_window *w, sint32 scrollIn case LIST_ITEM_TYPE_SCENARIO: y -= 24; if (y < 0 && !listItem->scenario.is_locked) { - audio_play_sound_panned(SOUND_CLICK_1, w->width / 2 + w->x, 0, 0, 0); + audio_play_sound(SOUND_CLICK_1, 0, w->x + (w->width / 2)); _callback(listItem->scenario.scenario->path); } break; diff --git a/src/openrct2/windows/track_list.c b/src/openrct2/windows/track_list.c index 4e44db18f0..89bd81afe3 100644 --- a/src/openrct2/windows/track_list.c +++ b/src/openrct2/windows/track_list.c @@ -193,7 +193,7 @@ static void window_track_list_select(rct_window *w, sint32 index) return; } - audio_play_sound_panned(SOUND_CLICK_1, w->x + (w->width / 2), 0, 0, 0); + audio_play_sound(SOUND_CLICK_1, 0, w->x + (w->width / 2)); if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)) { if (index == 0) { window_close(w);