dsound/tests: Add effect parameters tests.

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
stable
Alistair Leslie-Hughes 2019-09-03 23:44:08 +00:00 committed by Alexandre Julliard
parent 363b8809f3
commit 54f1d8e750
1 changed files with 316 additions and 0 deletions

View File

@ -1375,6 +1375,321 @@ static void test_effects(void)
while (IDirectSound8_Release(dso));
}
static void test_echo_parameters(IDirectSoundBuffer8 *secondary8)
{
HRESULT rc;
IDirectSoundFXEcho *echo;
rc = IDirectSoundBuffer8_GetObjectInPath(secondary8, &GUID_DSFX_STANDARD_ECHO, 0, &IID_IDirectSoundFXEcho, (void**)&echo);
ok(rc == DS_OK, "GetObjectInPath failed: %08x\n", rc);
if (rc == DS_OK)
{
DSFXEcho params;
rc = IDirectSoundFXEcho_GetAllParameters(echo, &params);
todo_wine ok(rc == DS_OK, "Failed: %08x\n", rc);
if (rc == DS_OK )
{
ok(params.fWetDryMix == 50.0f, "got %f\n", params.fWetDryMix);
ok(params.fFeedback == 50.0f, "got %f\n", params.fFeedback);
ok(params.fLeftDelay == 500.0f,"got %f\n", params.fLeftDelay);
ok(params.fRightDelay == 500.0f,"got %f\n", params.fRightDelay);
ok(params.lPanDelay == 0, "got %d\n", params.lPanDelay);
}
IDirectSoundFXEcho_Release(echo);
}
}
static void test_gargle_parameters(IDirectSoundBuffer8 *secondary8)
{
HRESULT rc;
IDirectSoundFXGargle *gargle;
rc = IDirectSoundBuffer8_GetObjectInPath(secondary8, &GUID_DSFX_STANDARD_GARGLE, 0, &IID_IDirectSoundFXGargle, (void**)&gargle);
todo_wine ok(rc == DS_OK, "GetObjectInPath failed: %08x\n", rc);
if (rc == DS_OK)
{
DSFXGargle params;
rc = IDirectSoundFXGargle_GetAllParameters(gargle, &params);
todo_wine ok(rc == DS_OK, "Failed: %08x\n", rc);
if (rc == DS_OK)
{
ok(params.dwRateHz == 20, "got %d\n", params.dwRateHz);
ok(params.dwWaveShape == DSFXGARGLE_WAVE_TRIANGLE, "got %d\n", params.dwWaveShape);
}
IDirectSoundFXGargle_Release(gargle);
}
}
static void test_chorus_parameters(IDirectSoundBuffer8 *secondary8)
{
HRESULT rc;
IDirectSoundFXChorus *chorus;
rc = IDirectSoundBuffer8_GetObjectInPath(secondary8, &GUID_DSFX_STANDARD_CHORUS, 0, &IID_IDirectSoundFXChorus,(void**)&chorus);
todo_wine ok(rc == DS_OK, "GetObjectInPath failed: %08x\n", rc);
if (rc == DS_OK)
{
DSFXChorus params;
rc = IDirectSoundFXChorus_GetAllParameters(chorus, &params);
todo_wine ok(rc == DS_OK, "Failed: %08x\n", rc);
if (rc == DS_OK)
{
ok(params.fWetDryMix == 50.0f, "got %f\n", params.fWetDryMix);
ok(params.fDepth == 10.0f, "got %f\n", params.fDepth);
ok(params.fFeedback == 25.0f, "got %f\n", params.fFeedback);
ok(params.fFrequency == 1.1f, "got %f\n", params.fFrequency);
ok(params.lWaveform == DSFXCHORUS_WAVE_SIN, "got %d\n", params.lWaveform);
ok(params.fDelay == 16.0f, "got %f\n", params.fDelay);
ok(params.lPhase == 3, "got %d\n", params.lPhase);
}
IDirectSoundFXChorus_Release(chorus);
}
}
static void test_flanger_parameters(IDirectSoundBuffer8 *secondary8)
{
HRESULT rc;
IDirectSoundFXFlanger *flanger;
rc = IDirectSoundBuffer8_GetObjectInPath(secondary8, &GUID_DSFX_STANDARD_FLANGER, 0, &IID_IDirectSoundFXFlanger,(void**)&flanger);
todo_wine ok(rc == DS_OK, "GetObjectInPath failed: %08x\n", rc);
if (rc == DS_OK)
{
DSFXFlanger params;
rc = IDirectSoundFXFlanger_GetAllParameters(flanger, &params);
todo_wine ok(rc == DS_OK, "Failed: %08x\n", rc);
if (rc == DS_OK)
{
ok(params.fWetDryMix == 50.0f, "got %f\n", params.fWetDryMix);
ok(params.fDepth == 100.0f, "got %f\n", params.fDepth);
ok(params.fFeedback == -50.0f, "got %f\n", params.fFeedback);
ok(params.fFrequency == 0.25f, "got %f\n", params.fFrequency);
ok(params.lWaveform == DSFXFLANGER_WAVE_SIN, "got %d\n", params.lWaveform);
ok(params.fDelay == 2.0f, "got %f\n", params.fDelay);
ok(params.lPhase == 2, "got %d\n", params.lPhase);
}
IDirectSoundFXFlanger_Release(flanger);
}
}
static void test_distortion_parameters(IDirectSoundBuffer8 *secondary8)
{
HRESULT rc;
IDirectSoundFXDistortion *distortion;
rc = IDirectSoundBuffer8_GetObjectInPath(secondary8, &GUID_DSFX_STANDARD_DISTORTION, 0, &IID_IDirectSoundFXDistortion,(void**)&distortion);
todo_wine ok(rc == DS_OK, "GetObjectInPath failed: %08x\n", rc);
if (rc == DS_OK)
{
DSFXDistortion params;
rc = IDirectSoundFXDistortion_GetAllParameters(distortion, &params);
todo_wine ok(rc == DS_OK, "Failed: %08x\n", rc);
if (rc == DS_OK)
{
ok(params.fGain == -18.0f, "got %f\n", params.fGain);
ok(params.fEdge == 15.0f, "got %f\n", params.fEdge);
ok(params.fPostEQCenterFrequency == 2400.0f, "got %f\n", params.fPostEQCenterFrequency);
ok(params.fPostEQBandwidth == 2400.0f, "got %f\n", params.fPostEQBandwidth);
ok(params.fPreLowpassCutoff == 3675.0f, "got %f\n", params.fPreLowpassCutoff);
}
IDirectSoundFXDistortion_Release(distortion);
}
}
static void test_compressor_parameters(IDirectSoundBuffer8 *secondary8)
{
HRESULT rc;
IDirectSoundFXCompressor *compressor;
rc = IDirectSoundBuffer8_GetObjectInPath(secondary8, &GUID_DSFX_STANDARD_COMPRESSOR, 0, &IID_IDirectSoundFXCompressor,(void**)&compressor);
todo_wine ok(rc == DS_OK, "GetObjectInPath failed: %08x\n", rc);
if (rc == DS_OK)
{
DSFXCompressor params;
rc = IDirectSoundFXCompressor_GetAllParameters(compressor, &params);
todo_wine ok(rc == DS_OK, "Failed: %08x\n", rc);
if (rc == DS_OK)
{
ok(params.fGain == 0.0f, "got %f\n", params.fGain);
ok(params.fAttack == 10.0f, "got %f\n", params.fAttack);
ok(params.fThreshold == -20.0f, "got %f\n", params.fThreshold);
ok(params.fRatio == 3.0f, "got %f\n", params.fRatio);
ok(params.fPredelay == 4.0f, "got %f\n", params.fPredelay);
}
IDirectSoundFXCompressor_Release(compressor);
}
}
static void test_parameq_parameters(IDirectSoundBuffer8 *secondary8)
{
HRESULT rc;
IDirectSoundFXParamEq *parameq;
rc = IDirectSoundBuffer8_GetObjectInPath(secondary8, &GUID_DSFX_STANDARD_PARAMEQ, 0, &IID_IDirectSoundFXParamEq,(void**)&parameq);
todo_wine ok(rc == DS_OK, "GetObjectInPath failed: %08x\n", rc);
if (rc == DS_OK)
{
DSFXParamEq params;
rc = IDirectSoundFXParamEq_GetAllParameters(parameq, &params);
todo_wine ok(rc == DS_OK, "Failed: %08x\n", rc);
if (rc == DS_OK)
{
ok(params.fCenter == 3675.0f, "got %f\n", params.fCenter);
ok(params.fBandwidth == 12.0f, "got %f\n", params.fBandwidth);
ok(params.fGain == 0.0f, "got %f\n", params.fGain);
}
IDirectSoundFXParamEq_Release(parameq);
}
}
static void test_reverb_parameters(IDirectSoundBuffer8 *secondary8)
{
HRESULT rc;
IDirectSoundFXI3DL2Reverb *reverb;
rc = IDirectSoundBuffer8_GetObjectInPath(secondary8, &GUID_DSFX_STANDARD_I3DL2REVERB, 0, &IID_IDirectSoundFXI3DL2Reverb, (void**)&reverb);
todo_wine ok(rc == DS_OK, "GetObjectInPath failed: %08x\n", rc);
if (rc == DS_OK)
{
DSFXI3DL2Reverb params;
rc = IDirectSoundFXI3DL2Reverb_GetAllParameters(reverb, &params);
todo_wine ok(rc == DS_OK, "Failed: %08x\n", rc);
if (rc == DS_OK)
{
ok(params.lRoom == -1000, "got %d\n", params.lRoom);
ok(params.flRoomRolloffFactor == 0.0f, "got %f\n", params.flRoomRolloffFactor);
ok(params.flDecayTime == 1.49f, "got %f\n", params.flDecayTime);
ok(params.flDecayHFRatio == 0.83f, "got %f\n", params.flDecayHFRatio);
ok(params.lReflections == -2602, "got %d\n", params.lReflections);
ok(params.lReverb == 200, "got %d\n", params.lReverb);
ok(params.flReverbDelay == 0.011f, "got %f\n", params.flReverbDelay);
ok(params.flDiffusion == 100.0f, "got %f\n", params.flDiffusion);
ok(params.flDensity == 100.0f, "got %f\n", params.flDensity);
ok(params.flHFReference == 5000.0f, "got %f\n", params.flHFReference);
}
IDirectSoundFXI3DL2Reverb_Release(reverb);
}
}
static void test_effects_parameters(void)
{
HRESULT rc;
IDirectSound8 *dso;
IDirectSoundBuffer *primary, *secondary = NULL;
IDirectSoundBuffer8 *secondary8 = NULL;
DSBUFFERDESC bufdesc;
WAVEFORMATEX wfx;
DSEFFECTDESC effects[8];
DWORD resultcodes[8];
/* Create a DirectSound8 object */
rc = pDirectSoundCreate8(NULL, &dso, NULL);
ok(rc == DS_OK || rc == DSERR_NODRIVER, "DirectSoundCreate8() failed: %08x\n", rc);
if (rc != DS_OK)
return;
rc = IDirectSound8_SetCooperativeLevel(dso, get_hwnd(), DSSCL_PRIORITY);
ok(rc == DS_OK, "IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
if (rc != DS_OK)
goto cleanup;
primary = NULL;
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize = sizeof(bufdesc);
bufdesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
rc = IDirectSound8_CreateSoundBuffer(dso, &bufdesc, &primary, NULL);
ok((rc == DS_OK && primary != NULL), "Failed to create a primary buffer: %08x\n", rc);
if (rc != DS_OK)
goto cleanup;
init_format(&wfx, WAVE_FORMAT_PCM, 11025, 8, 1);
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize = sizeof(bufdesc);
bufdesc.dwBufferBytes = align(wfx.nAvgBytesPerSec * BUFFER_LEN / 1000, wfx.nBlockAlign);
bufdesc.lpwfxFormat=&wfx;
ZeroMemory(effects, sizeof(effects));
effects[0].dwSize=sizeof(effects[0]);
effects[0].guidDSFXClass=GUID_DSFX_STANDARD_ECHO;
effects[1].dwSize=sizeof(effects[0]);
effects[1].guidDSFXClass=GUID_DSFX_STANDARD_GARGLE;
effects[2].dwSize=sizeof(effects[0]);
effects[2].guidDSFXClass=GUID_DSFX_STANDARD_CHORUS;
effects[3].dwSize=sizeof(effects[0]);
effects[3].guidDSFXClass=GUID_DSFX_STANDARD_FLANGER;
effects[4].dwSize=sizeof(effects[0]);
effects[4].guidDSFXClass=GUID_DSFX_STANDARD_DISTORTION;
effects[5].dwSize=sizeof(effects[0]);
effects[5].guidDSFXClass=GUID_DSFX_STANDARD_COMPRESSOR;
effects[6].dwSize=sizeof(effects[0]);
effects[6].guidDSFXClass=GUID_DSFX_STANDARD_PARAMEQ;
effects[7].dwSize=sizeof(effects[0]);
effects[7].guidDSFXClass=GUID_DSFX_STANDARD_I3DL2REVERB;
bufdesc.dwFlags = DSBCAPS_CTRLFX;
rc = IDirectSound8_CreateSoundBuffer(dso, &bufdesc, &secondary, NULL);
ok(rc == DS_OK && secondary != NULL, "Failed to create a secondary buffer: %08x\n",rc);
if (rc != DS_OK || !secondary)
goto cleanup;
rc = IDirectSoundBuffer_QueryInterface(secondary, &IID_IDirectSoundBuffer8, (void**)&secondary8);
ok(rc == DS_OK, "Failed: %08x\n", rc);
if (rc != DS_OK)
goto cleanup;
rc = IDirectSoundBuffer8_SetFX(secondary8, ARRAY_SIZE(effects), effects, resultcodes);
ok(rc == DS_OK || rc == REGDB_E_CLASSNOTREG || rc == DSERR_CONTROLUNAVAIL, "Failed: %08x\n", rc);
if (rc != DS_OK)
goto cleanup;
ok (resultcodes[0] == DSFXR_LOCSOFTWARE || resultcodes[0] == DSFXR_LOCHARDWARE, "Result: %08x\n", resultcodes[0]);
test_echo_parameters(secondary8);
ok (resultcodes[1] == DSFXR_LOCSOFTWARE || resultcodes[1] == DSFXR_LOCHARDWARE, "Result: %08x\n", resultcodes[1]);
test_gargle_parameters(secondary8);
ok (resultcodes[2] == DSFXR_LOCSOFTWARE || resultcodes[2] == DSFXR_LOCHARDWARE, "Result: %08x\n", resultcodes[2]);
test_chorus_parameters(secondary8);
ok (resultcodes[3] == DSFXR_LOCSOFTWARE || resultcodes[3] == DSFXR_LOCHARDWARE, "Result: %08x\n", resultcodes[3]);
test_flanger_parameters(secondary8);
ok (resultcodes[4] == DSFXR_LOCSOFTWARE || resultcodes[4] == DSFXR_LOCHARDWARE, "Result: %08x\n", resultcodes[4]);
test_distortion_parameters(secondary8);
ok (resultcodes[5] == DSFXR_LOCSOFTWARE || resultcodes[5] == DSFXR_LOCHARDWARE, "Result: %08x\n", resultcodes[5]);
test_compressor_parameters(secondary8);
ok (resultcodes[6] == DSFXR_LOCSOFTWARE || resultcodes[6] == DSFXR_LOCHARDWARE, "Result: %08x\n", resultcodes[6]);
test_parameq_parameters(secondary8);
ok (resultcodes[7] == DSFXR_LOCSOFTWARE || resultcodes[7] == DSFXR_LOCHARDWARE, "Result: %08x\n", resultcodes[7]);
test_reverb_parameters(secondary8);
cleanup:
if (secondary8)
IDirectSoundBuffer8_Release(secondary8);
if (primary)
IDirectSoundBuffer_Release(primary);
IDirectSound8_Release(dso);
}
START_TEST(dsound8)
{
HMODULE hDsound;
@ -1397,6 +1712,7 @@ START_TEST(dsound8)
test_hw_buffers();
test_first_device();
test_effects();
test_effects_parameters();
}
else
skip("DirectSoundCreate8 missing - skipping all tests\n");