Add fade in/out to the sound tests
Francois Gouget
fgouget at codeweavers.com
Wed May 19 05:43:13 CDT 2004
Running the winmm test on a laptop in Windows XP I got loud pops between
each test tone. It's not really a big problem. It just distracts testers
from the real problems. I don't think this is an issue with the sound
driver. It's more likely bad electronics which is unable to properly
control the even worse speakers.
So I added a simple 1/100 second linear fade in and fade out to each
test tone and this eliminated the pops for all tests with a sampling
rate >22050Hz, and significatly reduced them for the 11025Hz tests.
So I propose to just make this fade in/fade out standard in our test
tones but I'm open to suggestions.
Changelog:
* dlls/dsound/tests/dsound.c
dlls/winmm/tests/wave.c
Francois Gouget <fgouget at codeweavers.com>
Add a 1/100 second fade in/out to reduce the pops between the test
tones.
--
Francois Gouget
fgouget at codeweavers.com
-------------- next part --------------
Index: dlls/dsound/tests/dsound.c
===================================================================
RCS file: /var/cvs/wine/dlls/dsound/tests/dsound.c,v
retrieving revision 1.20
diff -u -r1.20 dsound.c
--- a/dlls/dsound/tests/dsound.c 20 Jan 2004 21:49:48 -0000 1.20
+++ b/dlls/dsound/tests/dsound.c 18 May 2004 21:38:12 -0000
@@ -73,16 +73,21 @@
#define PI 3.14159265358979323846
static char* wave_generate_la(WAVEFORMATEX* wfx, double duration, DWORD* size)
{
- int i;
+ int i,fade;
int nb_samples;
char* buf;
char* b;
+ fade=wfx->nSamplesPerSec/100;
nb_samples=(int)(duration*wfx->nSamplesPerSec);
*size=nb_samples*wfx->nBlockAlign;
b=buf=malloc(*size);
for (i=0;i<nb_samples;i++) {
double y=sin(440.0*2*PI*i/wfx->nSamplesPerSec);
+ if (i<fade)
+ y=y*i/fade;
+ else if (nb_samples-i<fade)
+ y=y*(nb_samples-1-i)/fade;
if (wfx->wBitsPerSample==8) {
unsigned char sample=(unsigned char)((double)127.5*(y+1.0));
*b++=sample;
Index: dlls/winmm/tests/wave.c
===================================================================
RCS file: /var/cvs/wine/dlls/winmm/tests/wave.c,v
retrieving revision 1.22
diff -u -r1.22 wave.c
--- a/dlls/winmm/tests/wave.c 14 May 2004 04:54:54 -0000 1.22
+++ b/dlls/winmm/tests/wave.c 18 May 2004 22:07:03 -0000
@@ -73,16 +54,21 @@
#define PI 3.14159265358979323846
static char* wave_generate_la(WAVEFORMATEX* wfx, double duration, DWORD* size)
{
- int i;
+ int i,fade;
int nb_samples;
char* buf;
char* b;
- nb_samples=(int)(duration*wfx->nSamplesPerSec);
+ fade=wfx->nSamplesPerSec/100;
+ nb_samples=(int)(duration*wfx->nSamplesPerSec)+1;
*size=nb_samples*wfx->nBlockAlign;
b=buf=malloc(*size);
for (i=0;i<nb_samples;i++) {
double y=sin(440.0*2*PI*i/wfx->nSamplesPerSec);
+ if (i<fade)
+ y=y*i/fade;
+ else if (nb_samples-i<fade)
+ y=y*(nb_samples-1-i)/fade;
if (wfx->wBitsPerSample==8) {
unsigned char sample=(unsigned char)((double)127.5*(y+1.0));
*b++=sample;
More information about the wine-patches
mailing list