summaryrefslogtreecommitdiff
path: root/bluenoise.c
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@redhat.com>2010-09-25 00:58:37 -0400
committerSøren Sandmann Pedersen <ssp@redhat.com>2010-09-25 00:58:37 -0400
commit9b14b53493320ce38e00b5b687e3ad30b389cac1 (patch)
tree62fb62ac97fe8f88ed80db205861b92464af9d1b /bluenoise.c
parent6f2cfe869efbc2d15dda6949013f499c3389a019 (diff)
noise
Diffstat (limited to 'bluenoise.c')
-rw-r--r--bluenoise.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/bluenoise.c b/bluenoise.c
new file mode 100644
index 0000000..ed57192
--- /dev/null
+++ b/bluenoise.c
@@ -0,0 +1,45 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include "fft.h"
+
+#define N_SAMPLES 512
+
+#define K ((2 * M_PI) / N_SAMPLES)
+
+static double
+ssin (double f)
+{
+ return 0.5 * (sin (K * f) + 1.0);
+}
+
+static double
+scos (double f)
+{
+ return 0.5 * (cos (K * f) + 1.0);
+}
+
+int
+main ()
+{
+ complex_t *noise = malloc (sizeof (complex_t) * N_SAMPLES * N_SAMPLES);
+ int i, j;
+
+ for (i = 0; i < N_SAMPLES; ++i)
+ {
+ for (j = 0; j < N_SAMPLES; ++j)
+ {
+ noise[i * N_SAMPLES + j].re = drand48();
+ noise[i * N_SAMPLES + j].im = 0;
+ }
+ }
+
+ fft_2d (noise, N_SAMPLES);
+
+ shift_2d (noise, N_SAMPLES);
+
+ show_image (noise, N_SAMPLES);
+
+ return 0;
+}