Changeset 5186:9667c5a66a36 in roaraudio for roarclients


Ignore:
Timestamp:
10/22/11 20:06:20 (12 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added code to enable endless generation without accuracy errors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roarclients/roarsin.c

    r4885 r5186  
    8080 float freq   = 523.2;            /* middle C */ 
    8181 float t      = 0; /* current time */ 
     82 float tcalc  = 0; /* current time for calculation */ 
    8283 float length = 5; /* 5 sec */ 
    8384 float step;       /* how much time per sample we have to encode ... */ 
     
    117118 while (t < 2*M_PI*freq*length) { 
    118119  for (i = 0; i < 1024; i++) { 
    119    out[i] = 32767*func(t); 
    120    t += step; 
     120   out[i] = 32767*func(tcalc); 
     121   t     += step; 
     122   tcalc += step; 
    121123  } 
    122124  roar_vs_write(vss, out, 2048, NULL); 
     125 
     126  // this code enables us to generate the same signal for a long periode of time 
     127  // without loosing accuracy of the float type. 
     128  while (tcalc > 2*M_PI) 
     129   tcalc -= 2*M_PI; 
    123130 } 
    124131 
Note: See TracChangeset for help on using the changeset viewer.