# HG changeset patch # User nenolod # Date 1164268945 28800 # Node ID 3d0b7ca9c8eb4cef67d5f86582de967cdad5c74d # Parent 5e19836a2db23bef70e96141ce3cd6cf8a5029c1 [svn] - add pn_draw_dot() and convert some functions to use that instead of redundant checks all over the code. diff -r 5e19836a2db2 -r 3d0b7ca9c8eb ChangeLog --- a/ChangeLog Wed Nov 22 23:00:31 2006 -0800 +++ b/ChangeLog Thu Nov 23 00:02:25 2006 -0800 @@ -1,3 +1,11 @@ +2006-11-23 07:00:31 +0000 William Pitcock + revision [660] + - damn shift key + + trunk/src/paranormal/containers.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + + 2006-11-23 06:59:26 +0000 William Pitcock revision [658] - improve beat detection diff -r 5e19836a2db2 -r 3d0b7ca9c8eb src/paranormal/drawing.c --- a/src/paranormal/drawing.c Wed Nov 22 23:00:31 2006 -0800 +++ b/src/paranormal/drawing.c Thu Nov 23 00:02:25 2006 -0800 @@ -7,6 +7,15 @@ extern SDL_Surface *screen; void +pn_draw_dot (guint x, guint y, guchar value) +{ + if (x > pn_image_data->width || x < 0 || y > pn_image_data->height || y < 0) + return; + + pn_image_data->surface[0][PN_IMG_INDEX(x, y)] = value; +} + +void pn_draw_line (guint _x0, guint _y0, guint _x1, guint _y1, guchar value) { gint x0 = _x0; @@ -17,10 +26,7 @@ gint dx = x1 - x0; gint dy = y1 - y0; - if (x0 > pn_image_data->width || x0 < 0 || y0 > pn_image_data->height || y0 < 0) - return; - - pn_image_data->surface[0][PN_IMG_INDEX(x0, y0)] = value; + pn_draw_dot(x0, y0, value); if (dx != 0) { @@ -33,10 +39,7 @@ x0 += dx; y0 = m * x0 + b; - if (x0 > pn_image_data->width || x0 < 0 || y0 > pn_image_data->height || y0 < 0) - continue; - - pn_image_data->surface[0][PN_IMG_INDEX(x0, y0)] = value; + pn_draw_dot(x0, y0, value); } } } diff -r 5e19836a2db2 -r 3d0b7ca9c8eb src/paranormal/drawing.h --- a/src/paranormal/drawing.h Wed Nov 22 23:00:31 2006 -0800 +++ b/src/paranormal/drawing.h Thu Nov 23 00:02:25 2006 -0800 @@ -3,6 +3,7 @@ #ifndef PN_DRAWING_H #define PN_DRAWING_H +void pn_draw_dot (guint x, guint y, guchar value); void pn_draw_line (guint _x0, guint _y0, guint _x1, guint _y1, guchar value); #endif diff -r 5e19836a2db2 -r 3d0b7ca9c8eb src/paranormal/wave.c --- a/src/paranormal/wave.c Wed Nov 22 23:00:31 2006 -0800 +++ b/src/paranormal/wave.c Thu Nov 23 00:02:25 2006 -0800 @@ -457,7 +457,7 @@ { struct pn_scope_data *data = (struct pn_scope_data *) op_data; gint i; - gdouble *xf, *yf, *index, *value; + gdouble *xf, *yf, *index, *value, *points; if (data->reset) { @@ -487,19 +487,23 @@ yf = dict_variable(data->dict, "y"); index = dict_variable(data->dict, "index"); value = dict_variable(data->dict, "value"); + points = dict_variable(data->dict, "points"); if (data->expr_on_frame != NULL) expr_execute(data->expr_on_frame, data->dict); + if (*points > 513 || *points == 0) + *points = 513; + if (data->expr_on_sample != NULL) { - for (i = 0; i < 513; i++) + for (i = 0; i < *points; i++) { gint x, y; static gint oldx, oldy; *value = 1.0 * pn_sound_data->pcm_data[0][i & 511] / 32768.0; - *index = i / 512.0; + *index = i / (*points - 1); expr_execute(data->expr_on_sample, data->dict);