aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2014-09-18 16:33:35 +0000
committerDimitri Sokolyuk <demon@dim13.org>2014-09-18 16:33:35 +0000
commit1d95aaae57f555f8b6930cf223316fb2ab6fc430 (patch)
treece3621fc7d10e754a82f83e5096be9e53e833f5d
parent33652e007609f316c2cb8543b88d4e38738b0957 (diff)
basic data display
-rw-r--r--Sgraph.c14
-rw-r--r--fft.c10
-rw-r--r--fft.h2
-rw-r--r--spectrogram.c3
4 files changed, 19 insertions, 10 deletions
diff --git a/Sgraph.c b/Sgraph.c
index a8e1e3f..3251384 100644
--- a/Sgraph.c
+++ b/Sgraph.c
@@ -250,22 +250,30 @@ Redisplay(Widget w, XEvent *event, Region r)
0, 0, width, height);
*/
+ /*
XDrawLine(XtDisplay(sw), sw->sgraph.backBuf, sw->sgraph.foreGC,
0, height / 2, 2 * width, height / 2);
XDrawLine(XtDisplay(sw), sw->sgraph.backBuf, sw->sgraph.foreGC,
0, height / 2 + height, 2 * width, height / 2 + height);
+ */
for (x = 0; x < sw->sgraph.size; x++) {
- yl = sw->sgraph.leftData[x] * height / 2;
+ if (x > width)
+ yl = sw->sgraph.leftData[x] * height / 2;
+ else
+ yl = sw->sgraph.leftData[x];
yl += height / 2;
yr = sw->sgraph.rightData[x] * height / 2;
yr += height / 2;
yr += height;
- XDrawPoint(XtDisplay(sw), sw->sgraph.backBuf,
- sw->sgraph.foreGC, x, yl);
+ XDrawLine(XtDisplay(sw), sw->sgraph.backBuf,
+ sw->sgraph.foreGC,
+ x, height / 2, x, yl);
+ /*
XDrawPoint(XtDisplay(sw), sw->sgraph.backBuf,
sw->sgraph.foreGC, x, yr);
+ */
}
/* flicker test */
diff --git a/fft.c b/fft.c
index 84e8a95..48a084e 100644
--- a/fft.c
+++ b/fft.c
@@ -43,10 +43,8 @@ hamming(size_t n)
p = calloc(n, sizeof(double));
assert(p);
- for (i = 0; i < n; i++) {
+ for (i = 0; i < n; i++)
p[i] = alpha - beta * cos(2 * M_PI * i / (n - 1));
- p[i] /= INT16_MAX;
- }
return p;
}
@@ -67,10 +65,10 @@ squares(size_t n)
}
int
-init_fft(size_t maxn, size_t n)
+init_fft(size_t n)
{
- in = fftw_malloc(maxn * sizeof(double));
- out = fftw_malloc(maxn * sizeof(fftw_complex) / 2);
+ in = fftw_malloc(n * sizeof(double));
+ out = fftw_malloc(n * sizeof(fftw_complex) / 2);
assert(in && out);
plan = fftw_plan_dft_r2c_1d(n, in, out, FFTW_MEASURE);
diff --git a/fft.h b/fft.h
index 200a763..ddbc053 100644
--- a/fft.h
+++ b/fft.h
@@ -19,7 +19,7 @@
#define __FFT_H
__BEGIN_DECLS
-int init_fft(size_t, size_t);
+int init_fft(size_t);
int exec_fft(double *);
void free_fft(void);
__END_DECLS
diff --git a/spectrogram.c b/spectrogram.c
index 3c7dbad..384edef 100644
--- a/spectrogram.c
+++ b/spectrogram.c
@@ -84,6 +84,8 @@ worker(XtPointer data)
XtGetValues(data, arg, n);
size = read_sio(left, right, size);
+ exec_fft(left);
+ exec_fft(right);
//warnx("samples: %d, size: %d, %d", samples, size, n);
//warnx("l/r: %p (%lf) / %p (%lf)", left, *left, right, *right);
@@ -109,6 +111,7 @@ main(int argc, char **argv)
usage();
samples = init_sio();
+ init_fft(samples);
warnx("samples: %d", samples);
n = 0;