Skip to content

Commit 90a9fdf

Browse files
committed
Add suggestions from code review and style fixes.
1 parent 318cdb1 commit 90a9fdf

4 files changed

Lines changed: 70 additions & 74 deletions

File tree

Sources/MaxPlugin/MaxComponent/plAudioComponents.cpp

Lines changed: 59 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -155,38 +155,37 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
155155
#define EAX_MATERIAL_CURTAINLF 0.15f
156156
#define EAX_MATERIAL_CURTAINROOMRATIO 1.00f
157157

158-
#define EAX_NUM_LEGACY_PRESETS 26
159-
const char* EAX_LEGACY_PRESET_NAMES[EAX_NUM_LEGACY_PRESETS] =
160-
{
161-
"Generic",
162-
"Padded Cell",
163-
"Room",
164-
"Bathroom",
165-
"Living Room",
166-
"Stone Room",
167-
"Auditorium",
168-
"Concert Hall",
169-
"Cave",
170-
"Arena",
171-
"Hangar",
172-
"Carpetted Hallway",
173-
"Hallway",
174-
"Stone Corridor",
175-
"Alley",
176-
"Forest",
177-
"City",
178-
"Mountains",
179-
"Quarry",
180-
"Plain",
181-
"Parking Lot",
182-
"Sewer Pipe",
183-
"Underwater",
184-
"Drugged",
185-
"Dizzy",
186-
"Psychotic"
158+
//#define EAX_NUM_LEGACY_PRESETS 26
159+
const TCHAR *EAX_LEGACY_PRESET_NAMES[] = {
160+
_T("Generic"),
161+
_T("Padded Cell"),
162+
_T("Room"),
163+
_T("Bathroom"),
164+
_T("Living Room"),
165+
_T("Stone Room"),
166+
_T("Auditorium"),
167+
_T("Concert Hall"),
168+
_T("Cave"),
169+
_T("Arena"),
170+
_T("Hangar"),
171+
_T("Carpeted Hallway"),
172+
_T("Hallway"),
173+
_T("Stone Corridor"),
174+
_T("Alley"),
175+
_T("Forest"),
176+
_T("City"),
177+
_T("Mountains"),
178+
_T("Quarry"),
179+
_T("Plain"),
180+
_T("Parking Lot"),
181+
_T("Sewer Pipe"),
182+
_T("Underwater"),
183+
_T("Drugged"),
184+
_T("Dizzy"),
185+
_T("Psychotic")
187186
};
188187

189-
EFXEAXREVERBPROPERTIES EAX_LEGACY_PRESETS[EAX_NUM_LEGACY_PRESETS] = {
188+
EFXEAXREVERBPROPERTIES EAX_LEGACY_PRESETS[] = {
190189
EFX_REVERB_PRESET_GENERIC,
191190
EFX_REVERB_PRESET_PADDEDCELL,
192191
EFX_REVERB_PRESET_ROOM,
@@ -1689,7 +1688,7 @@ void plBaseSoundEmitterComponent::IGrabEAXParams( plSound *sound, plErrorMsg
16891688
{
16901689
sEAXPropsDlgProc.FlushSwappedPBs();
16911690

1692-
plEAXSourceSettings &settings = sound->GetEAXSettings();
1691+
plEAXSourceSettings &settings = sound->GetEFXSettings();
16931692

16941693
if( fCompPB->GetInt( (ParamID)kEAXEnabled ) )
16951694
{
@@ -2544,7 +2543,7 @@ bool plBackgroundMusicComponent::Convert(plMaxNode *node, plErrorMsg *pErrMsg)
25442543
}
25452544

25462545
IGrabSoftRegion( sound, pErrMsg );
2547-
sound->GetEAXSettings().Enable( false );
2546+
sound->GetEFXSettings().Enable( false );
25482547
}
25492548

25502549
return true;
@@ -2832,8 +2831,8 @@ class plEAXListenerDlgProc : public plSingleCompSelProc
28322831
HWND comboBox = GetDlgItem( hWnd, IDC_EAX_PRESET_COMBO );
28332832
ComboBox_ResetContent( comboBox );
28342833

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

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

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

29792978
// Get the raw params
2980-
eaxProps->flEnvironmentSize = fCompPB->GetFloat( (ParamID)kRefEnvironmentSize );
2981-
eaxProps->flEnvironmentDiffusion = fCompPB->GetFloat( (ParamID)kRefEnvironmentDiffusion );
2982-
eaxProps->lRoom = fCompPB->GetInt( (ParamID)kRefRoom );
2983-
eaxProps->lRoomHF = fCompPB->GetInt( (ParamID)kRefRoomHF );
2984-
eaxProps->lRoomLF = fCompPB->GetInt( (ParamID)kRefRoomLF );
2985-
eaxProps->flDecayTime = fCompPB->GetFloat( (ParamID)kRefDecayTime );
2986-
eaxProps->flDecayHFRatio = fCompPB->GetFloat( (ParamID)kRefDecayHFRatio );
2987-
eaxProps->flDecayLFRatio = fCompPB->GetFloat( (ParamID)kRefDecayLFRatio );
2988-
eaxProps->lReflections = fCompPB->GetInt( (ParamID)kRefReflections );
2989-
eaxProps->flReflectionsDelay = fCompPB->GetFloat( (ParamID)kRefReflectionsDelay );
2990-
//eaxProps->vReflectionsPan; // early reflections panning vector
2991-
eaxProps->lReverb = fCompPB->GetInt( (ParamID)kRefReverb ); // late reverberation level relative to room effect
2992-
eaxProps->flReverbDelay = fCompPB->GetFloat( (ParamID)kRefReverbDelay );
2993-
//eaxProps->vReverbPan; // late reverberation panning vector
2994-
eaxProps->flEchoTime = fCompPB->GetFloat( (ParamID)kRefEchoTime );
2995-
eaxProps->flEchoDepth = fCompPB->GetFloat( (ParamID)kRefEchoDepth );
2996-
eaxProps->flModulationTime = fCompPB->GetFloat( (ParamID)kRefModulationTime );
2997-
eaxProps->flModulationDepth = fCompPB->GetFloat( (ParamID)kRefModulationDepth );
2998-
eaxProps->flAirAbsorptionHF = fCompPB->GetFloat( (ParamID)kRefAirAbsorptionHF );
2999-
eaxProps->flHFReference = fCompPB->GetFloat( (ParamID)kRefHFReference );
3000-
eaxProps->flLFReference = fCompPB->GetFloat( (ParamID)kRefLFReference );
3001-
eaxProps->flRoomRolloffFactor = fCompPB->GetFloat( (ParamID)kRefRoomRolloffFactor );
3002-
eaxProps->ulFlags = fCompPB->GetInt( (ParamID)kRefFlags );
2979+
eaxProps.flEnvironmentSize = fCompPB->GetFloat( (ParamID)kRefEnvironmentSize );
2980+
eaxProps.flEnvironmentDiffusion = fCompPB->GetFloat( (ParamID)kRefEnvironmentDiffusion );
2981+
eaxProps.lRoom = fCompPB->GetInt( (ParamID)kRefRoom );
2982+
eaxProps.lRoomHF = fCompPB->GetInt( (ParamID)kRefRoomHF );
2983+
eaxProps.lRoomLF = fCompPB->GetInt( (ParamID)kRefRoomLF );
2984+
eaxProps.flDecayTime = fCompPB->GetFloat( (ParamID)kRefDecayTime );
2985+
eaxProps.flDecayHFRatio = fCompPB->GetFloat( (ParamID)kRefDecayHFRatio );
2986+
eaxProps.flDecayLFRatio = fCompPB->GetFloat( (ParamID)kRefDecayLFRatio );
2987+
eaxProps.lReflections = fCompPB->GetInt( (ParamID)kRefReflections );
2988+
eaxProps.flReflectionsDelay = fCompPB->GetFloat( (ParamID)kRefReflectionsDelay );
2989+
//eaxProps->vReflectionsPan;
2990+
eaxProps.lReverb = fCompPB->GetInt( (ParamID)kRefReverb );
2991+
eaxProps.flReverbDelay = fCompPB->GetFloat( (ParamID)kRefReverbDelay );
2992+
//eaxProps->vReverbPan;
2993+
eaxProps.flEchoTime = fCompPB->GetFloat( (ParamID)kRefEchoTime );
2994+
eaxProps.flEchoDepth = fCompPB->GetFloat( (ParamID)kRefEchoDepth );
2995+
eaxProps.flModulationTime = fCompPB->GetFloat( (ParamID)kRefModulationTime );
2996+
eaxProps.flModulationDepth = fCompPB->GetFloat( (ParamID)kRefModulationDepth );
2997+
eaxProps.flAirAbsorptionHF = fCompPB->GetFloat( (ParamID)kRefAirAbsorptionHF );
2998+
eaxProps.flHFReference = fCompPB->GetFloat( (ParamID)kRefHFReference );
2999+
eaxProps.flLFReference = fCompPB->GetFloat( (ParamID)kRefLFReference );
3000+
eaxProps.flRoomRolloffFactor = fCompPB->GetFloat( (ParamID)kRefRoomRolloffFactor );
3001+
eaxProps.ulFlags = fCompPB->GetInt( (ParamID)kRefFlags );
30033002

30043003
// Convert to EFX and store them
3005-
plEAXListenerMod::ConvertEAXToEFX(eaxProps, listener->GetListenerProps());
3006-
delete eaxProps;
3004+
*(listener->GetListenerProps()) = *ConvertEAXToEFX(&eaxProps);
30073005
}
30083006

30093007
return true;
30103008
}
30113009

30123010
bool plEAXListenerComponent::PreConvert(plMaxNode *pNode, plErrorMsg *errMsg)
30133011
{
3014-
30153012
return true;
30163013
}
30173014

30183015
// SetupProperties - Internal setup and write-only set properties on the MaxNode. No reading
30193016
// of properties on the MaxNode, as it's still indeterminant.
30203017
bool plEAXListenerComponent::SetupProperties(plMaxNode *pNode, plErrorMsg *errMsg)
30213018
{
3022-
30233019
return true;
30243020
}
30253021

Sources/Plasma/PubUtilLib/plAudio/plEAXEffects.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ plEAXListener &plEAXListener::GetInstance()
185185

186186
bool plEAXListener::Init()
187187
{
188-
if(fInited)
188+
if (fInited)
189189
return true;
190190

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

220220
void plEAXListener::Shutdown()
221221
{
222-
if(!fInited)
222+
if (!fInited)
223223
return;
224224

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

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

361-
if( totalStrength >= 1.f )
361+
if (totalStrength >= 1.f)
362362
break;
363363
}
364364
}
365365

366-
if( firstOne )
366+
if (firstOne)
367367
{
368368
// No regions of strength > 0, so just make it quiet
369-
DebugLog( "Reverb should be quiet." );
370-
if( fLastWasEmpty )
369+
DebugLog("Reverb should be quiet.");
370+
if (fLastWasEmpty)
371371
return;
372372

373373
finalProps = EFX_REVERB_PRESET_GENERIC;

Sources/Plasma/PubUtilLib/plAudio/plEAXListenerMod.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,6 @@ bool plEAXListenerMod::MsgReceive( plMessage* pMsg )
156156
return plSingleModifier::MsgReceive( pMsg );
157157
}
158158

159-
LPEFXEAXREVERBPROPERTIES ConvertEAXToEFX(const LPEAXLISTENERPROPERTIES eax);
160-
LPEAXLISTENERPROPERTIES ConvertEFXToEAX(const LPEFXEAXREVERBPROPERTIES efx);
161-
162159
void plEAXListenerMod::Read( hsStream* s, hsResMgr* mgr )
163160
{
164161
plSingleModifier::Read( s, mgr );

Sources/Plasma/PubUtilLib/plAudio/plEAXListenerMod.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
5858

5959
class plMessage;
6060
class plSoftVolume;
61-
//struct EFXEAXREVERBPROPERTIES;
6261

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

95+
typedef struct _EAXLISTENERPROPERTIES *LPEAXLISTENERPROPERTIES;
96+
LPEFXEAXREVERBPROPERTIES ConvertEAXToEFX(const LPEAXLISTENERPROPERTIES eax);
97+
LPEAXLISTENERPROPERTIES ConvertEFXToEAX(const LPEFXEAXREVERBPROPERTIES efx);
98+
9699
#endif // _plEAXListenerMod_h

0 commit comments

Comments
 (0)