Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions plugin_sa/game_sa/AudioTypes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
Plugin-SDK (Grand Theft Auto San Andreas) header file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
#pragma once
#include "PluginBase.h"

struct tBeat {
UInt32 time;
UInt32 key;
};
VALIDATE_OFFSET(tBeat, time, 0x0);
VALIDATE_OFFSET(tBeat, key, 0x4);
VALIDATE_SIZE(tBeat, 0x8);

struct tBeatInfo {
tBeat beatWindow[20];
Int32 isBeatInfoPresent;
Int32 beatTypeThisFrame;
Int32 beatNumber;
};
VALIDATE_OFFSET(tBeatInfo, beatWindow, 0x0);
VALIDATE_OFFSET(tBeatInfo, isBeatInfoPresent, 0xA0);
VALIDATE_OFFSET(tBeatInfo, beatTypeThisFrame, 0xA4);
VALIDATE_OFFSET(tBeatInfo, beatNumber, 0xA8);
VALIDATE_SIZE(tBeatInfo, 0xAC);

struct tTrackInfo {
tBeat beats[1000];
UInt32 field_1F40[16];
UInt16 field_1F80;
};
VALIDATE_OFFSET(tTrackInfo, beats, 0x0);
VALIDATE_OFFSET(tTrackInfo, field_1F40, 0x1F40);
VALIDATE_OFFSET(tTrackInfo, field_1F80, 0x1F80);
VALIDATE_SIZE(tTrackInfo, 0x1F84);
32 changes: 16 additions & 16 deletions plugin_sa/game_sa/CAEAudioHardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

class PLUGIN_API CAEAudioHardware {
public:
unsigned char field_0;
char m_bDisableEffectsLoading;
char field_2;
char field_3;
char field_4;
bool m_bInitialised;
bool m_bDisableEffectsLoading;
bool m_bPrevMaxSecondarySlowFadeout;
bool m_bPrevMaxGlobalSlowFadeout;
Comment on lines +18 to +19

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: "Secondary" is the loudest frontend sound (channel flag 0x1), "Global" the loudest overall; the bools are its smooth ducking flag (0x80). Mobile SDK names:

Suggested change
bool m_bPrevMaxSecondarySlowFadeout;
bool m_bPrevMaxGlobalSlowFadeout;
bool m_bLoudestFrontendSoundWasSmoothDucking;
bool m_bLoudestOverallSoundWasSmoothDucking;

bool m_bHardwareMixAvailable;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set when dwFreeHw3DAllBuffers >= 24 (0x4D9AA5).

char m_nReverbEnvironment;
short m_awChannelFlags[64];
short field_86;
Expand All @@ -26,16 +26,16 @@ class PLUGIN_API CAEAudioHardware {
unsigned short m_nNumChannels;
short m_anNumSoundsInSlot[64];
float m_afChannelVolumes[64];
int field_210[64];
float m_afChannelGains[64]; // linear volume gain (10 ^ (dB / 20))
float m_afChannelsFrqScalingFactor[64];
float m_fMusicMasterScalingFactor;
float m_fEffectMasterScalingFactor;
float m_fMusicFaderScalingFactor;
float m_fEffectsFaderScalingFactor;
float m_fStreamFaderScalingFactor;
float m_fNonStreamFaderScalingFactor;
float field_428;
float field_42C;
float m_fNonStreamFaderScalingFactor; // order swapped with m_fStreamFaderScalingFactor?
Comment on lines 35 to +36

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swapped: SetNonStreamFaderScalingFactor (0x4D95A0) writes 0x420, SetStreamFaderScalingFactor (0x4D95B0) writes 0x424.

Suggested change
float m_fStreamFaderScalingFactor;
float m_fNonStreamFaderScalingFactor;
float field_428;
float field_42C;
float m_fNonStreamFaderScalingFactor; // order swapped with m_fStreamFaderScalingFactor?
float m_fNonStreamFaderScalingFactor;
float m_fStreamFaderScalingFactor;

float m_fPrevMaxVolumeSecondary;
float m_fPrevMaxVolumeGlobal;
Comment on lines +37 to +38

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
float m_fPrevMaxVolumeSecondary;
float m_fPrevMaxVolumeGlobal;
float m_fLoudestFrontendSoundVolumeLastFrame;
float m_fLoudestOverallSoundVolumeLastFrame;

short m_aBankSlotIds[300];
short m_aSoundTypes[300];
short m_anVirtualChannelSoundLoopStartTimes[300];
Expand Down Expand Up @@ -64,11 +64,11 @@ class PLUGIN_API CAEAudioHardware {
public:
int GetActiveTrackID();
};
VALIDATE_OFFSET(CAEAudioHardware, field_0, 0x0);
VALIDATE_OFFSET(CAEAudioHardware, m_bInitialised, 0x0);
VALIDATE_OFFSET(CAEAudioHardware, m_bDisableEffectsLoading, 0x1);
VALIDATE_OFFSET(CAEAudioHardware, field_2, 0x2);
VALIDATE_OFFSET(CAEAudioHardware, field_3, 0x3);
VALIDATE_OFFSET(CAEAudioHardware, field_4, 0x4);
VALIDATE_OFFSET(CAEAudioHardware, m_bPrevMaxSecondarySlowFadeout, 0x2);
VALIDATE_OFFSET(CAEAudioHardware, m_bPrevMaxGlobalSlowFadeout, 0x3);
Comment on lines +69 to +70

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
VALIDATE_OFFSET(CAEAudioHardware, m_bPrevMaxSecondarySlowFadeout, 0x2);
VALIDATE_OFFSET(CAEAudioHardware, m_bPrevMaxGlobalSlowFadeout, 0x3);
VALIDATE_OFFSET(CAEAudioHardware, m_bLoudestFrontendSoundWasSmoothDucking, 0x2);
VALIDATE_OFFSET(CAEAudioHardware, m_bLoudestOverallSoundWasSmoothDucking, 0x3);

VALIDATE_OFFSET(CAEAudioHardware, m_bHardwareMixAvailable, 0x4);
VALIDATE_OFFSET(CAEAudioHardware, m_nReverbEnvironment, 0x5);
VALIDATE_OFFSET(CAEAudioHardware, m_awChannelFlags, 0x6);
VALIDATE_OFFSET(CAEAudioHardware, field_86, 0x86);
Expand All @@ -77,16 +77,16 @@ VALIDATE_OFFSET(CAEAudioHardware, m_wNumAvailableChannels, 0x8C);
VALIDATE_OFFSET(CAEAudioHardware, m_nNumChannels, 0x8E);
VALIDATE_OFFSET(CAEAudioHardware, m_anNumSoundsInSlot, 0x90);
VALIDATE_OFFSET(CAEAudioHardware, m_afChannelVolumes, 0x110);
VALIDATE_OFFSET(CAEAudioHardware, field_210, 0x210);
VALIDATE_OFFSET(CAEAudioHardware, m_afChannelGains, 0x210);
VALIDATE_OFFSET(CAEAudioHardware, m_afChannelsFrqScalingFactor, 0x310);
VALIDATE_OFFSET(CAEAudioHardware, m_fMusicMasterScalingFactor, 0x410);
VALIDATE_OFFSET(CAEAudioHardware, m_fEffectMasterScalingFactor, 0x414);
VALIDATE_OFFSET(CAEAudioHardware, m_fMusicFaderScalingFactor, 0x418);
VALIDATE_OFFSET(CAEAudioHardware, m_fEffectsFaderScalingFactor, 0x41C);
VALIDATE_OFFSET(CAEAudioHardware, m_fStreamFaderScalingFactor, 0x420);
VALIDATE_OFFSET(CAEAudioHardware, m_fNonStreamFaderScalingFactor, 0x424);
Comment on lines 86 to 87

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
VALIDATE_OFFSET(CAEAudioHardware, m_fStreamFaderScalingFactor, 0x420);
VALIDATE_OFFSET(CAEAudioHardware, m_fNonStreamFaderScalingFactor, 0x424);
VALIDATE_OFFSET(CAEAudioHardware, m_fNonStreamFaderScalingFactor, 0x420);
VALIDATE_OFFSET(CAEAudioHardware, m_fStreamFaderScalingFactor, 0x424);

VALIDATE_OFFSET(CAEAudioHardware, field_428, 0x428);
VALIDATE_OFFSET(CAEAudioHardware, field_42C, 0x42C);
VALIDATE_OFFSET(CAEAudioHardware, m_fPrevMaxVolumeSecondary, 0x428);
VALIDATE_OFFSET(CAEAudioHardware, m_fPrevMaxVolumeGlobal, 0x42C);
Comment on lines +88 to +89

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
VALIDATE_OFFSET(CAEAudioHardware, m_fPrevMaxVolumeSecondary, 0x428);
VALIDATE_OFFSET(CAEAudioHardware, m_fPrevMaxVolumeGlobal, 0x42C);
VALIDATE_OFFSET(CAEAudioHardware, m_fLoudestFrontendSoundVolumeLastFrame, 0x428);
VALIDATE_OFFSET(CAEAudioHardware, m_fLoudestOverallSoundVolumeLastFrame, 0x42C);

VALIDATE_OFFSET(CAEAudioHardware, m_aBankSlotIds, 0x430);
VALIDATE_OFFSET(CAEAudioHardware, m_aSoundTypes, 0x688);
VALIDATE_OFFSET(CAEAudioHardware, m_anVirtualChannelSoundLoopStartTimes, 0x8E0);
Expand Down
4 changes: 2 additions & 2 deletions plugin_sa/game_sa/CAERadioTrackManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ char *CAERadioTrackManager::GetRadioStationName(signed char id)
return ((char *(__thiscall *)(CAERadioTrackManager *, signed char))0x4E9E10)(this, id);
}

void CAERadioTrackManager::StartRadio(int stationId, float bass, int arg, char unused) {
plugin::CallMethod<0x4EB3C0, CAERadioTrackManager*, int, float, int, char>(this, stationId, bass, arg, unused);
void CAERadioTrackManager::StartRadio(eRadioID stationId, float bass, int arg, char unused) {
plugin::CallMethod<0x4EB3C0, CAERadioTrackManager*, eRadioID, float, int, char>(this, stationId, bass, arg, unused);
Comment on lines +21 to +22

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void CAERadioTrackManager::StartRadio(eRadioID stationId, float bass, int arg, char unused) {
plugin::CallMethod<0x4EB3C0, CAERadioTrackManager*, eRadioID, float, int, char>(this, stationId, bass, arg, unused);
void CAERadioTrackManager::StartRadio(eRadioID stationId, Int8 bassSetting, float bassGain, bool skipTrack) {
plugin::CallMethod<0x4EB3C0, CAERadioTrackManager*, eRadioID, Int8, float, bool>(this, stationId, bassSetting, bassGain, skipTrack);

}

void CAERadioTrackManager::StopRadio(tVehicleAudioSettings* settings, char arg) {
Expand Down
5 changes: 3 additions & 2 deletions plugin_sa/game_sa/CAERadioTrackManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "PluginBase.h"
#include "CAEVehicleAudioEntity.h"
#include "eRadioID.h"

struct PLUGIN_API tRadioSettings {
Int32 TrackIDs[5];
Expand All @@ -16,7 +17,7 @@ struct PLUGIN_API tRadioSettings {
Int32 PlayTime;
Int32 TrackLengthMs;
UInt8 TrackFlags;
Int8 StationID; // eRadioID
eRadioID StationID;
Int8 BassSetting;
Int8 _pad27;
float BassFactor;
Expand Down Expand Up @@ -110,7 +111,7 @@ class PLUGIN_API CAERadioTrackManager {
public:
bool IsVehicleRadioActive();
char* GetRadioStationName(signed char id);
void StartRadio(int stationId, float bass, int arg, char unused);
void StartRadio(eRadioID stationId, float bass, int arg, char unused);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real signature: _ZN20CAERadioTrackManager10StartRadioEaafh. The args go to settings2 +0x25/+0x26/+0x28, the last one is passed to 0x4EAC30 (Service passes 1).

Suggested change
void StartRadio(eRadioID stationId, float bass, int arg, char unused);
void StartRadio(eRadioID stationId, Int8 bassSetting, float bassGain, bool skipTrack);

void StopRadio(tVehicleAudioSettings* settings, char arg);

static void Load();
Expand Down
8 changes: 4 additions & 4 deletions plugin_sa/game_sa/CAudioEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ void CAudioEngine::SetRadioAutoRetuneOnOff(bool on) {
plugin::CallMethod<0x506F80, CAudioEngine*, bool>(this, on);
}

void CAudioEngine::RetuneRadio(char stationId) {
plugin::CallMethod<0x507E10, CAudioEngine*, char>(this, stationId);
void CAudioEngine::RetuneRadio(eRadioID stationId) {
plugin::CallMethod<0x507E10, CAudioEngine*, eRadioID>(this, stationId);
}

CReference* CAudioEngine::ReportFrontendAudioEvent(int id, float volume, float speed) {
Expand All @@ -58,8 +58,8 @@ void CAudioEngine::ServiceLoadingTune(float fade) {
plugin::CallMethod<0x5078A0, CAudioEngine*, float>(this, fade);
}

void CAudioEngine::StartRadio(int radioStation, char arg) {
plugin::CallMethod<0x507DC0, CAudioEngine*, int, char>(this, radioStation, arg);
void CAudioEngine::StartRadio(eRadioID radioStation, char arg) {
plugin::CallMethod<0x507DC0, CAudioEngine*, eRadioID, char>(this, radioStation, arg);
Comment on lines +61 to +62

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void CAudioEngine::StartRadio(eRadioID radioStation, char arg) {
plugin::CallMethod<0x507DC0, CAudioEngine*, eRadioID, char>(this, radioStation, arg);
void CAudioEngine::StartRadio(eRadioID radioStation, char bassSetting) {
plugin::CallMethod<0x507DC0, CAudioEngine*, eRadioID, char>(this, radioStation, bassSetting);

}

void CAudioEngine::StopRadio(tVehicleAudioSettings* settings, bool arg) {
Expand Down
36 changes: 15 additions & 21 deletions plugin_sa/game_sa/CAudioEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,24 @@
*/
#pragma once
#include "PluginBase.h"
#include "AudioTypes.h"
#include "CAEFrontendAudioEntity.h"
#include "CAEPedlessSpeechAudioEntity.h"
#include "CAETwinLoopSoundEntity.h"
#include "CAEScriptAudioEntity.h"
#include "CAECollisionAudioEntity.h"
#include "CAEVehicleAudioEntity.h"
#include "eAudioEvents.h"
#include "eRadioID.h"

class PLUGIN_API CAudioEngine {
public:
char field_0;
char field_1;
char m_nCurrentRadiostationId;
char field_3;
int field_4;
char field_8[152];
char field_A0;
char field_A1[15];
char field_B0;
char field_B1[3];
bool m_bPlayingMissionCompleteTrack;
bool m_bStoppingMissionCompleteTrack;
eRadioID m_nCurrentRadiostationId;
eRadioID m_nSavedRadioStationId;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0x3 is never accessed (the mobile layout has nothing there either). The saved station is 0x2: PreloadCutsceneTrack stores it, StopCutsceneTrack restores it.

Suggested change
eRadioID m_nSavedRadioStationId;
char _pad3;

int m_nBackgroundAudioChannel;
tBeatInfo m_beatInfo;
CAEFrontendAudioEntity m_FrontendAudio;
CAETwinLoopSoundEntity field_150;
CAETwinLoopSoundEntity field_1F8;
Expand All @@ -44,12 +42,12 @@ class PLUGIN_API CAudioEngine {
void SetMusicMasterVolume(char volume);
void SetBassEnhanceOnOff(bool on);
void SetRadioAutoRetuneOnOff(bool on);
void RetuneRadio(char stationId);
void RetuneRadio(eRadioID stationId);
CReference* ReportFrontendAudioEvent(int id, float volume, float speed);
void ReportMissionAudioEvent(eAudioEvents audioEvent, CVector const* coords);
void Service();
void ServiceLoadingTune(float fade);
void StartRadio(int radioStation, char arg);
void StartRadio(eRadioID radioStation, char arg);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void StartRadio(eRadioID radioStation, char arg);
void StartRadio(eRadioID radioStation, char bassSetting);

void StopRadio(tVehicleAudioSettings* settings, bool arg);
bool IsRadioRetuneInProgress();
bool IsLoadingTuneActive();
Expand All @@ -62,16 +60,12 @@ class PLUGIN_API CAudioEngine {
void SetMusicFaderScalingFactor(float value);
void SetEffectsFaderScalingFactor(float value);
};
VALIDATE_OFFSET(CAudioEngine, field_0, 0x0);
VALIDATE_OFFSET(CAudioEngine, field_1, 0x1);
VALIDATE_OFFSET(CAudioEngine, m_bPlayingMissionCompleteTrack, 0x0);
VALIDATE_OFFSET(CAudioEngine, m_bStoppingMissionCompleteTrack, 0x1);
VALIDATE_OFFSET(CAudioEngine, m_nCurrentRadiostationId, 0x2);
VALIDATE_OFFSET(CAudioEngine, field_3, 0x3);
VALIDATE_OFFSET(CAudioEngine, field_4, 0x4);
VALIDATE_OFFSET(CAudioEngine, field_8, 0x8);
VALIDATE_OFFSET(CAudioEngine, field_A0, 0xA0);
VALIDATE_OFFSET(CAudioEngine, field_A1, 0xA1);
VALIDATE_OFFSET(CAudioEngine, field_B0, 0xB0);
VALIDATE_OFFSET(CAudioEngine, field_B1, 0xB1);
VALIDATE_OFFSET(CAudioEngine, m_nSavedRadioStationId, 0x3);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
VALIDATE_OFFSET(CAudioEngine, m_nSavedRadioStationId, 0x3);
VALIDATE_OFFSET(CAudioEngine, _pad3, 0x3);

VALIDATE_OFFSET(CAudioEngine, m_nBackgroundAudioChannel, 0x4);
VALIDATE_OFFSET(CAudioEngine, m_beatInfo, 0x8);
VALIDATE_OFFSET(CAudioEngine, m_FrontendAudio, 0xB4);
VALIDATE_OFFSET(CAudioEngine, field_150, 0x150);
VALIDATE_OFFSET(CAudioEngine, field_1F8, 0x1F8);
Expand Down
Loading