CSUSM FM Synth 2017 / Mbed 2 deprecated FMSynthCSUSM

Dependencies:   mbed

Fork of STM32FMSynth by Steven Clark

Revision:
3:83ac767f3a63
Parent:
2:5454dee210ed
Child:
4:1d2a699c95c7
diff -r 5454dee210ed -r 83ac767f3a63 main.cpp
--- a/main.cpp	Mon Nov 27 22:05:48 2017 +0000
+++ b/main.cpp	Tue Nov 28 23:27:34 2017 +0000
@@ -1,4 +1,5 @@
 #include "mbed.h"
+#include "sintable.h"
 
 AnalogOut DAC0(PA_4);//Not labeled in the docs for the f401, but seems to be for all
 AnalogOut DAC1(PA_5);
@@ -77,7 +78,13 @@
 int carR;
 
 int fastSin(const int phase){
-    return 0;
+    int i = phase >> 2;
+    int sum = 0;
+    sum += (phase & 0x3) * sintable[i+1];
+    sum += (0x4 - (phase & 0x3)) * sintable[i];
+    sum = sum >> 2;
+    
+    return sum;
 }
 
 void synthesize(){