Fundamentals of Audio and Video Programming for Games (Pro-Developer)

In the CSoundEffect class, defined in  RumpusSFX.h , the last data member, and the only one we have not described so far, is the following.

CSoundFXData* SoundFXData;

This is a pointer to a CSoundFXData object, which holds special effects parameters for all nine effects.

The CSoundFXData class (defined in the  extended_dsutil.cpp file) is declared in the  extended_dsutil.h file.

class CSoundFXData { public: CSoundFXData( ); ~CSoundFXData( ); DSFXChorus m_paramsChorus; DSFXCompressor m_paramsCompressor; DSFXDistortion m_paramsDistortion; DSFXEcho m_paramsEcho; DSFXFlanger m_paramsFlanger; DSFXGargle m_paramsGargle; DSFXParamEq m_paramsParamEq; DSFXWavesReverb m_paramsReverb; DSFXI3DL2Reverb m_paramsEnvironment; void CopyAllData(CSoundFXData* copyFromClass); void WriteBytes(FILE *fp, char* address, int nBytes); void WriteAllData(FILE *fp); void ReadBytes(FILE *fp, char* address, int nBytes); void ReadAllData(FILE *fp); };

This class has the following constructor; notice how all the default settings are applied here.

CSoundFXData::CSoundFXData( ) { ZeroMemory( &m_paramsChorus, sizeof( DSFXChorus ) ); ZeroMemory( &m_paramsCompressor, sizeof( DSFXCompressor ) ); ZeroMemory( &m_paramsDistortion, sizeof( DSFXDistortion ) ); ZeroMemory( &m_paramsFlanger, sizeof( DSFXFlanger ) ); ZeroMemory( &m_paramsEcho, sizeof( DSFXEcho ) ); ZeroMemory( &m_paramsGargle, sizeof( DSFXGargle ) ); ZeroMemory( &m_paramsParamEq, sizeof( DSFXParamEq ) ); ZeroMemory( &m_paramsReverb, sizeof( DSFXWavesReverb ) ); ZeroMemory( &m_paramsEnvironment, sizeof( DSFXI3DL2Reverb ) ); m_paramsChorus.fWetDryMix = 50.0f; m_paramsChorus.fDepth = 10.0f; m_paramsChorus.fFeedback = 25.0f; m_paramsChorus.fFrequency = 1.1f; m_paramsChorus.lWaveform = DSFXCHORUS_WAVE_SIN; m_paramsChorus.fDelay = 16.0f; m_paramsChorus.lPhase = DSFXCHORUS_PHASE_NEG_90; m_paramsCompressor.fGain = 0.0f; m_paramsCompressor.fAttack = 10.0f; m_paramsCompressor.fRelease = 200.0f; m_paramsCompressor.fThreshold = -20.0f; m_paramsCompressor.fRatio = 3.0f; m_paramsCompressor.fPredelay = 4.0f; m_paramsDistortion.fGain = -18.0f; m_paramsDistortion.fEdge = 15.0f; m_paramsDistortion.fPostEQCenterFrequency = 2400.0f; m_paramsDistortion.fPostEQBandwidth = 2400.0f; m_paramsDistortion.fPreLowpassCutoff = 7350.0f; m_paramsFlanger.fWetDryMix = 50.0f; m_paramsFlanger.fDepth = 100.0f; m_paramsFlanger.fFeedback = -50.0f; m_paramsFlanger.fFrequency = 0.25f; m_paramsFlanger.lWaveform = DSFXFLANGER_WAVE_SIN; m_paramsFlanger.fDelay = 2.0f; m_paramsFlanger.lPhase = DSFXFLANGER_PHASE_ZERO; m_paramsEcho.fWetDryMix = 50.0f; m_paramsEcho.fFeedback = 50.0f; m_paramsEcho.fLeftDelay = 500.0f; m_paramsEcho.fRightDelay = 500.0f; m_paramsEcho.lPanDelay = DSFXECHO_PANDELAY_MIN; m_paramsGargle.dwRateHz = 20; m_paramsGargle.dwWaveShape = DSFXGARGLE_WAVE_TRIANGLE; m_paramsParamEq.fCenter = 7350.0f; m_paramsParamEq.fBandwidth = 12.0f; m_paramsParamEq.fGain = 0.0f; m_paramsReverb.fInGain = 0.0f; m_paramsReverb.fReverbMix = 0.0f; m_paramsReverb.fReverbTime = 1000.0f; m_paramsReverb.fHighFreqRTRatio = 0.001f;

m_paramsEnvironment.lRoom = DSFX_I3DL2REVERB_ROOM_DEFAULT; m_paramsEnvironment.lRoomHF = DSFX_I3DL2REVERB_ROOMHF_DEFAULT; m_paramsEnvironment.flRoomRolloffFactor = DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_DEFAULT; m_paramsEnvironment.flDecayTime = DSFX_I3DL2REVERB_DECAYTIME_DEFAULT; m_paramsEnvironment.flDecayHFRatio = DSFX_I3DL2REVERB_DECAYHFRATIO_DEFAULT; m_paramsEnvironment.lReflections = DSFX_I3DL2REVERB_REFLECTIONS_DEFAULT; m_paramsEnvironment.flReflectionsDelay = DSFX_I3DL2REVERB_REFLECTIONSDELAY_DEFAULT; m_paramsEnvironment.lReverb = DSFX_I3DL2REVERB_REVERB_DEFAULT; m_paramsEnvironment.flReverbDelay = DSFX_I3DL2REVERB_REVERBDELAY_DEFAULT; m_paramsEnvironment.flDiffusion = DSFX_I3DL2REVERB_DIFFUSION_DEFAULT; m_paramsEnvironment.flDensity = DSFX_I3DL2REVERB_DENSITY_DEFAULT; m_paramsEnvironment.flHFReference = DSFX_I3DL2REVERB_HFREFERENCE_DEFAULT; }

Chapter 5 discusses the audio background behind all of these parameters and settings.

Four of the five methods of this class only concern the reading and writing of this data out to a Rumpus (.rfx) file, and are self-explanatory. The other method, CopyAllData , will copy in all the parameters from a second CSoundFXData object. The cSoundEffect objects (and their associated CSoundFXData objects) are created when the Rumpus tool is started. All the sound effects will contain the default settings shown previously. Both the cSoundEffect and CSound classes inherit the CSoundFXData class. The purpose of a cSoundEffect object holding this information is simply to aid in changing the parameters using the UI. The copy actually used to communicate the parameters to the DirectSound SDK is held in a CSound object.

Категории