Move ride audio into own namespace

This commit is contained in:
Ted John 2021-01-20 21:10:17 +00:00
parent 28f4ec2b43
commit a9755609c2
6 changed files with 367 additions and 361 deletions

View File

@ -1375,7 +1375,7 @@ static void window_options_audio_mouseup(rct_window* w, rct_widgetindex widgetIn
gConfigSound.ride_music_enabled = !gConfigSound.ride_music_enabled; gConfigSound.ride_music_enabled = !gConfigSound.ride_music_enabled;
if (!gConfigSound.ride_music_enabled) if (!gConfigSound.ride_music_enabled)
{ {
RideAudioStopAllChannels(); OpenRCT2::RideAudio::StopAllChannels();
} }
config_save_default(); config_save_default();
w->Invalidate(); w->Invalidate();

View File

@ -292,7 +292,7 @@ namespace OpenRCT2::Audio
{ {
StopTitleMusic(); StopTitleMusic();
StopVehicleSounds(); StopVehicleSounds();
RideAudioStopAllChannels(); RideAudio::StopAllChannels();
peep_stop_crowd_noise(); peep_stop_crowd_noise();
StopWeatherSound(); StopWeatherSound();
} }
@ -357,7 +357,7 @@ namespace OpenRCT2::Audio
{ {
peep_stop_crowd_noise(); peep_stop_crowd_noise();
StopTitleMusic(); StopTitleMusic();
RideAudioStopAllChannels(); RideAudio::StopAllChannels();
StopWeatherSound(); StopWeatherSound();
_currentAudioDevice = -1; _currentAudioDevice = -1;
} }
@ -382,7 +382,7 @@ namespace OpenRCT2::Audio
{ {
gGameSoundsOff = true; gGameSoundsOff = true;
StopVehicleSounds(); StopVehicleSounds();
RideAudioStopAllChannels(); RideAudio::StopAllChannels();
peep_stop_crowd_noise(); peep_stop_crowd_noise();
StopWeatherSound(); StopWeatherSound();
} }

View File

@ -1785,7 +1785,7 @@ void window_close_construction_windows()
*/ */
void window_update_viewport_ride_music() void window_update_viewport_ride_music()
{ {
RideAudioClearAllViewportInstances(); OpenRCT2::RideAudio::ClearAllViewportInstances();
g_music_tracking_viewport = nullptr; g_music_tracking_viewport = nullptr;
for (auto it = g_window_list.rbegin(); it != g_window_list.rend(); it++) for (auto it = g_window_list.rbegin(); it != g_window_list.rend(); it++)

View File

@ -2038,7 +2038,7 @@ void Ride::UpdateAll()
for (auto& ride : GetRideManager()) for (auto& ride : GetRideManager())
ride.Update(); ride.Update();
RideUpdateMusicChannels(); OpenRCT2::RideAudio::UpdateMusicChannels();
} }
std::unique_ptr<TrackDesign> Ride::SaveToTrackDesign() const std::unique_ptr<TrackDesign> Ride::SaveToTrackDesign() const
@ -2923,7 +2923,7 @@ static void ride_music_update(Ride* ride)
sampleRate += 22050; sampleRate += 22050;
} }
RideUpdateMusicInstance(*ride, rideCoords, sampleRate); OpenRCT2::RideAudio::UpdateMusicInstance(*ride, rideCoords, sampleRate);
} }
#pragma endregion #pragma endregion

View File

@ -24,6 +24,9 @@
using namespace OpenRCT2; using namespace OpenRCT2;
using namespace OpenRCT2::Audio; using namespace OpenRCT2::Audio;
namespace OpenRCT2::RideAudio
{
constexpr uint8_t TUNE_ID_NULL = 0xFF;
constexpr size_t MAX_RIDE_MUSIC_CHANNELS = 32; constexpr size_t MAX_RIDE_MUSIC_CHANNELS = 32;
/** /**
@ -160,12 +163,12 @@ struct RideMusicChannel
static std::vector<ViewportRideMusicInstance> _musicInstances; static std::vector<ViewportRideMusicInstance> _musicInstances;
static std::vector<RideMusicChannel> _musicChannels; static std::vector<RideMusicChannel> _musicChannels;
void RideAudioStopAllChannels() void StopAllChannels()
{ {
_musicChannels.clear(); _musicChannels.clear();
} }
void RideAudioClearAllViewportInstances() void ClearAllViewportInstances()
{ {
_musicInstances.clear(); _musicInstances.clear();
} }
@ -247,7 +250,7 @@ static void UpdateRideMusicChannelForMusicParams(const ViewportRideMusicInstance
/** /**
* Start, update and stop audio channels for each ride music instance that can be heard across all viewports. * Start, update and stop audio channels for each ride music instance that can be heard across all viewports.
*/ */
void RideUpdateMusicChannels() void UpdateMusicChannels()
{ {
if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) != 0 || (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) != 0) if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) != 0 || (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) != 0)
return; return;
@ -301,7 +304,8 @@ static void RideUpdateMusicPosition(Ride& ride)
} }
} }
static void RideUpdateMusicPosition(Ride& ride, size_t offset, size_t length, int16_t volume, int16_t pan, uint16_t sampleRate) static void RideUpdateMusicPosition(
Ride& ride, size_t offset, size_t length, int16_t volume, int16_t pan, uint16_t sampleRate)
{ {
if (offset < length) if (offset < length)
{ {
@ -369,7 +373,7 @@ static uint8_t CalculateVolume(int32_t pan)
/** /**
* Register an instance of audible ride music for this frame at the given coordinates. * Register an instance of audible ride music for this frame at the given coordinates.
*/ */
void RideUpdateMusicInstance(Ride& ride, const CoordsXYZ& rideCoords, uint16_t sampleRate) void UpdateMusicInstance(Ride& ride, const CoordsXYZ& rideCoords, uint16_t sampleRate)
{ {
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gGameSoundsOff && g_music_tracking_viewport != nullptr) if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gGameSoundsOff && g_music_tracking_viewport != nullptr)
{ {
@ -420,3 +424,4 @@ void RideUpdateMusicInstance(Ride& ride, const CoordsXYZ& rideCoords, uint16_t s
} }
} }
} }
} // namespace OpenRCT2::RideAudio

View File

@ -14,9 +14,10 @@
struct CoordsXYZ; struct CoordsXYZ;
struct Ride; struct Ride;
constexpr uint8_t TUNE_ID_NULL = 0xFF; namespace OpenRCT2::RideAudio
{
void RideAudioClearAllViewportInstances(); void ClearAllViewportInstances();
void RideAudioStopAllChannels(); void StopAllChannels();
void RideUpdateMusicChannels(); void UpdateMusicChannels();
void RideUpdateMusicInstance(Ride& ride, const CoordsXYZ& rideCoords, uint16_t sampleRate); void UpdateMusicInstance(Ride& ride, const CoordsXYZ& rideCoords, uint16_t sampleRate);
} // namespace OpenRCT2::RideAudio