aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2014-09-18 13:24:04 +0000
committerDimitri Sokolyuk <demon@dim13.org>2014-09-18 13:24:04 +0000
commit82fb7d543e11b2dae290f5df59685e9dc6b2effc (patch)
tree5b6f4408ef5e1db573de69ab697e94c861ccf4d4
parent3408ce19b34c50ae566f52d3dad7638c41ae6dcd (diff)
flicker
-rw-r--r--Sgraph.c29
-rw-r--r--alsa.c4
-rw-r--r--spectrogram.c1
3 files changed, 22 insertions, 12 deletions
diff --git a/Sgraph.c b/Sgraph.c
index 9e4c89a..a6941d9 100644
--- a/Sgraph.c
+++ b/Sgraph.c
@@ -21,6 +21,7 @@
#include "SgraphP.h"
#include <err.h>
+#include <stdint.h>
static void Initialize(Widget request, Widget w, ArgList args, Cardinal *nargs);
static void Realize(Widget w, XtValueMask *mask, XSetWindowAttributes *attr);
@@ -184,7 +185,7 @@ Resize(Widget w)
winheight = w->core.height;
width = winwidth / 2;
- height = winheight;
+ height = winheight / 4;
warnx("win: %dx%d", winwidth, winheight);
warnx("sub: %dx%d", width, height);
warnx("size: %d", sw->sgraph.size);
@@ -193,15 +194,12 @@ Resize(Widget w)
if (sw->sgraph.bg != None)
XFreePixmap(XtDisplay(sw), sw->sgraph.bg);
sw->sgraph.bg = XCreatePixmap(XtDisplay(sw), XtWindow(sw),
- width, height / 4, DefaultDepthOfScreen(XtScreen(sw)));
- XSetForeground(XtDisplay(sw), sw->sgraph.foreGC, 0xFF0000);
- XFillRectangle(XtDisplay(sw), sw->sgraph.bg, sw->sgraph.foreGC,
- 0, 0, width, height / 4);
+ width, height, DefaultDepthOfScreen(XtScreen(sw)));
if (sw->sgraph.mask != None)
XFreePixmap(XtDisplay(sw), sw->sgraph.mask);
sw->sgraph.mask = XCreatePixmap(XtDisplay(sw), XtWindow(sw),
- width, height / 4, 1);
+ width, height, 1);
}
@@ -210,7 +208,8 @@ Redisplay(Widget w, XEvent *event, Region r)
{
SgraphWidget sw = (SgraphWidget)w;
Dimension width = winwidth / 2;
- Dimension height = winheight;
+ Dimension height = winheight / 4;
+ Dimension x, y;
static Dimension n;
if (!XtIsRealized(w))
@@ -227,12 +226,20 @@ Redisplay(Widget w, XEvent *event, Region r)
width - 2 * BORDER, height - 2 * BORDER);
*/
- warnx("%lf : %lf" , sw->sgraph.leftData[0], sw->sgraph.rightData[0]);
+ //warnx("%lf : %lf" , sw->sgraph.leftData[0], sw->sgraph.rightData[0]);
- XClearWindow(XtDisplay(sw), XtWindow(sw));
- n = (n + 1) % width;
+ XFillRectangle(XtDisplay(sw), sw->sgraph.bg, sw->sgraph.backGC,
+ 0, 0, width, height);
+
+ for (x = 0; x < sw->sgraph.size; x++) {
+ y = sw->sgraph.leftData[x] / (2 * height) + height / 2;
+ XDrawPoint(XtDisplay(sw), sw->sgraph.bg, sw->sgraph.foreGC,
+ x, y);
+ }
+
+ //XClearWindow(XtDisplay(sw), XtWindow(sw));
XCopyArea(XtDisplay(sw), sw->sgraph.bg, XtWindow(sw), sw->sgraph.foreGC,
- 0, 0, width, height / 4, BORDER + n, BORDER);
+ 0, 0, width, height, BORDER, BORDER);
}
static Boolean
diff --git a/alsa.c b/alsa.c
index ebf0ad0..881246f 100644
--- a/alsa.c
+++ b/alsa.c
@@ -73,7 +73,7 @@ init_sio(void)
return samples;
}
-void
+size_t
read_sio(double *left, double *right, size_t n)
{
snd_pcm_sframes_t rc;
@@ -96,6 +96,8 @@ read_sio(double *left, double *right, size_t n)
left[i] = data[i].left;
right[i] = data[i].right;
}
+
+ return n;
}
void
diff --git a/spectrogram.c b/spectrogram.c
index da3f6e6..f45ba21 100644
--- a/spectrogram.c
+++ b/spectrogram.c
@@ -91,6 +91,7 @@ worker(XtPointer data)
n = 0;
XtSetArg(arg[n], XtNsize, size); n++;
XtSetValues(data, arg, n); /* trigger expose */
+ //redisplay(XtDisplay(data), XtWindow(data));
usleep(40); /* emulate 25 Hz */
return False; /* don't remove the work procedure from the list */