Skip to content

Commit 449c5c3

Browse files
StrixGqaisjpPirulaxpatrikjuvonentheSarrum
authored
Add functions to change sound effect parameters (#642)
* Add setSoundEffectParameter and getSoundEffectParameters functions Co-authored-by: Sarrum <thesarrum@gmail.com> Co-authored-by: Qais Patankar <qaisjp@gmail.com> Co-authored-by: Pirulax <patrikjankovics7@gmail.com> Co-authored-by: patrikjuvonen <22572159+patrikjuvonen@users.noreply.github.com> Co-authored-by: Sarrum <thesarrum@gmail.com>
1 parent 6ba6ad7 commit 449c5c3

File tree

10 files changed

+1028
-9
lines changed

10 files changed

+1028
-9
lines changed

Client/mods/deathmatch/logic/CBassAudio.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,16 @@ void CBassAudio::ApplyFxEffects()
843843
}
844844
}
845845

846+
BOOL CBassAudio::SetFxParameters(uint iFxEffect, void* params)
847+
{
848+
return BASS_FXSetParameters(m_FxEffects[iFxEffect], params);
849+
}
850+
851+
BOOL CBassAudio::GetFxParameters(uint iFxEffect, void* params)
852+
{
853+
return BASS_FXGetParameters(m_FxEffects[iFxEffect], params);
854+
}
855+
846856
//
847857
// Must be call every frame
848858
//

Client/mods/deathmatch/logic/CBassAudio.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
/*****************************************************************************
22
*
3-
* PROJECT: Multi Theft Auto v1.0
4-
* (Shared logic for modifications)
3+
* PROJECT: Multi Theft Auto
54
* LICENSE: See LICENSE in the top level directory
6-
* FILE:
7-
* PURPOSE:
5+
*
6+
* Multi Theft Auto is available from http://www.multitheftauto.com/
87
*
98
*****************************************************************************/
109

11-
#define CUT_OFF 5.0f //Cut off point at which volume is regarded as 0 in the function e^-x
10+
#define CUT_OFF 5.0f // Cut off point at which volume is regarded as 0 in the function e^-x
1211

1312
enum eSoundEventType
1413
{
@@ -76,6 +75,8 @@ class CBassAudio
7675
bool GetPanEnabled() { return m_bPan; };
7776
void SetPanEnabled(bool bPan) { m_bPan = bPan; };
7877
void SetFxEffects(int* pEnabledEffects, uint iNumElements);
78+
BOOL SetFxParameters(uint iFxEffect, void* params);
79+
BOOL GetFxParameters(uint iFxEffect, void* params);
7980
SString GetMetaTags(const SString& strFormat);
8081
uint GetReachedEndCount();
8182
bool IsFreed();

Client/mods/deathmatch/logic/CClientPlayerVoice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class CClientPlayerVoice
7272

7373
bool SetFxEffect(uint uiFxEffect, bool bEnable);
7474
bool IsFxEffectEnabled(uint uiFxEffect);
75+
7576
bool IsActive() { return m_bVoiceActive; }
7677

7778
private:

Client/mods/deathmatch/logic/CClientSound.cpp

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
CClientSound::CClientSound(CClientManager* pManager, ElementID ID) : ClassInit(this), CClientEntity(ID)
1414
{
1515
m_pSoundManager = pManager->GetSoundManager();
16-
m_pAudio = NULL;
16+
m_pAudio = nullptr;
1717

1818
SetTypeName("sound");
1919

@@ -26,7 +26,7 @@ CClientSound::CClientSound(CClientManager* pManager, ElementID ID) : ClassInit(t
2626
m_bPan = true;
2727
m_fPan = 0.0f;
2828

29-
m_pBuffer = NULL;
29+
m_pBuffer = nullptr;
3030
m_uiFrameNumberCreated = g_pClientGame->GetFrameCount();
3131
}
3232

@@ -643,6 +643,30 @@ bool CClientSound::IsFxEffectEnabled(uint uiFxEffect)
643643
return m_EnabledEffects[uiFxEffect] ? true : false;
644644
}
645645

646+
bool CClientSound::SetFxEffectParameters(uint uiFxEffect, void* params)
647+
{
648+
if (uiFxEffect >= NUMELMS(m_EnabledEffects))
649+
return false;
650+
651+
if (m_pAudio)
652+
if (m_pAudio->SetFxParameters(uiFxEffect, params))
653+
return true;
654+
655+
return false;
656+
}
657+
658+
bool CClientSound::GetFxEffectParameters(uint uiFxEffect, void* params)
659+
{
660+
if (uiFxEffect >= NUMELMS(m_EnabledEffects))
661+
return false;
662+
663+
if (m_pAudio)
664+
if (m_pAudio->GetFxParameters(uiFxEffect, params))
665+
return true;
666+
667+
return false;
668+
}
669+
646670
////////////////////////////////////////////////////////////
647671
//
648672
// CClientSound::Process3D
@@ -726,7 +750,7 @@ void CClientSound::Process3D(const CVector& vecPlayerPosition, const CVector& ve
726750
}
727751
else if (eventInfo.type == SOUND_EVENT_STREAM_RESULT)
728752
{
729-
// Call onClientSoundStream LUA event
753+
// Call onClientSoundStream Lua event
730754
CLuaArguments Arguments;
731755
Arguments.PushBoolean(eventInfo.bBool);
732756
Arguments.PushNumber(eventInfo.dNumber);

Client/mods/deathmatch/logic/CClientSound.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ class CClientSound final : public CClientEntity
8282

8383
bool SetFxEffect(uint uiFxEffect, bool bEnable);
8484
bool IsFxEffectEnabled(uint uiFxEffect);
85+
86+
bool SetFxEffectParameters(uint uiFxEffect, void* params);
87+
bool GetFxEffectParameters(uint uiFxEffect, void* params);
8588

8689
void Unlink(){};
8790

Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,97 @@ ADD_ENUM(eClientModelType::OBJECT, "object")
667667
ADD_ENUM(eClientModelType::VEHICLE, "vehicle")
668668
IMPLEMENT_ENUM_CLASS_END("client-model-type")
669669

670+
// Sound effects
671+
IMPLEMENT_ENUM_BEGIN(eSoundEffectType)
672+
ADD_ENUM(BASS_FX_DX8_CHORUS, "chorus")
673+
ADD_ENUM(BASS_FX_DX8_COMPRESSOR, "compressor")
674+
ADD_ENUM(BASS_FX_DX8_DISTORTION, "distortion")
675+
ADD_ENUM(BASS_FX_DX8_ECHO, "echo")
676+
ADD_ENUM(BASS_FX_DX8_FLANGER, "flanger")
677+
ADD_ENUM(BASS_FX_DX8_GARGLE, "gargle")
678+
ADD_ENUM(BASS_FX_DX8_I3DL2REVERB, "i3dl2reverb")
679+
ADD_ENUM(BASS_FX_DX8_PARAMEQ, "parameq")
680+
ADD_ENUM(BASS_FX_DX8_REVERB, "reverb")
681+
IMPLEMENT_ENUM_END("soundeffect-type")
682+
683+
IMPLEMENT_ENUM_CLASS_BEGIN(eSoundEffectParams::Chorus)
684+
ADD_ENUM(eSoundEffectParams::Chorus::WET_DRY_MIX, "wetDryMix")
685+
ADD_ENUM(eSoundEffectParams::Chorus::DEPTH, "depth")
686+
ADD_ENUM(eSoundEffectParams::Chorus::FEEDBACK, "feedback")
687+
ADD_ENUM(eSoundEffectParams::Chorus::FREQUENCY, "frequency")
688+
ADD_ENUM(eSoundEffectParams::Chorus::WAVEFORM, "waveform")
689+
ADD_ENUM(eSoundEffectParams::Chorus::DELAY, "delay")
690+
ADD_ENUM(eSoundEffectParams::Chorus::PHASE, "phase")
691+
IMPLEMENT_ENUM_CLASS_END("soundeffect-params-chorus")
692+
693+
IMPLEMENT_ENUM_CLASS_BEGIN(eSoundEffectParams::Compressor)
694+
ADD_ENUM(eSoundEffectParams::Compressor::GAIN, "gain")
695+
ADD_ENUM(eSoundEffectParams::Compressor::ATTACK, "attack")
696+
ADD_ENUM(eSoundEffectParams::Compressor::RELEASE, "release")
697+
ADD_ENUM(eSoundEffectParams::Compressor::THRESHOLD, "threshold")
698+
ADD_ENUM(eSoundEffectParams::Compressor::RATIO, "ratio")
699+
ADD_ENUM(eSoundEffectParams::Compressor::PREDELAY, "predelay")
700+
IMPLEMENT_ENUM_CLASS_END("soundeffect-params-compressor")
701+
702+
IMPLEMENT_ENUM_CLASS_BEGIN(eSoundEffectParams::Distortion)
703+
ADD_ENUM(eSoundEffectParams::Distortion::GAIN, "gain")
704+
ADD_ENUM(eSoundEffectParams::Distortion::EDGE, "edge")
705+
ADD_ENUM(eSoundEffectParams::Distortion::POST_EQ_CENTER_FREQUENCY, "postEQCenterFrequency")
706+
ADD_ENUM(eSoundEffectParams::Distortion::POST_EQ_BANDWIDTH, "postEQBandwidth")
707+
ADD_ENUM(eSoundEffectParams::Distortion::PRE_LOWPASS_CUTOFF, "preLowpassCutoff")
708+
IMPLEMENT_ENUM_CLASS_END("soundeffect-params-distortion")
709+
710+
IMPLEMENT_ENUM_CLASS_BEGIN(eSoundEffectParams::Echo)
711+
ADD_ENUM(eSoundEffectParams::Echo::WET_DRY_MIX, "wetDryMix")
712+
ADD_ENUM(eSoundEffectParams::Echo::FEEDBACK, "feedback")
713+
ADD_ENUM(eSoundEffectParams::Echo::LEFT_DELAY, "leftDelay")
714+
ADD_ENUM(eSoundEffectParams::Echo::RIGHT_DELAY, "rightDelay")
715+
ADD_ENUM(eSoundEffectParams::Echo::PAN_DELAY, "panDelay")
716+
IMPLEMENT_ENUM_CLASS_END("soundeffect-params-echo")
717+
718+
IMPLEMENT_ENUM_CLASS_BEGIN(eSoundEffectParams::Flanger)
719+
ADD_ENUM(eSoundEffectParams::Flanger::WET_DRY_MIX, "wetDryMix")
720+
ADD_ENUM(eSoundEffectParams::Flanger::DEPTH, "depth")
721+
ADD_ENUM(eSoundEffectParams::Flanger::FEEDBACK, "feedback")
722+
ADD_ENUM(eSoundEffectParams::Flanger::FREQUENCY, "frequency")
723+
ADD_ENUM(eSoundEffectParams::Flanger::WAVEFORM, "waveform")
724+
ADD_ENUM(eSoundEffectParams::Flanger::DELAY, "delay")
725+
ADD_ENUM(eSoundEffectParams::Flanger::PHASE, "phase")
726+
IMPLEMENT_ENUM_CLASS_END("soundeffect-params-flanger")
727+
728+
IMPLEMENT_ENUM_CLASS_BEGIN(eSoundEffectParams::Gargle)
729+
ADD_ENUM(eSoundEffectParams::Gargle::RATE_HZ, "rateHz")
730+
ADD_ENUM(eSoundEffectParams::Gargle::WAVE_SHAPE, "waveShape")
731+
IMPLEMENT_ENUM_CLASS_END("soundeffect-params-gargle")
732+
733+
IMPLEMENT_ENUM_CLASS_BEGIN(eSoundEffectParams::I3DL2Reverb)
734+
ADD_ENUM(eSoundEffectParams::I3DL2Reverb::ROOM, "room")
735+
ADD_ENUM(eSoundEffectParams::I3DL2Reverb::ROOM_HF, "roomHF")
736+
ADD_ENUM(eSoundEffectParams::I3DL2Reverb::ROOM_ROLLOFF_FACTOR, "roomRolloffFactor")
737+
ADD_ENUM(eSoundEffectParams::I3DL2Reverb::DECAY_TIME, "decayTime")
738+
ADD_ENUM(eSoundEffectParams::I3DL2Reverb::DECAY_HF_RATIO, "decayHFRatio")
739+
ADD_ENUM(eSoundEffectParams::I3DL2Reverb::REFLECTIONS, "reflections")
740+
ADD_ENUM(eSoundEffectParams::I3DL2Reverb::REFLECTIONS_DELAY, "reflectionsDelay")
741+
ADD_ENUM(eSoundEffectParams::I3DL2Reverb::REVERB, "reverb")
742+
ADD_ENUM(eSoundEffectParams::I3DL2Reverb::REVERB_DELAY, "reverbDelay")
743+
ADD_ENUM(eSoundEffectParams::I3DL2Reverb::DIFFUSION, "diffusion")
744+
ADD_ENUM(eSoundEffectParams::I3DL2Reverb::DENSITY, "density")
745+
ADD_ENUM(eSoundEffectParams::I3DL2Reverb::HF_REFERENCE, "HFReference")
746+
IMPLEMENT_ENUM_CLASS_END("soundeffect-params-i3dl2reverb")
747+
748+
IMPLEMENT_ENUM_CLASS_BEGIN(eSoundEffectParams::ParamEq)
749+
ADD_ENUM(eSoundEffectParams::ParamEq::CENTER, "center")
750+
ADD_ENUM(eSoundEffectParams::ParamEq::BANDWIDTH, "bandwidth")
751+
ADD_ENUM(eSoundEffectParams::ParamEq::GAIN, "gain")
752+
IMPLEMENT_ENUM_CLASS_END("soundeffect-params-parameq")
753+
754+
IMPLEMENT_ENUM_CLASS_BEGIN(eSoundEffectParams::Reverb)
755+
ADD_ENUM(eSoundEffectParams::Reverb::IN_GAIN, "inGain")
756+
ADD_ENUM(eSoundEffectParams::Reverb::REVERB_MIX, "reverbMix")
757+
ADD_ENUM(eSoundEffectParams::Reverb::REVERB_TIME, "reverbTime")
758+
ADD_ENUM(eSoundEffectParams::Reverb::HIGH_FREQ_RT_RATIO, "highFreqRTRatio")
759+
IMPLEMENT_ENUM_CLASS_END("soundeffect-params-reverb")
760+
670761
//
671762
// Get best guess at name of userdata type
672763
//

Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ DECLARE_ENUM(eSurfaceWheelEffect);
6666
DECLARE_ENUM(eSurfaceSkidMarkType);
6767
DECLARE_ENUM(eSurfaceAdhesionGroup);
6868
DECLARE_ENUM_CLASS(eClientModelType);
69+
DECLARE_ENUM(eSoundEffectType);
70+
DECLARE_ENUM_CLASS(eSoundEffectParams::Chorus);
71+
DECLARE_ENUM_CLASS(eSoundEffectParams::Compressor);
72+
DECLARE_ENUM_CLASS(eSoundEffectParams::Distortion);
73+
DECLARE_ENUM_CLASS(eSoundEffectParams::Echo);
74+
DECLARE_ENUM_CLASS(eSoundEffectParams::Flanger);
75+
DECLARE_ENUM_CLASS(eSoundEffectParams::Gargle);
76+
DECLARE_ENUM_CLASS(eSoundEffectParams::I3DL2Reverb);
77+
DECLARE_ENUM_CLASS(eSoundEffectParams::ParamEq);
78+
DECLARE_ENUM_CLASS(eSoundEffectParams::Reverb);
6979

7080
class CRemoteCall;
7181

@@ -455,6 +465,46 @@ inline SString GetClassByTypeName(eObjectGroup::BreakMode*)
455465
{
456466
return "objectgroup-breakmode";
457467
}
468+
inline SString GetClassTypeName(eSoundEffectType*)
469+
{
470+
return "soundeffect-type";
471+
}
472+
inline SString GetClassTypeName(eSoundEffectParams::Chorus*)
473+
{
474+
return "soundeffect-params-chorus";
475+
}
476+
inline SString GetClassTypeName(eSoundEffectParams::Compressor*)
477+
{
478+
return "soundeffect-params-compressor";
479+
}
480+
inline SString GetClassTypeName(eSoundEffectParams::Distortion*)
481+
{
482+
return "soundeffect-params-distortion";
483+
}
484+
inline SString GetClassTypeName(eSoundEffectParams::Echo*)
485+
{
486+
return "soundeffect-params-echo";
487+
}
488+
inline SString GetClassTypeName(eSoundEffectParams::Flanger*)
489+
{
490+
return "soundeffect-params-flanger";
491+
}
492+
inline SString GetClassTypeName(eSoundEffectParams::Gargle*)
493+
{
494+
return "soundeffect-params-gargle";
495+
}
496+
inline SString GetClassTypeName(eSoundEffectParams::I3DL2Reverb*)
497+
{
498+
return "soundeffect-params-i3dl2reverb";
499+
}
500+
inline SString GetClassTypeName(eSoundEffectParams::ParamEq*)
501+
{
502+
return "soundeffect-params-parameq";
503+
}
504+
inline SString GetClassTypeName(eSoundEffectParams::Reverb*)
505+
{
506+
return "soundeffect-params-reverb";
507+
}
458508

459509
inline SString GetClassByTypeName(eClientModelType)
460510
{

0 commit comments

Comments
 (0)