Skip to content

Commit

Permalink
Add suggestions from code review and style fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Deledrius committed Feb 21, 2025
1 parent 318cdb1 commit 90a9fdf
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 74 deletions.
122 changes: 59 additions & 63 deletions Sources/MaxPlugin/MaxComponent/plAudioComponents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,38 +155,37 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define EAX_MATERIAL_CURTAINLF 0.15f
#define EAX_MATERIAL_CURTAINROOMRATIO 1.00f

#define EAX_NUM_LEGACY_PRESETS 26
const char* EAX_LEGACY_PRESET_NAMES[EAX_NUM_LEGACY_PRESETS] =
{
"Generic",
"Padded Cell",
"Room",
"Bathroom",
"Living Room",
"Stone Room",
"Auditorium",
"Concert Hall",
"Cave",
"Arena",
"Hangar",
"Carpetted Hallway",
"Hallway",
"Stone Corridor",
"Alley",
"Forest",
"City",
"Mountains",
"Quarry",
"Plain",
"Parking Lot",
"Sewer Pipe",
"Underwater",
"Drugged",
"Dizzy",
"Psychotic"
//#define EAX_NUM_LEGACY_PRESETS 26
const TCHAR *EAX_LEGACY_PRESET_NAMES[] = {
_T("Generic"),
_T("Padded Cell"),
_T("Room"),
_T("Bathroom"),
_T("Living Room"),
_T("Stone Room"),
_T("Auditorium"),
_T("Concert Hall"),
_T("Cave"),
_T("Arena"),
_T("Hangar"),
_T("Carpeted Hallway"),
_T("Hallway"),
_T("Stone Corridor"),
_T("Alley"),
_T("Forest"),
_T("City"),
_T("Mountains"),
_T("Quarry"),
_T("Plain"),
_T("Parking Lot"),
_T("Sewer Pipe"),
_T("Underwater"),
_T("Drugged"),
_T("Dizzy"),
_T("Psychotic")
};

EFXEAXREVERBPROPERTIES EAX_LEGACY_PRESETS[EAX_NUM_LEGACY_PRESETS] = {
EFXEAXREVERBPROPERTIES EAX_LEGACY_PRESETS[] = {
EFX_REVERB_PRESET_GENERIC,
EFX_REVERB_PRESET_PADDEDCELL,
EFX_REVERB_PRESET_ROOM,
Expand Down Expand Up @@ -1689,7 +1688,7 @@ void plBaseSoundEmitterComponent::IGrabEAXParams( plSound *sound, plErrorMsg
{
sEAXPropsDlgProc.FlushSwappedPBs();

plEAXSourceSettings &settings = sound->GetEAXSettings();
plEAXSourceSettings &settings = sound->GetEFXSettings();

if( fCompPB->GetInt( (ParamID)kEAXEnabled ) )
{
Expand Down Expand Up @@ -2544,7 +2543,7 @@ bool plBackgroundMusicComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg)
}

IGrabSoftRegion( sound, pErrMsg );
sound->GetEAXSettings().Enable( false );
sound->GetEFXSettings().Enable( false );
}

return true;
Expand Down Expand Up @@ -2832,8 +2831,8 @@ class plEAXListenerDlgProc : public plSingleCompSelProc
HWND comboBox = GetDlgItem( hWnd, IDC_EAX_PRESET_COMBO );
ComboBox_ResetContent( comboBox );

for( int i = 0; i < EAX_NUM_LEGACY_PRESETS; i++ )
ComboBox_AddString(comboBox, EAX_LEGACY_PRESET_NAMES[i]);
for (auto preset_name : EAX_LEGACY_PRESET_NAMES)
ComboBox_AddString(comboBox, preset_name);

ComboBox_SetCurSel( comboBox, pb->GetInt( (ParamID)plEAXListenerComponent::kRefPreset ) );

Expand Down Expand Up @@ -2971,55 +2970,52 @@ bool plEAXListenerComponent::Convert(plMaxNode *node, plErrorMsg *errMsg)
// Set up the parameters of the listener mod
if(fCompPB->GetInt( (ParamID)kRefWhichSettings ) == 0) {
// Set params based on a preset
listener->SetFromEFXPreset(EAX_LEGACY_PRESETS[fCompPB->GetInt((ParamID)kRefPreset)]);
listener->SetFromPreset(EAX_LEGACY_PRESETS[fCompPB->GetInt((ParamID)kRefPreset)]);
} else {
// Set params based on artist selections
EAXREVERBPROPERTIES *eaxProps = new EAXREVERBPROPERTIES;
EAXLISTENERPROPERTIES eaxProps;

// Get the raw params
eaxProps->flEnvironmentSize = fCompPB->GetFloat( (ParamID)kRefEnvironmentSize );
eaxProps->flEnvironmentDiffusion = fCompPB->GetFloat( (ParamID)kRefEnvironmentDiffusion );
eaxProps->lRoom = fCompPB->GetInt( (ParamID)kRefRoom );
eaxProps->lRoomHF = fCompPB->GetInt( (ParamID)kRefRoomHF );
eaxProps->lRoomLF = fCompPB->GetInt( (ParamID)kRefRoomLF );
eaxProps->flDecayTime = fCompPB->GetFloat( (ParamID)kRefDecayTime );
eaxProps->flDecayHFRatio = fCompPB->GetFloat( (ParamID)kRefDecayHFRatio );
eaxProps->flDecayLFRatio = fCompPB->GetFloat( (ParamID)kRefDecayLFRatio );
eaxProps->lReflections = fCompPB->GetInt( (ParamID)kRefReflections );
eaxProps->flReflectionsDelay = fCompPB->GetFloat( (ParamID)kRefReflectionsDelay );
//eaxProps->vReflectionsPan; // early reflections panning vector
eaxProps->lReverb = fCompPB->GetInt( (ParamID)kRefReverb ); // late reverberation level relative to room effect
eaxProps->flReverbDelay = fCompPB->GetFloat( (ParamID)kRefReverbDelay );
//eaxProps->vReverbPan; // late reverberation panning vector
eaxProps->flEchoTime = fCompPB->GetFloat( (ParamID)kRefEchoTime );
eaxProps->flEchoDepth = fCompPB->GetFloat( (ParamID)kRefEchoDepth );
eaxProps->flModulationTime = fCompPB->GetFloat( (ParamID)kRefModulationTime );
eaxProps->flModulationDepth = fCompPB->GetFloat( (ParamID)kRefModulationDepth );
eaxProps->flAirAbsorptionHF = fCompPB->GetFloat( (ParamID)kRefAirAbsorptionHF );
eaxProps->flHFReference = fCompPB->GetFloat( (ParamID)kRefHFReference );
eaxProps->flLFReference = fCompPB->GetFloat( (ParamID)kRefLFReference );
eaxProps->flRoomRolloffFactor = fCompPB->GetFloat( (ParamID)kRefRoomRolloffFactor );
eaxProps->ulFlags = fCompPB->GetInt( (ParamID)kRefFlags );
eaxProps.flEnvironmentSize = fCompPB->GetFloat( (ParamID)kRefEnvironmentSize );
eaxProps.flEnvironmentDiffusion = fCompPB->GetFloat( (ParamID)kRefEnvironmentDiffusion );
eaxProps.lRoom = fCompPB->GetInt( (ParamID)kRefRoom );
eaxProps.lRoomHF = fCompPB->GetInt( (ParamID)kRefRoomHF );
eaxProps.lRoomLF = fCompPB->GetInt( (ParamID)kRefRoomLF );
eaxProps.flDecayTime = fCompPB->GetFloat( (ParamID)kRefDecayTime );
eaxProps.flDecayHFRatio = fCompPB->GetFloat( (ParamID)kRefDecayHFRatio );
eaxProps.flDecayLFRatio = fCompPB->GetFloat( (ParamID)kRefDecayLFRatio );
eaxProps.lReflections = fCompPB->GetInt( (ParamID)kRefReflections );
eaxProps.flReflectionsDelay = fCompPB->GetFloat( (ParamID)kRefReflectionsDelay );
//eaxProps->vReflectionsPan;
eaxProps.lReverb = fCompPB->GetInt( (ParamID)kRefReverb );
eaxProps.flReverbDelay = fCompPB->GetFloat( (ParamID)kRefReverbDelay );
//eaxProps->vReverbPan;
eaxProps.flEchoTime = fCompPB->GetFloat( (ParamID)kRefEchoTime );
eaxProps.flEchoDepth = fCompPB->GetFloat( (ParamID)kRefEchoDepth );
eaxProps.flModulationTime = fCompPB->GetFloat( (ParamID)kRefModulationTime );
eaxProps.flModulationDepth = fCompPB->GetFloat( (ParamID)kRefModulationDepth );
eaxProps.flAirAbsorptionHF = fCompPB->GetFloat( (ParamID)kRefAirAbsorptionHF );
eaxProps.flHFReference = fCompPB->GetFloat( (ParamID)kRefHFReference );
eaxProps.flLFReference = fCompPB->GetFloat( (ParamID)kRefLFReference );
eaxProps.flRoomRolloffFactor = fCompPB->GetFloat( (ParamID)kRefRoomRolloffFactor );
eaxProps.ulFlags = fCompPB->GetInt( (ParamID)kRefFlags );

// Convert to EFX and store them
plEAXListenerMod::ConvertEAXToEFX(eaxProps, listener->GetListenerProps());
delete eaxProps;
*(listener->GetListenerProps()) = *ConvertEAXToEFX(&eaxProps);
}

return true;
}

bool plEAXListenerComponent::PreConvert(plMaxNode *pNode, plErrorMsg *errMsg)
{

return true;
}

// SetupProperties - Internal setup and write-only set properties on the MaxNode. No reading
// of properties on the MaxNode, as it's still indeterminant.
bool plEAXListenerComponent::SetupProperties(plMaxNode *pNode, plErrorMsg *errMsg)
{

return true;
}

Expand Down
14 changes: 7 additions & 7 deletions Sources/Plasma/PubUtilLib/plAudio/plEAXEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ plEAXListener &plEAXListener::GetInstance()

bool plEAXListener::Init()
{
if(fInited)
if (fInited)
return true;

alListenerf(AL_METERS_PER_UNIT, 0.3048f); // Distance units set to feet
Expand Down Expand Up @@ -219,7 +219,7 @@ bool plEAXListener::Init()

void plEAXListener::Shutdown()
{
if(!fInited)
if (!fInited)
return;

IRelease();
Expand Down Expand Up @@ -314,7 +314,7 @@ void plEAXListener::ProcessMods(const std::set<plEAXListenerMod*>& modArray)
if (myLog != nullptr)
myLog->Clear();

if(modArray.size() != fLastModCount)
if (modArray.size() != fLastModCount)
{
DebugLog("Clearing cache...");
ClearProcessCache(); // Code path changed, clear the entire cache
Expand Down Expand Up @@ -358,16 +358,16 @@ void plEAXListener::ProcessMods(const std::set<plEAXListenerMod*>& modArray)
bMorphing = true;
}

if( totalStrength >= 1.f )
if (totalStrength >= 1.f)
break;
}
}

if( firstOne )
if (firstOne)
{
// No regions of strength > 0, so just make it quiet
DebugLog( "Reverb should be quiet." );
if( fLastWasEmpty )
DebugLog("Reverb should be quiet.");
if (fLastWasEmpty)
return;

finalProps = EFX_REVERB_PRESET_GENERIC;
Expand Down
3 changes: 0 additions & 3 deletions Sources/Plasma/PubUtilLib/plAudio/plEAXListenerMod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@ bool plEAXListenerMod::MsgReceive( plMessage* pMsg )
return plSingleModifier::MsgReceive( pMsg );
}

LPEFXEAXREVERBPROPERTIES ConvertEAXToEFX(const LPEAXLISTENERPROPERTIES eax);
LPEAXLISTENERPROPERTIES ConvertEFXToEAX(const LPEFXEAXREVERBPROPERTIES efx);

void plEAXListenerMod::Read( hsStream* s, hsResMgr* mgr )
{
plSingleModifier::Read( s, mgr );
Expand Down
5 changes: 4 additions & 1 deletion Sources/Plasma/PubUtilLib/plAudio/plEAXListenerMod.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com

class plMessage;
class plSoftVolume;
//struct EFXEAXREVERBPROPERTIES;

class plEAXListenerMod : public plSingleModifier
{
Expand Down Expand Up @@ -93,4 +92,8 @@ class plEAXListenerMod : public plSingleModifier
bool IEval(double secs, float del, uint32_t dirty) override; // called only by owner object's Eval()
};

typedef struct _EAXLISTENERPROPERTIES *LPEAXLISTENERPROPERTIES;
LPEFXEAXREVERBPROPERTIES ConvertEAXToEFX(const LPEAXLISTENERPROPERTIES eax);
LPEAXLISTENERPROPERTIES ConvertEFXToEAX(const LPEFXEAXREVERBPROPERTIES efx);

#endif // _plEAXListenerMod_h

0 comments on commit 90a9fdf

Please sign in to comment.