Skip to content

Add functions to change sound effect parameters #642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Aug 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9fc58a1
Add setSoundEffectParameter and getSoundEffectParameters functions
StrixG Oct 4, 2018
7f493ae
Use enum
StrixG Jul 4, 2019
3238c93
Fix typo
StrixG Jul 4, 2019
e122522
Use enums for effects parameters
StrixG Jul 4, 2019
4975bc3
Remove unused bEffectEnabled boolean
StrixG Jul 4, 2019
633ad2a
Merge branch 'master' into sound-effect-parameters
StrixG Sep 7, 2019
6f59216
Merge branch 'master' into sound-effect-parameters
StrixG Nov 2, 2019
fa5481f
Merge branch 'master' into sound-effect-parameters
qaisjp Apr 2, 2020
d5f78ee
Initialize pointers
StrixG Apr 2, 2020
4c6bc7a
Remove Set/GetSoundEffectParameter from CStaticFunctionDefinitions
StrixG Apr 2, 2020
792d5c9
Merge branch 'master' into sound-effect-parameters
StrixG Sep 25, 2020
bde57e3
Merge branch 'master' into sound-effect-parameters
StrixG Oct 26, 2020
2a8a735
Merge branch 'master' into sound-effect-parameters
StrixG Nov 1, 2020
5a90bbb
Remove functions from CStaticFunctionDefinitions
StrixG Nov 1, 2020
ebe5ace
Merge remote-tracking branch 'upstream/master' into sound-effect-para…
StrixG Nov 1, 2020
613ef78
Use lua_createtable
StrixG Nov 1, 2020
b42eaf0
Merge branch 'master' into sound-effect-parameters
StrixG Dec 10, 2020
02ee5a3
Merge branch 'master' of https://github.com/multitheftauto/mtasa-blue…
Pirulax Apr 9, 2021
da13fd0
Fix typos
Pirulax Apr 9, 2021
1ba7c43
Remove unused code
StrixG Apr 15, 2021
a382f58
Accept only sound element/Error on failure
StrixG Apr 15, 2021
b27fdca
Return error when parameter value is wrong
StrixG May 13, 2021
d239d3d
Merge remote-tracking branch 'upstream/master' into sound-effect-para…
patrikjuvonen Aug 4, 2021
09162eb
Update Common.h
patrikjuvonen Aug 4, 2021
32e917d
Update Client/mods/deathmatch/logic/luadefs/CLuaAudioDefs.cpp
patrikjuvonen Aug 4, 2021
8fe2e2d
Merge branch 'master' into sound-effect-parameters
StrixG Aug 5, 2021
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
10 changes: 10 additions & 0 deletions Client/mods/deathmatch/logic/CBassAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,16 @@ void CBassAudio::ApplyFxEffects()
}
}

BOOL CBassAudio::SetFxParameters(uint iFxEffect, void* params)
{
return BASS_FXSetParameters(m_FxEffects[iFxEffect], params);
}

BOOL CBassAudio::GetFxParameters(uint iFxEffect, void* params)
{
return BASS_FXGetParameters(m_FxEffects[iFxEffect], params);
}

//
// Must be call every frame
//
Expand Down
11 changes: 6 additions & 5 deletions Client/mods/deathmatch/logic/CBassAudio.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/*****************************************************************************
*
* PROJECT: Multi Theft Auto v1.0
* (Shared logic for modifications)
* PROJECT: Multi Theft Auto
* LICENSE: See LICENSE in the top level directory
* FILE:
* PURPOSE:
*
* Multi Theft Auto is available from http://www.multitheftauto.com/
*
*****************************************************************************/

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

enum eSoundEventType
{
Expand Down Expand Up @@ -76,6 +75,8 @@ class CBassAudio
bool GetPanEnabled() { return m_bPan; };
void SetPanEnabled(bool bPan) { m_bPan = bPan; };
void SetFxEffects(int* pEnabledEffects, uint iNumElements);
BOOL SetFxParameters(uint iFxEffect, void* params);
BOOL GetFxParameters(uint iFxEffect, void* params);
SString GetMetaTags(const SString& strFormat);
uint GetReachedEndCount();
bool IsFreed();
Expand Down
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/CClientPlayerVoice.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class CClientPlayerVoice

bool SetFxEffect(uint uiFxEffect, bool bEnable);
bool IsFxEffectEnabled(uint uiFxEffect);

bool IsActive() { return m_bVoiceActive; }

private:
Expand Down
30 changes: 27 additions & 3 deletions Client/mods/deathmatch/logic/CClientSound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
CClientSound::CClientSound(CClientManager* pManager, ElementID ID) : ClassInit(this), CClientEntity(ID)
{
m_pSoundManager = pManager->GetSoundManager();
m_pAudio = NULL;
m_pAudio = nullptr;

SetTypeName("sound");

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

m_pBuffer = NULL;
m_pBuffer = nullptr;
m_uiFrameNumberCreated = g_pClientGame->GetFrameCount();
}

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

bool CClientSound::SetFxEffectParameters(uint uiFxEffect, void* params)
{
if (uiFxEffect >= NUMELMS(m_EnabledEffects))
return false;

if (m_pAudio)
if (m_pAudio->SetFxParameters(uiFxEffect, params))
return true;

return false;
}

bool CClientSound::GetFxEffectParameters(uint uiFxEffect, void* params)
{
if (uiFxEffect >= NUMELMS(m_EnabledEffects))
return false;

if (m_pAudio)
if (m_pAudio->GetFxParameters(uiFxEffect, params))
return true;

return false;
}

////////////////////////////////////////////////////////////
//
// CClientSound::Process3D
Expand Down Expand Up @@ -726,7 +750,7 @@ void CClientSound::Process3D(const CVector& vecPlayerPosition, const CVector& ve
}
else if (eventInfo.type == SOUND_EVENT_STREAM_RESULT)
{
// Call onClientSoundStream LUA event
// Call onClientSoundStream Lua event
CLuaArguments Arguments;
Arguments.PushBoolean(eventInfo.bBool);
Arguments.PushNumber(eventInfo.dNumber);
Expand Down
3 changes: 3 additions & 0 deletions Client/mods/deathmatch/logic/CClientSound.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ class CClientSound final : public CClientEntity

bool SetFxEffect(uint uiFxEffect, bool bEnable);
bool IsFxEffectEnabled(uint uiFxEffect);

bool SetFxEffectParameters(uint uiFxEffect, void* params);
bool GetFxEffectParameters(uint uiFxEffect, void* params);

void Unlink(){};

Expand Down
91 changes: 91 additions & 0 deletions Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,97 @@ ADD_ENUM(eClientModelType::OBJECT, "object")
ADD_ENUM(eClientModelType::VEHICLE, "vehicle")
IMPLEMENT_ENUM_CLASS_END("client-model-type")

// Sound effects
IMPLEMENT_ENUM_BEGIN(eSoundEffectType)
ADD_ENUM(BASS_FX_DX8_CHORUS, "chorus")
ADD_ENUM(BASS_FX_DX8_COMPRESSOR, "compressor")
ADD_ENUM(BASS_FX_DX8_DISTORTION, "distortion")
ADD_ENUM(BASS_FX_DX8_ECHO, "echo")
ADD_ENUM(BASS_FX_DX8_FLANGER, "flanger")
ADD_ENUM(BASS_FX_DX8_GARGLE, "gargle")
ADD_ENUM(BASS_FX_DX8_I3DL2REVERB, "i3dl2reverb")
ADD_ENUM(BASS_FX_DX8_PARAMEQ, "parameq")
ADD_ENUM(BASS_FX_DX8_REVERB, "reverb")
IMPLEMENT_ENUM_END("soundeffect-type")

IMPLEMENT_ENUM_CLASS_BEGIN(eSoundEffectParams::Chorus)
ADD_ENUM(eSoundEffectParams::Chorus::WET_DRY_MIX, "wetDryMix")
ADD_ENUM(eSoundEffectParams::Chorus::DEPTH, "depth")
ADD_ENUM(eSoundEffectParams::Chorus::FEEDBACK, "feedback")
ADD_ENUM(eSoundEffectParams::Chorus::FREQUENCY, "frequency")
ADD_ENUM(eSoundEffectParams::Chorus::WAVEFORM, "waveform")
ADD_ENUM(eSoundEffectParams::Chorus::DELAY, "delay")
ADD_ENUM(eSoundEffectParams::Chorus::PHASE, "phase")
IMPLEMENT_ENUM_CLASS_END("soundeffect-params-chorus")

IMPLEMENT_ENUM_CLASS_BEGIN(eSoundEffectParams::Compressor)
ADD_ENUM(eSoundEffectParams::Compressor::GAIN, "gain")
ADD_ENUM(eSoundEffectParams::Compressor::ATTACK, "attack")
ADD_ENUM(eSoundEffectParams::Compressor::RELEASE, "release")
ADD_ENUM(eSoundEffectParams::Compressor::THRESHOLD, "threshold")
ADD_ENUM(eSoundEffectParams::Compressor::RATIO, "ratio")
ADD_ENUM(eSoundEffectParams::Compressor::PREDELAY, "predelay")
IMPLEMENT_ENUM_CLASS_END("soundeffect-params-compressor")

IMPLEMENT_ENUM_CLASS_BEGIN(eSoundEffectParams::Distortion)
ADD_ENUM(eSoundEffectParams::Distortion::GAIN, "gain")
ADD_ENUM(eSoundEffectParams::Distortion::EDGE, "edge")
ADD_ENUM(eSoundEffectParams::Distortion::POST_EQ_CENTER_FREQUENCY, "postEQCenterFrequency")
ADD_ENUM(eSoundEffectParams::Distortion::POST_EQ_BANDWIDTH, "postEQBandwidth")
ADD_ENUM(eSoundEffectParams::Distortion::PRE_LOWPASS_CUTOFF, "preLowpassCutoff")
IMPLEMENT_ENUM_CLASS_END("soundeffect-params-distortion")

IMPLEMENT_ENUM_CLASS_BEGIN(eSoundEffectParams::Echo)
ADD_ENUM(eSoundEffectParams::Echo::WET_DRY_MIX, "wetDryMix")
ADD_ENUM(eSoundEffectParams::Echo::FEEDBACK, "feedback")
ADD_ENUM(eSoundEffectParams::Echo::LEFT_DELAY, "leftDelay")
ADD_ENUM(eSoundEffectParams::Echo::RIGHT_DELAY, "rightDelay")
ADD_ENUM(eSoundEffectParams::Echo::PAN_DELAY, "panDelay")
IMPLEMENT_ENUM_CLASS_END("soundeffect-params-echo")

IMPLEMENT_ENUM_CLASS_BEGIN(eSoundEffectParams::Flanger)
ADD_ENUM(eSoundEffectParams::Flanger::WET_DRY_MIX, "wetDryMix")
ADD_ENUM(eSoundEffectParams::Flanger::DEPTH, "depth")
ADD_ENUM(eSoundEffectParams::Flanger::FEEDBACK, "feedback")
ADD_ENUM(eSoundEffectParams::Flanger::FREQUENCY, "frequency")
ADD_ENUM(eSoundEffectParams::Flanger::WAVEFORM, "waveform")
ADD_ENUM(eSoundEffectParams::Flanger::DELAY, "delay")
ADD_ENUM(eSoundEffectParams::Flanger::PHASE, "phase")
IMPLEMENT_ENUM_CLASS_END("soundeffect-params-flanger")

IMPLEMENT_ENUM_CLASS_BEGIN(eSoundEffectParams::Gargle)
ADD_ENUM(eSoundEffectParams::Gargle::RATE_HZ, "rateHz")
ADD_ENUM(eSoundEffectParams::Gargle::WAVE_SHAPE, "waveShape")
IMPLEMENT_ENUM_CLASS_END("soundeffect-params-gargle")

IMPLEMENT_ENUM_CLASS_BEGIN(eSoundEffectParams::I3DL2Reverb)
ADD_ENUM(eSoundEffectParams::I3DL2Reverb::ROOM, "room")
ADD_ENUM(eSoundEffectParams::I3DL2Reverb::ROOM_HF, "roomHF")
ADD_ENUM(eSoundEffectParams::I3DL2Reverb::ROOM_ROLLOFF_FACTOR, "roomRolloffFactor")
ADD_ENUM(eSoundEffectParams::I3DL2Reverb::DECAY_TIME, "decayTime")
ADD_ENUM(eSoundEffectParams::I3DL2Reverb::DECAY_HF_RATIO, "decayHFRatio")
ADD_ENUM(eSoundEffectParams::I3DL2Reverb::REFLECTIONS, "reflections")
ADD_ENUM(eSoundEffectParams::I3DL2Reverb::REFLECTIONS_DELAY, "reflectionsDelay")
ADD_ENUM(eSoundEffectParams::I3DL2Reverb::REVERB, "reverb")
ADD_ENUM(eSoundEffectParams::I3DL2Reverb::REVERB_DELAY, "reverbDelay")
ADD_ENUM(eSoundEffectParams::I3DL2Reverb::DIFFUSION, "diffusion")
ADD_ENUM(eSoundEffectParams::I3DL2Reverb::DENSITY, "density")
ADD_ENUM(eSoundEffectParams::I3DL2Reverb::HF_REFERENCE, "HFReference")
IMPLEMENT_ENUM_CLASS_END("soundeffect-params-i3dl2reverb")

IMPLEMENT_ENUM_CLASS_BEGIN(eSoundEffectParams::ParamEq)
ADD_ENUM(eSoundEffectParams::ParamEq::CENTER, "center")
ADD_ENUM(eSoundEffectParams::ParamEq::BANDWIDTH, "bandwidth")
ADD_ENUM(eSoundEffectParams::ParamEq::GAIN, "gain")
IMPLEMENT_ENUM_CLASS_END("soundeffect-params-parameq")

IMPLEMENT_ENUM_CLASS_BEGIN(eSoundEffectParams::Reverb)
ADD_ENUM(eSoundEffectParams::Reverb::IN_GAIN, "inGain")
ADD_ENUM(eSoundEffectParams::Reverb::REVERB_MIX, "reverbMix")
ADD_ENUM(eSoundEffectParams::Reverb::REVERB_TIME, "reverbTime")
ADD_ENUM(eSoundEffectParams::Reverb::HIGH_FREQ_RT_RATIO, "highFreqRTRatio")
IMPLEMENT_ENUM_CLASS_END("soundeffect-params-reverb")

//
// Get best guess at name of userdata type
//
Expand Down
50 changes: 50 additions & 0 deletions Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ DECLARE_ENUM(eSurfaceWheelEffect);
DECLARE_ENUM(eSurfaceSkidMarkType);
DECLARE_ENUM(eSurfaceAdhesionGroup);
DECLARE_ENUM_CLASS(eClientModelType);
DECLARE_ENUM(eSoundEffectType);
DECLARE_ENUM_CLASS(eSoundEffectParams::Chorus);
DECLARE_ENUM_CLASS(eSoundEffectParams::Compressor);
DECLARE_ENUM_CLASS(eSoundEffectParams::Distortion);
DECLARE_ENUM_CLASS(eSoundEffectParams::Echo);
DECLARE_ENUM_CLASS(eSoundEffectParams::Flanger);
DECLARE_ENUM_CLASS(eSoundEffectParams::Gargle);
DECLARE_ENUM_CLASS(eSoundEffectParams::I3DL2Reverb);
DECLARE_ENUM_CLASS(eSoundEffectParams::ParamEq);
DECLARE_ENUM_CLASS(eSoundEffectParams::Reverb);

class CRemoteCall;

Expand Down Expand Up @@ -455,6 +465,46 @@ inline SString GetClassByTypeName(eObjectGroup::BreakMode*)
{
return "objectgroup-breakmode";
}
inline SString GetClassTypeName(eSoundEffectType*)
{
return "soundeffect-type";
}
inline SString GetClassTypeName(eSoundEffectParams::Chorus*)
{
return "soundeffect-params-chorus";
}
inline SString GetClassTypeName(eSoundEffectParams::Compressor*)
{
return "soundeffect-params-compressor";
}
inline SString GetClassTypeName(eSoundEffectParams::Distortion*)
{
return "soundeffect-params-distortion";
}
inline SString GetClassTypeName(eSoundEffectParams::Echo*)
{
return "soundeffect-params-echo";
}
inline SString GetClassTypeName(eSoundEffectParams::Flanger*)
{
return "soundeffect-params-flanger";
}
inline SString GetClassTypeName(eSoundEffectParams::Gargle*)
{
return "soundeffect-params-gargle";
}
inline SString GetClassTypeName(eSoundEffectParams::I3DL2Reverb*)
{
return "soundeffect-params-i3dl2reverb";
}
inline SString GetClassTypeName(eSoundEffectParams::ParamEq*)
{
return "soundeffect-params-parameq";
}
inline SString GetClassTypeName(eSoundEffectParams::Reverb*)
{
return "soundeffect-params-reverb";
}

inline SString GetClassByTypeName(eClientModelType)
{
Expand Down
Loading