Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: LUTs/LUTS.cpp
- Revision:
- 30:08cc4ec58d07
- Parent:
- 29:207111ffd6e6
- Child:
- 31:cfdb014ff086
--- a/LUTs/LUTS.cpp Mon May 25 20:00:31 2020 +0000
+++ b/LUTs/LUTS.cpp Tue May 26 10:17:47 2020 +0000
@@ -20,11 +20,10 @@
void LUTs::sin_wavetable()
{
- printf("Generating sin Wavetable \n");
+ //printf("Generating sin Wavetable \n");
for (int i=0; i<1024; i++) {
sin_d= 65535*(0.5*sin(2.0*PI*(i/1024.0))+0.5);
- //calculates remainder for rounding
- rem= fmod(sin_d,1);
+ rem= fmod(sin_d,1); //calculates remainder for rounding
//printf("preround= %g -", sin_d); //DEBUG
if (rem>=0.5) {
sin_d=ceil(sin_d); //round UP
@@ -40,13 +39,12 @@
/*//DEBUG
for (int i=0; i<1024; i=i+128) {
printf("sin_wav[%d]= %u \n", i, sin_wavtable);
- }
- */
+ } */
}
void LUTs::tri_wavetable(int pulsewidth)
{
- printf("Generating Tri-wavetable\n");
+ //printf("Generating Tri-wavetable\n");
tri_wavtable[0]=0;
rise_t=(pulsewidth*1024/100);
rise_tu=(uint16_t)rise_t;
@@ -54,14 +52,13 @@
dif=65536/rise_t;
dif_u=(uint16_t)dif;
- /*#ifdef SLOW_TIME
+ #ifdef SLOW_TIME
printf("PRINTING TRI WAVETABLE Values\n");
printf("PW= %d \n",pulsewidth);
printf("Rise Samples= %u\n", rise_tu);
printf("Fall Samples= %u\n", fall_tu);
printf("UP sample dif= %u\n", dif_u);
- #endif
- */
+ #endif
for (int i=1; i<=rise_tu; i++) {
tri_wavtable[i]=tri_wavtable[i-1]+dif_u;
}
@@ -70,12 +67,11 @@
#ifdef SLOW_TIME
//printf("down sample dif= %u\n", dif_u);
- #endif
-
+ #endif
for (int i=rise_tu; i<1024; i++) {
tri_wavtable[i]=65535-((i-rise_tu)*dif_u);
}
-
+
#ifdef SLOW_TIME
//tri_wav_results();
#endif
@@ -104,26 +100,4 @@
for (i=0; i<=1024; i=i+64) {
printf("%d, %u\n",i,tri_wavtable[i]);
}
- }
-
-/*
-uint16_t get_sin(int i)
-{
- //calculates sin val as double (0->65535)
-
- sin_d= 65535*(0.5*sin(2.0*PI*(i/1024.0))+0.5);
- //calculates remainder for rounding
- rem= fmod(sin_d,1);
- //printf("preround= %g -", sin_d[i]); //DEBUG
- if (rem>=0.5) {
- sin_d=ceil(sin_d); //round UP
- } else {
- sin_d= floor(sin_d-rem); //round DOWN
- }
- //printf("Postround= %g -",sin_d[i]); //DEBUG
- return((uint16_t)sin_d);
-
- //summed into one function
- return((uint16_t)floor(65535*(0.5*sin(2.0*PI*(i/1024.0))+0.5)));
-}
-*/
\ No newline at end of file
+ }
\ No newline at end of file