Your chain saw is merrily rattling away, and now you want to modify the effect to simulate the slowing down of the engine as the saw bites into wood. Fortunately, DirectInput lets you modify the parameters of an effect while it is playing.
To change the effect, you need to set up a DIEFFECT structure or have access to the one you used to create the effect. If you are setting up a new structure with local scope, you need to initialize only the dwSize member and any members that contain or point to data that is to be changed.
In this case you want to change a type-specific parameter ¾ the period of the effect ¾ so you need to have access to the DIPERIODIC structure you used when creating the effect, or else create a local copy with all members initialized. Make sure that the address of the DIPERIODIC structure is in the lpvTypeSpecificParams member of the DIEFFECT structure.
Now set the new period of the effect:
diPeriodic.dwPeriod = (DWORD) (0.08 * DI_SECONDS);
Then call the method that actually makes the changes:
HRESULT hr = g_lpdiEffect->SetParameters(&diEffect,
DIEP_TYPESPECIFICPARAMS)
Note the flag that restricts the changes to a single member of the DIEFFECT structure.
You can control the way changes are handled by using other flags. For example, by using the DIEP_NODOWNLOAD flag you could change the parameters immediately after starting the effect but delay the implementation until the user actually started cutting wood. Then you would call the IDirectInputEffect::Download method. For more information on how to use the various control flags, see IDirectInputEffect::SetParameters.