Update of /cvsroot/alsa/alsa-lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16320
Modified Files:
pcm.c
Log Message:
Maarten de Boer <[EMAIL PROTECTED]>
The attached patch makes the alsa-lib/test/pmc.c generate_sine code
slightly more simple, efficient and readable (but not less accurate),
taking quite some calculation out of the loop.
Index: pcm.c
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/test/pcm.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- pcm.c 5 Feb 2004 11:01:55 -0000 1.30
+++ pcm.c 5 Mar 2004 09:11:13 -0000 1.31
@@ -29,9 +29,9 @@
snd_pcm_uframes_t offset,
int count, double *_phase)
{
+ static double max_phase = 2. * M_PI;
double phase = *_phase;
- double max_phase = 1.0 / freq;
- double step = 1.0 / (double)rate;
+ double step = max_phase*freq/(double)rate;
double res;
signed short *samples[channels];
int steps[channels];
@@ -53,7 +53,7 @@
}
/* fill the channel areas */
while (count-- > 0) {
- res = sin((phase * 2 * M_PI) / max_phase - M_PI) * 32767;
+ res = sin(phase) * 32767;
ires = res;
for (chn = 0; chn < channels; chn++) {
*samples[chn] = ires;
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Alsa-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-cvslog