mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-06 06:32:56 +01:00
clang-format audio
This commit is contained in:
committed by
Hielke Morsink
parent
90f1a328ab
commit
77f3513cba
@@ -7,25 +7,25 @@
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "../config/Config.h"
|
||||
#include "audio.h"
|
||||
|
||||
#include "../Context.h"
|
||||
#include "../Intro.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../config/Config.h"
|
||||
#include "../core/File.h"
|
||||
#include "../core/FileStream.hpp"
|
||||
#include "../core/Memory.hpp"
|
||||
#include "../core/String.hpp"
|
||||
#include "../interface/Viewport.h"
|
||||
#include "../localisation/Language.h"
|
||||
#include "../localisation/StringIds.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../ride/Ride.h"
|
||||
#include "../ui/UiContext.h"
|
||||
#include "audio.h"
|
||||
#include "../util/Util.h"
|
||||
#include "AudioContext.h"
|
||||
#include "AudioMixer.h"
|
||||
|
||||
#include "../interface/Viewport.h"
|
||||
#include "../Intro.h"
|
||||
#include "../localisation/Language.h"
|
||||
#include "../ride/Ride.h"
|
||||
#include "../util/Util.h"
|
||||
|
||||
using namespace OpenRCT2::Audio;
|
||||
|
||||
struct AudioParams
|
||||
@@ -35,23 +35,23 @@ struct AudioParams
|
||||
int32_t pan;
|
||||
};
|
||||
|
||||
audio_device * gAudioDevices = nullptr;
|
||||
int32_t gAudioDeviceCount;
|
||||
int32_t gAudioCurrentDevice = -1;
|
||||
audio_device* gAudioDevices = nullptr;
|
||||
int32_t gAudioDeviceCount;
|
||||
int32_t gAudioCurrentDevice = -1;
|
||||
|
||||
bool gGameSoundsOff = false;
|
||||
int32_t gVolumeAdjustZoom = 0;
|
||||
bool gGameSoundsOff = false;
|
||||
int32_t gVolumeAdjustZoom = 0;
|
||||
|
||||
void * gTitleMusicChannel = nullptr;
|
||||
void * gRainSoundChannel = nullptr;
|
||||
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_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;
|
||||
rct_vehicle_sound gVehicleSoundList[AUDIO_MAX_VEHICLE_SOUNDS];
|
||||
rct_vehicle_sound_params gVehicleSoundParamsList[AUDIO_MAX_VEHICLE_SOUNDS];
|
||||
rct_vehicle_sound_params* gVehicleSoundParamsListEnd;
|
||||
|
||||
// clang-format off
|
||||
static int32_t SoundVolumeAdjust[SOUND_MAXID] =
|
||||
@@ -122,7 +122,7 @@ static int32_t SoundVolumeAdjust[SOUND_MAXID] =
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
AudioParams audio_get_params_from_location(int32_t soundId, const LocationXYZ16 *location);
|
||||
AudioParams audio_get_params_from_location(int32_t soundId, const LocationXYZ16* location);
|
||||
|
||||
void audio_init()
|
||||
{
|
||||
@@ -154,7 +154,7 @@ void audio_populate_devices()
|
||||
std::vector<std::string> devices = audioContext->GetOutputDevices();
|
||||
|
||||
// Replace blanks with localised unknown string
|
||||
for (auto &device : devices)
|
||||
for (auto& device : devices)
|
||||
{
|
||||
if (device.empty())
|
||||
{
|
||||
@@ -196,12 +196,12 @@ int32_t audio_play_sound_at_location(int32_t soundId, int16_t x, int16_t y, int1
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the audio parameters to use when playing the specified sound at a virtual location.
|
||||
* @param soundId The sound effect to be played.
|
||||
* @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.
|
||||
*/
|
||||
AudioParams audio_get_params_from_location(int32_t soundId, const LocationXYZ16 *location)
|
||||
* Returns the audio parameters to use when playing the specified sound at a virtual location.
|
||||
* @param soundId The sound effect to be played.
|
||||
* @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.
|
||||
*/
|
||||
AudioParams audio_get_params_from_location(int32_t soundId, const LocationXYZ16* location)
|
||||
{
|
||||
int32_t volumeDown = 0;
|
||||
AudioParams params;
|
||||
@@ -209,7 +209,7 @@ AudioParams audio_get_params_from_location(int32_t soundId, const LocationXYZ16
|
||||
params.volume = 0;
|
||||
params.pan = 0;
|
||||
|
||||
rct_tile_element * element = map_get_surface_element_at({location->x, location->y});
|
||||
rct_tile_element* element = map_get_surface_element_at({ location->x, location->y });
|
||||
if (element && (element->base_height * 8) - 5 > location->z)
|
||||
{
|
||||
volumeDown = 10;
|
||||
@@ -218,7 +218,7 @@ AudioParams audio_get_params_from_location(int32_t soundId, const LocationXYZ16
|
||||
uint8_t rotation = get_current_rotation();
|
||||
LocationXY16 pos2 = coordinate_3d_to_2d(location, rotation);
|
||||
|
||||
rct_viewport * viewport = nullptr;
|
||||
rct_viewport* viewport = nullptr;
|
||||
while ((viewport = window_get_previous_viewport(viewport)) != nullptr)
|
||||
{
|
||||
if (viewport->flags & VIEWPORT_FLAG_SOUND_ON)
|
||||
@@ -270,19 +270,19 @@ void audio_start_title_music()
|
||||
}
|
||||
|
||||
int32_t 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;
|
||||
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);
|
||||
@@ -294,7 +294,7 @@ void audio_start_title_music()
|
||||
|
||||
void audio_stop_ride_music()
|
||||
{
|
||||
for (auto &rideMusic : gRideMusicList)
|
||||
for (auto& rideMusic : gRideMusicList)
|
||||
{
|
||||
if (rideMusic.ride_id != RIDE_ID_NULL)
|
||||
{
|
||||
@@ -339,9 +339,9 @@ void audio_init_ride_sounds_and_info()
|
||||
int32_t deviceNum = 0;
|
||||
audio_init_ride_sounds(deviceNum);
|
||||
|
||||
for (auto &rideMusicInfo : gRideMusicInfoList)
|
||||
for (auto& rideMusicInfo : gRideMusicInfoList)
|
||||
{
|
||||
const utf8 * path = context_get_path_legacy(rideMusicInfo.path_id);
|
||||
const utf8* path = context_get_path_legacy(rideMusicInfo.path_id);
|
||||
if (File::Exists(path))
|
||||
{
|
||||
try
|
||||
@@ -358,7 +358,7 @@ void audio_init_ride_sounds_and_info()
|
||||
rideMusicInfo.length = fs.GetLength();
|
||||
}
|
||||
}
|
||||
catch (const std::exception &)
|
||||
catch (const std::exception&)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -368,14 +368,14 @@ void audio_init_ride_sounds_and_info()
|
||||
void audio_init_ride_sounds(int32_t device)
|
||||
{
|
||||
audio_close();
|
||||
for (auto &vehicleSound : gVehicleSoundList)
|
||||
for (auto& vehicleSound : gVehicleSoundList)
|
||||
{
|
||||
vehicleSound.id = SOUND_ID_NULL;
|
||||
}
|
||||
|
||||
gAudioCurrentDevice = device;
|
||||
config_save_default();
|
||||
for (auto &rideMusic : gRideMusicList)
|
||||
for (auto& rideMusic : gRideMusicList)
|
||||
{
|
||||
rideMusic.ride_id = RIDE_ID_NULL;
|
||||
}
|
||||
@@ -425,7 +425,7 @@ void audio_stop_vehicle_sounds()
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto &vehicleSound : gVehicleSoundList)
|
||||
for (auto& vehicleSound : gVehicleSoundList)
|
||||
{
|
||||
if (vehicleSound.id != SOUND_ID_NULL)
|
||||
{
|
||||
|
||||
@@ -23,30 +23,30 @@ namespace OpenRCT2::Audio
|
||||
{
|
||||
virtual ~IAudioChannel() = default;
|
||||
|
||||
virtual IAudioSource * GetSource() const abstract;
|
||||
virtual IAudioSource* GetSource() const abstract;
|
||||
|
||||
virtual int32_t GetGroup() const abstract;
|
||||
virtual void SetGroup(int32_t group) abstract;
|
||||
virtual int32_t GetGroup() const abstract;
|
||||
virtual void SetGroup(int32_t group) abstract;
|
||||
|
||||
virtual double GetRate() const abstract;
|
||||
virtual void SetRate(double rate) abstract;
|
||||
virtual double GetRate() const abstract;
|
||||
virtual void SetRate(double rate) abstract;
|
||||
|
||||
virtual uint64_t GetOffset() const abstract;
|
||||
virtual bool SetOffset(uint64_t offset) abstract;
|
||||
virtual uint64_t GetOffset() const abstract;
|
||||
virtual bool SetOffset(uint64_t offset) abstract;
|
||||
|
||||
virtual int32_t GetLoop() const abstract;
|
||||
virtual void SetLoop(int32_t value) abstract;
|
||||
virtual int32_t GetLoop() const abstract;
|
||||
virtual void SetLoop(int32_t value) abstract;
|
||||
|
||||
virtual int32_t GetVolume() const abstract;
|
||||
virtual float GetVolumeL() const abstract;
|
||||
virtual float GetVolumeR() const abstract;
|
||||
virtual float GetOldVolumeL() const abstract;
|
||||
virtual float GetOldVolumeR() const abstract;
|
||||
virtual int32_t GetOldVolume() const abstract;
|
||||
virtual void SetVolume(int32_t volume) abstract;
|
||||
virtual int32_t GetVolume() const abstract;
|
||||
virtual float GetVolumeL() const abstract;
|
||||
virtual float GetVolumeR() const abstract;
|
||||
virtual float GetOldVolumeL() const abstract;
|
||||
virtual float GetOldVolumeR() const abstract;
|
||||
virtual int32_t GetOldVolume() const abstract;
|
||||
virtual void SetVolume(int32_t volume) abstract;
|
||||
|
||||
virtual float GetPan() const abstract;
|
||||
virtual void SetPan(float pan) abstract;
|
||||
virtual float GetPan() const abstract;
|
||||
virtual void SetPan(float pan) abstract;
|
||||
|
||||
virtual bool IsStopping() const abstract;
|
||||
virtual void SetStopping(bool value) abstract;
|
||||
@@ -64,6 +64,6 @@ namespace OpenRCT2::Audio
|
||||
virtual void Play(IAudioSource * source, int32_t loop = 0) abstract;
|
||||
virtual void UpdateOldVolume() abstract;
|
||||
|
||||
virtual size_t Read(void * dst, size_t len) abstract;
|
||||
virtual size_t Read(void* dst, size_t len) abstract;
|
||||
};
|
||||
} // namespace OpenRCT2::Audio
|
||||
|
||||
@@ -9,10 +9,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "../common.h"
|
||||
|
||||
namespace OpenRCT2::Audio
|
||||
{
|
||||
@@ -27,19 +28,18 @@ namespace OpenRCT2::Audio
|
||||
{
|
||||
virtual ~IAudioContext() = default;
|
||||
|
||||
virtual IAudioMixer * GetMixer() abstract;
|
||||
virtual IAudioMixer* GetMixer() abstract;
|
||||
|
||||
virtual std::vector<std::string> GetOutputDevices() abstract;
|
||||
virtual void SetOutputDevice(const std::string &deviceName) abstract;
|
||||
|
||||
virtual IAudioSource * CreateStreamFromWAV(const std::string &path) abstract;
|
||||
virtual void SetOutputDevice(const std::string& deviceName) abstract;
|
||||
|
||||
virtual IAudioSource* CreateStreamFromWAV(const std::string& path) abstract;
|
||||
|
||||
virtual void StartTitleMusic() abstract;
|
||||
|
||||
virtual IAudioChannel * PlaySound(int32_t soundId, int32_t volume, int32_t pan) abstract;
|
||||
virtual IAudioChannel * PlaySoundAtLocation(int32_t soundId, int16_t x, int16_t y, int16_t z) abstract;
|
||||
virtual IAudioChannel * PlaySoundPanned(int32_t soundId, int32_t pan, int16_t x, int16_t y, int16_t z) abstract;
|
||||
virtual IAudioChannel* PlaySound(int32_t soundId, int32_t volume, int32_t pan) abstract;
|
||||
virtual IAudioChannel* PlaySoundAtLocation(int32_t soundId, int16_t x, int16_t y, int16_t z) abstract;
|
||||
virtual IAudioChannel* PlaySoundPanned(int32_t soundId, int32_t pan, int16_t x, int16_t y, int16_t z) abstract;
|
||||
|
||||
virtual void ToggleAllSounds() abstract;
|
||||
virtual void PauseSounds() abstract;
|
||||
|
||||
@@ -7,25 +7,27 @@
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#include <cmath>
|
||||
#include "../config/Config.h"
|
||||
#include "AudioMixer.h"
|
||||
|
||||
#include "../Context.h"
|
||||
#include "audio.h"
|
||||
#include "../config/Config.h"
|
||||
#include "AudioChannel.h"
|
||||
#include "AudioContext.h"
|
||||
#include "AudioMixer.h"
|
||||
#include "AudioSource.h"
|
||||
#include "audio.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
using namespace OpenRCT2::Audio;
|
||||
|
||||
static IAudioMixer * GetMixer()
|
||||
static IAudioMixer* GetMixer()
|
||||
{
|
||||
auto audioContext = GetContext()->GetAudioContext();
|
||||
return audioContext->GetMixer();
|
||||
}
|
||||
|
||||
void Mixer_Init(const char * device)
|
||||
void Mixer_Init(const char* device)
|
||||
{
|
||||
auto audioContext = GetContext()->GetAudioContext();
|
||||
if (device == nullptr)
|
||||
@@ -35,9 +37,9 @@ void Mixer_Init(const char * device)
|
||||
audioContext->SetOutputDevice(std::string(device));
|
||||
}
|
||||
|
||||
void * Mixer_Play_Effect(size_t id, int32_t loop, int32_t volume, float pan, double rate, int32_t deleteondone)
|
||||
void* Mixer_Play_Effect(size_t id, int32_t loop, int32_t volume, float pan, double rate, int32_t deleteondone)
|
||||
{
|
||||
IAudioChannel * channel = nullptr;
|
||||
IAudioChannel* channel = nullptr;
|
||||
if (gConfigSound.sound_enabled)
|
||||
{
|
||||
if (id >= SOUND_MAXID)
|
||||
@@ -46,11 +48,11 @@ void * Mixer_Play_Effect(size_t id, int32_t loop, int32_t volume, float pan, dou
|
||||
}
|
||||
else
|
||||
{
|
||||
IAudioMixer * mixer = GetMixer();
|
||||
IAudioMixer* mixer = GetMixer();
|
||||
if (mixer != nullptr)
|
||||
{
|
||||
mixer->Lock();
|
||||
IAudioSource * source = mixer->GetSoundSource((int32_t)id);
|
||||
IAudioSource* source = mixer->GetSoundSource((int32_t)id);
|
||||
channel = mixer->Play(source, loop, deleteondone != 0, false);
|
||||
if (channel != nullptr)
|
||||
{
|
||||
@@ -65,7 +67,7 @@ void * Mixer_Play_Effect(size_t id, int32_t loop, int32_t volume, float pan, dou
|
||||
return channel;
|
||||
}
|
||||
|
||||
void Mixer_Stop_Channel(void * channel)
|
||||
void Mixer_Stop_Channel(void* channel)
|
||||
{
|
||||
auto mixer = GetMixer();
|
||||
if (mixer != nullptr)
|
||||
@@ -74,9 +76,9 @@ void Mixer_Stop_Channel(void * channel)
|
||||
}
|
||||
}
|
||||
|
||||
void Mixer_Channel_Volume(void * channel, int32_t volume)
|
||||
void Mixer_Channel_Volume(void* channel, int32_t volume)
|
||||
{
|
||||
IAudioMixer * audioMixer = GetMixer();
|
||||
IAudioMixer* audioMixer = GetMixer();
|
||||
if (audioMixer != nullptr)
|
||||
{
|
||||
audioMixer->Lock();
|
||||
@@ -85,9 +87,9 @@ void Mixer_Channel_Volume(void * channel, int32_t volume)
|
||||
}
|
||||
}
|
||||
|
||||
void Mixer_Channel_Pan(void * channel, float pan)
|
||||
void Mixer_Channel_Pan(void* channel, float pan)
|
||||
{
|
||||
IAudioMixer * audioMixer = GetMixer();
|
||||
IAudioMixer* audioMixer = GetMixer();
|
||||
if (audioMixer != nullptr)
|
||||
{
|
||||
audioMixer->Lock();
|
||||
@@ -98,7 +100,7 @@ void Mixer_Channel_Pan(void * channel, float pan)
|
||||
|
||||
void Mixer_Channel_Rate(void* channel, double rate)
|
||||
{
|
||||
IAudioMixer * audioMixer = GetMixer();
|
||||
IAudioMixer* audioMixer = GetMixer();
|
||||
if (audioMixer != nullptr)
|
||||
{
|
||||
audioMixer->Lock();
|
||||
@@ -107,38 +109,38 @@ void Mixer_Channel_Rate(void* channel, double rate)
|
||||
}
|
||||
}
|
||||
|
||||
int32_t Mixer_Channel_IsPlaying(void * channel)
|
||||
int32_t Mixer_Channel_IsPlaying(void* channel)
|
||||
{
|
||||
return static_cast<IAudioChannel*>(channel)->IsPlaying();
|
||||
}
|
||||
|
||||
uint64_t Mixer_Channel_GetOffset(void * channel)
|
||||
uint64_t Mixer_Channel_GetOffset(void* channel)
|
||||
{
|
||||
return static_cast<IAudioChannel*>(channel)->GetOffset();
|
||||
}
|
||||
|
||||
int32_t Mixer_Channel_SetOffset(void * channel, uint64_t offset)
|
||||
int32_t Mixer_Channel_SetOffset(void* channel, uint64_t offset)
|
||||
{
|
||||
return static_cast<IAudioChannel*>(channel)->SetOffset(offset);
|
||||
}
|
||||
|
||||
void Mixer_Channel_SetGroup(void * channel, int32_t group)
|
||||
void Mixer_Channel_SetGroup(void* channel, int32_t group)
|
||||
{
|
||||
static_cast<IAudioChannel *>(channel)->SetGroup(group);
|
||||
static_cast<IAudioChannel*>(channel)->SetGroup(group);
|
||||
}
|
||||
|
||||
void * Mixer_Play_Music(int32_t pathId, int32_t loop, int32_t streaming)
|
||||
void* Mixer_Play_Music(int32_t pathId, int32_t loop, int32_t streaming)
|
||||
{
|
||||
IAudioChannel * channel = nullptr;
|
||||
IAudioMixer * mixer = GetMixer();
|
||||
IAudioChannel* channel = nullptr;
|
||||
IAudioMixer* mixer = GetMixer();
|
||||
if (mixer != nullptr)
|
||||
{
|
||||
if (streaming)
|
||||
{
|
||||
const utf8 * path = context_get_path_legacy(pathId);
|
||||
const utf8* path = context_get_path_legacy(pathId);
|
||||
|
||||
auto audioContext = GetContext()->GetAudioContext();
|
||||
IAudioSource * source = audioContext->CreateStreamFromWAV(path);
|
||||
IAudioSource* source = audioContext->CreateStreamFromWAV(path);
|
||||
if (source != nullptr)
|
||||
{
|
||||
channel = mixer->Play(source, loop, false, true);
|
||||
@@ -152,7 +154,7 @@ void * Mixer_Play_Music(int32_t pathId, int32_t loop, int32_t streaming)
|
||||
{
|
||||
if (mixer->LoadMusic(pathId))
|
||||
{
|
||||
IAudioSource * source = mixer->GetMusicSource(pathId);
|
||||
IAudioSource* source = mixer->GetMusicSource(pathId);
|
||||
channel = mixer->Play(source, MIXER_LOOP_INFINITE, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
#define MIXER_VOLUME_MAX 128
|
||||
#define MIXER_LOOP_NONE 0
|
||||
#define MIXER_LOOP_INFINITE (-1)
|
||||
#define MIXER_VOLUME_MAX 128
|
||||
#define MIXER_LOOP_NONE 0
|
||||
#define MIXER_LOOP_INFINITE (-1)
|
||||
|
||||
enum MIXER_GROUP
|
||||
{
|
||||
@@ -34,17 +34,17 @@ namespace OpenRCT2::Audio
|
||||
{
|
||||
virtual ~IAudioMixer() = default;
|
||||
|
||||
virtual void Init(const char * device) abstract;
|
||||
virtual void Init(const char* device) abstract;
|
||||
virtual void Close() abstract;
|
||||
virtual void Lock() abstract;
|
||||
virtual void Unlock() abstract;
|
||||
virtual IAudioChannel * Play(IAudioSource * source, int32_t loop, bool deleteondone, bool deletesourceondone) abstract;
|
||||
virtual IAudioChannel* Play(IAudioSource * source, int32_t loop, bool deleteondone, bool deletesourceondone) abstract;
|
||||
virtual void Stop(IAudioChannel * channel) abstract;
|
||||
virtual bool LoadMusic(size_t pathid) abstract;
|
||||
virtual void SetVolume(float volume) abstract;
|
||||
|
||||
virtual IAudioSource * GetSoundSource(int32_t id) abstract;
|
||||
virtual IAudioSource * GetMusicSource(int32_t id) abstract;
|
||||
virtual IAudioSource* GetSoundSource(int32_t id) abstract;
|
||||
virtual IAudioSource* GetMusicSource(int32_t id) abstract;
|
||||
};
|
||||
} // namespace OpenRCT2::Audio
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace OpenRCT2::Audio
|
||||
#define DSBPAN_RIGHT 10000
|
||||
#endif
|
||||
|
||||
void Mixer_Init(const char * device);
|
||||
void Mixer_Init(const char* device);
|
||||
void* Mixer_Play_Effect(size_t id, int32_t loop, int32_t volume, float pan, double rate, int32_t deleteondone);
|
||||
void Mixer_Stop_Channel(void* channel);
|
||||
void Mixer_Channel_Volume(void* channel, int32_t volume);
|
||||
@@ -71,4 +71,3 @@ void Mixer_SetVolume(float volume);
|
||||
int32_t DStoMixerVolume(int32_t volume);
|
||||
float DStoMixerPan(int32_t pan);
|
||||
double DStoMixerRate(int32_t frequency);
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ namespace OpenRCT2::Audio
|
||||
|
||||
virtual uint64_t GetLength() const abstract;
|
||||
// virtual AudioFormat GetFormat() abstract;
|
||||
virtual size_t Read(void * dst, uint64_t offset, size_t len) abstract;
|
||||
virtual size_t Read(void* dst, uint64_t offset, size_t len) abstract;
|
||||
};
|
||||
|
||||
namespace AudioSource
|
||||
{
|
||||
IAudioSource * CreateNull();
|
||||
IAudioSource* CreateNull();
|
||||
}
|
||||
} // namespace OpenRCT2::Audio
|
||||
|
||||
@@ -13,29 +13,70 @@ namespace OpenRCT2::Audio
|
||||
{
|
||||
class DummyAudioContext final : public IAudioContext
|
||||
{
|
||||
IAudioMixer * GetMixer() override { return nullptr; }
|
||||
IAudioMixer* GetMixer() override
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<std::string> GetOutputDevices() override { return std::vector<std::string>(); }
|
||||
void SetOutputDevice(const std::string &/*deviceName*/) override { }
|
||||
std::vector<std::string> GetOutputDevices() override
|
||||
{
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
void SetOutputDevice(const std::string& /*deviceName*/) override
|
||||
{
|
||||
}
|
||||
|
||||
IAudioSource * CreateStreamFromWAV(const std::string &/*path*/) override { return nullptr; }
|
||||
IAudioSource* CreateStreamFromWAV(const std::string& /*path*/) override
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void StartTitleMusic() override { }
|
||||
void StartTitleMusic() override
|
||||
{
|
||||
}
|
||||
|
||||
IAudioChannel * PlaySound(int32_t /*soundId*/, int32_t /*volume*/, int32_t /*pan*/) override { return nullptr; }
|
||||
IAudioChannel * PlaySoundAtLocation(int32_t /*soundId*/, int16_t /*x*/, int16_t /*y*/, int16_t /*z*/) override { return nullptr; }
|
||||
IAudioChannel * PlaySoundPanned(int32_t /*soundId*/, int32_t /*pan*/, int16_t /*x*/, int16_t /*y*/, int16_t /*z*/) override { return nullptr; }
|
||||
IAudioChannel* PlaySound(int32_t /*soundId*/, int32_t /*volume*/, int32_t /*pan*/) override
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
IAudioChannel* PlaySoundAtLocation(int32_t /*soundId*/, int16_t /*x*/, int16_t /*y*/, int16_t /*z*/) override
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
IAudioChannel*
|
||||
PlaySoundPanned(int32_t /*soundId*/, int32_t /*pan*/, int16_t /*x*/, int16_t /*y*/, int16_t /*z*/) override
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ToggleAllSounds() override { }
|
||||
void PauseSounds() override { }
|
||||
void UnpauseSounds() override { }
|
||||
void ToggleAllSounds() override
|
||||
{
|
||||
}
|
||||
void PauseSounds() override
|
||||
{
|
||||
}
|
||||
void UnpauseSounds() override
|
||||
{
|
||||
}
|
||||
|
||||
void StopAll() override { }
|
||||
void StopCrowdSound() override { }
|
||||
void StopRainSound() override { }
|
||||
void StopRideMusic() override { }
|
||||
void StopTitleMusic() override { }
|
||||
void StopVehicleSounds() override { }
|
||||
void StopAll() override
|
||||
{
|
||||
}
|
||||
void StopCrowdSound() override
|
||||
{
|
||||
}
|
||||
void StopRainSound() override
|
||||
{
|
||||
}
|
||||
void StopRideMusic() override
|
||||
{
|
||||
}
|
||||
void StopTitleMusic() override
|
||||
{
|
||||
}
|
||||
void StopVehicleSounds() override
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
std::unique_ptr<IAudioContext> CreateDummyAudioContext()
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace OpenRCT2::Audio
|
||||
}
|
||||
};
|
||||
|
||||
IAudioSource * AudioSource::CreateNull()
|
||||
IAudioSource* AudioSource::CreateNull()
|
||||
{
|
||||
return new NullAudioSource();
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
#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 SOUND_ID_NULL 0xFFFF
|
||||
#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 SOUND_ID_NULL 0xFFFF
|
||||
|
||||
struct audio_device
|
||||
{
|
||||
@@ -145,104 +145,104 @@ enum RCT2_SOUND
|
||||
SOUND_MAXID
|
||||
};
|
||||
|
||||
extern audio_device * gAudioDevices;
|
||||
extern int32_t gAudioDeviceCount;
|
||||
extern int32_t gAudioCurrentDevice;
|
||||
extern audio_device* gAudioDevices;
|
||||
extern int32_t gAudioDeviceCount;
|
||||
extern int32_t gAudioCurrentDevice;
|
||||
|
||||
extern bool gGameSoundsOff;
|
||||
extern int32_t gVolumeAdjustZoom;
|
||||
extern bool gGameSoundsOff;
|
||||
extern int32_t gVolumeAdjustZoom;
|
||||
|
||||
extern void * gTitleMusicChannel;
|
||||
extern void * gRainSoundChannel;
|
||||
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_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;
|
||||
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.
|
||||
* rct2: 0x006BAB21
|
||||
*/
|
||||
* Deregisters the audio device.
|
||||
* rct2: 0x006BAB21
|
||||
*/
|
||||
void audio_close();
|
||||
/**
|
||||
* Initialises the audio subsystem.
|
||||
*/
|
||||
* Initialises the audio subsystem.
|
||||
*/
|
||||
void audio_init();
|
||||
/**
|
||||
* Loads the ride sounds and info.
|
||||
* rct2: 0x006BA8E0
|
||||
*/
|
||||
* Loads the ride sounds and info.
|
||||
* rct2: 0x006BA8E0
|
||||
*/
|
||||
void audio_init_ride_sounds_and_info();
|
||||
/**
|
||||
* Loads the ride sounds.
|
||||
* rct2: 0x006BA9B5
|
||||
*/
|
||||
* Loads the ride sounds.
|
||||
* rct2: 0x006BA9B5
|
||||
*/
|
||||
void audio_init_ride_sounds(int32_t device);
|
||||
/**
|
||||
* Temporarily stops playing sounds until audio_unpause_sounds() is called.
|
||||
* rct2: 0x006BABB4
|
||||
*/
|
||||
* Temporarily stops playing sounds until audio_unpause_sounds() is called.
|
||||
* rct2: 0x006BABB4
|
||||
*/
|
||||
void audio_pause_sounds();
|
||||
/**
|
||||
* Plays the specified sound.
|
||||
* @param soundId The sound effect to play.
|
||||
* @param volume The volume at which the sound effect should be played.
|
||||
* @param pan The pan at which the sound effect should be played. If set to anything other than AUDIO_PLAY_AT_CENTRE, plays the
|
||||
* sound at a position relative to the centre of the viewport.
|
||||
* @return 0 if the sound was not out of range; otherwise, soundId.
|
||||
*/
|
||||
* Plays the specified sound.
|
||||
* @param soundId The sound effect to play.
|
||||
* @param volume The volume at which the sound effect should be played.
|
||||
* @param pan The pan at which the sound effect should be played. If set to anything other than AUDIO_PLAY_AT_CENTRE, plays the
|
||||
* sound at a position relative to the centre of the viewport.
|
||||
* @return 0 if the sound was not out of range; otherwise, soundId.
|
||||
*/
|
||||
int32_t audio_play_sound(int32_t soundId, int32_t volume, int32_t pan);
|
||||
/**
|
||||
* Plays the specified sound at a virtual location.
|
||||
* @param soundId The sound effect to play.
|
||||
* @param x The x coordinate of the location.
|
||||
* @param y The y coordinate of the location.
|
||||
* @param z The z coordinate of the location.
|
||||
* @return 0 if the sound was not out of range; otherwise, soundId.
|
||||
*/
|
||||
* Plays the specified sound at a virtual location.
|
||||
* @param soundId The sound effect to play.
|
||||
* @param x The x coordinate of the location.
|
||||
* @param y The y coordinate of the location.
|
||||
* @param z The z coordinate of the location.
|
||||
* @return 0 if the sound was not out of range; otherwise, soundId.
|
||||
*/
|
||||
int32_t audio_play_sound_at_location(int32_t soundId, int16_t x, int16_t y, int16_t z);
|
||||
/**
|
||||
* Populates the gAudioDevices array with the available audio devices.
|
||||
*/
|
||||
* Populates the gAudioDevices array with the available audio devices.
|
||||
*/
|
||||
void audio_populate_devices();
|
||||
/**
|
||||
* Starts playing the title music.
|
||||
* rct2: 0x006BD0F8
|
||||
*/
|
||||
* Starts playing the title music.
|
||||
* rct2: 0x006BD0F8
|
||||
*/
|
||||
void audio_start_title_music();
|
||||
/**
|
||||
* Stops the rain sound effect from playing.
|
||||
*/
|
||||
* Stops the rain sound effect from playing.
|
||||
*/
|
||||
void audio_stop_rain_sound();
|
||||
/**
|
||||
* Stops ride music from playing.
|
||||
* rct2: 0x006BCA9F
|
||||
*/
|
||||
* Stops ride music from playing.
|
||||
* rct2: 0x006BCA9F
|
||||
*/
|
||||
void audio_stop_ride_music();
|
||||
/**
|
||||
* Stops the title music from playing.
|
||||
* rct2: 0x006BD0BD
|
||||
*/
|
||||
* Stops the title music from playing.
|
||||
* rct2: 0x006BD0BD
|
||||
*/
|
||||
void audio_stop_title_music();
|
||||
/**
|
||||
* Stops vehicle sounds from playing.
|
||||
* rct2: 0x006BABDF
|
||||
*/
|
||||
* Stops vehicle sounds from playing.
|
||||
* rct2: 0x006BABDF
|
||||
*/
|
||||
void audio_stop_vehicle_sounds();
|
||||
/**
|
||||
* Toggles whether all sounds should be played.
|
||||
* rct2: 0x006BAB8A
|
||||
*/
|
||||
* Toggles whether all sounds should be played.
|
||||
* rct2: 0x006BAB8A
|
||||
*/
|
||||
void audio_toggle_all_sounds();
|
||||
/**
|
||||
* Resumes playing sounds that had been paused by a call to audio_pause_sounds().
|
||||
* rct2: 0x006BABD8
|
||||
*/
|
||||
* Resumes playing sounds that had been paused by a call to audio_pause_sounds().
|
||||
* rct2: 0x006BABD8
|
||||
*/
|
||||
void audio_unpause_sounds();
|
||||
|
||||
void audio_stop_all_music_and_sounds();
|
||||
|
||||
Reference in New Issue
Block a user