Add fft, 2d_fft and sinwave to examples.
[Faustine.git] / examples / sinwave / sin.dsp
diff --git a/examples/sinwave/sin.dsp b/examples/sinwave/sin.dsp
new file mode 100644 (file)
index 0000000..b1650f2
--- /dev/null
@@ -0,0 +1,19 @@
+//sin = ffunction(float sin(float), <math.h>, "");
+//floor = ffunction(float floor(float), <math.h>, "");
+PI = 3.141592653589;
+
+tablesize = 40000;
+samplingfreq = 44100.;
+
+time = (+(1)~_) - 1;
+sinwavform = time * (2 * PI)/tablesize : sin;
+
+decimal = _ <: -(floor);
+phase(freq) = freq / samplingfreq : mem : ( + : decimal) ~ _ : * (tablesize) : int;
+osc(freq) = phase(freq) : rdtable(tablesize, sinwavform);
+
+vol = 1;
+freq = 1000;
+
+process = osc(freq) * vol;
+//process = freq / samplingfreq : @(1): ( + : decimal) ~ _ : * (tablesize) : int ;