# HG changeset patch # User nenolod # Date 1162552226 28800 # Node ID 5e8cf0611af3cba692b3c79413ea76a8dac9dfda # Parent 4b48e6e9b3cb62677075083bf9ab29597543c19a [svn] - faster line calculation algorithm (only calculates 256 or 128 points of the waveform) - update rush preset (DON'T use lines here.) diff -r 4b48e6e9b3cb -r 5e8cf0611af3 ChangeLog --- a/ChangeLog Fri Nov 03 02:54:12 2006 -0800 +++ b/ChangeLog Fri Nov 03 03:10:26 2006 -0800 @@ -1,3 +1,13 @@ +2006-11-03 10:54:12 +0000 William Pitcock + revision [386] + - rewrite line drawing algorithm for speed + - use lines instead of dots by default in horizontal and vertical waveforms + + trunk/src/paranormal/drawing.c | 68 ++++---------------- + trunk/src/paranormal/wave.c | 138 ++++++++++++++++++++++++++++++++++++++++- + 2 files changed, 151 insertions(+), 55 deletions(-) + + 2006-11-03 06:19:05 +0000 William Pitcock revision [384] - add fast linedrawing code diff -r 4b48e6e9b3cb -r 5e8cf0611af3 src/paranormal/presets/nenolod_-_rush.pnv --- a/src/paranormal/presets/nenolod_-_rush.pnv Fri Nov 03 02:54:12 2006 -0800 +++ b/src/paranormal/presets/nenolod_-_rush.pnv Fri Nov 03 03:10:26 2006 -0800 @@ -12,9 +12,13 @@ -1 + 255 + FALSE -1 + 255 + FALSE 0 diff -r 4b48e6e9b3cb -r 5e8cf0611af3 src/paranormal/wave.c --- a/src/paranormal/wave.c Fri Nov 03 02:54:12 2006 -0800 +++ b/src/paranormal/wave.c Fri Nov 03 03:10:26 2006 -0800 @@ -2,6 +2,8 @@ # include #endif +#include + #include "paranormal.h" #include "actuators.h" #include "pn_utils.h" @@ -60,40 +62,42 @@ guchar value = (opts[1].val.ival < 0 || opts[1].val.ival > 255) ? 255 : opts[1].val.ival; int *x_pos, *y_pos; /* dynamic tables which store the positions for the line */ int *x2_pos, *y2_pos; /* dynamic tables which store the positions for the line */ - int i; + int i, step; - x_pos = g_new0(int, pn_image_data->width + 1); - y_pos = g_new0(int, pn_image_data->width + 1); - x2_pos = g_new0(int, pn_image_data->width + 1); - y2_pos = g_new0(int, pn_image_data->width + 1); + x_pos = g_new0(int, 257); + y_pos = g_new0(int, 257); + x2_pos = g_new0(int, 257); + y2_pos = g_new0(int, 257); + + step = round((gfloat)pn_image_data->width / 256.0); /* calculate the line. */ - for (i = 0; i < pn_image_data->width; i++) + for (i = 0; i < 256; i++) { if (opts[0].val.ival != 0) { - x_pos[i] = i; + x_pos[i] = i * step; y_pos[i] = (pn_image_data->height>>1) - - CAP (pn_sound_data->pcm_data[channel][i*512/pn_image_data->width]>>8, + CAP (pn_sound_data->pcm_data[channel][i * 2]>>8, (pn_image_data->height>>1)-1); } else { - x_pos[i] = i; + x_pos[i] = i * step; y_pos[i] = (pn_image_data->height>>2) - - CAP (pn_sound_data->pcm_data[0][i*512/pn_image_data->width]>>9, + CAP (pn_sound_data->pcm_data[0][i * 2]>>9, (pn_image_data->height>>2)-1); - x2_pos[i] = i; + x2_pos[i] = i * step; y2_pos[i] = 3*(pn_image_data->height>>2) - - CAP (pn_sound_data->pcm_data[1][i*512/pn_image_data->width]>>9, + CAP (pn_sound_data->pcm_data[1][i * 2]>>9, (pn_image_data->height>>2)-1); } } /* draw the line. */ - for (i = 1; i < pn_image_data->width; i++) + for (i = 1; i < 256; i++) { pn_draw_line(x_pos[i - 1], y_pos[i - 1], x_pos[i], y_pos[i], value); @@ -176,42 +180,44 @@ guchar value = (opts[1].val.ival < 0 || opts[1].val.ival > 255) ? 255 : opts[1].val.ival; int *x_pos, *y_pos; /* dynamic tables which store the positions for the line */ int *x2_pos, *y2_pos; /* dynamic tables which store the positions for the line */ - int i; + int i, step; - x_pos = g_new0(int, pn_image_data->height + 1); - y_pos = g_new0(int, pn_image_data->height + 1); - x2_pos = g_new0(int, pn_image_data->height + 1); - y2_pos = g_new0(int, pn_image_data->height + 1); + x_pos = g_new0(int, 129); + y_pos = g_new0(int, 129); + x2_pos = g_new0(int, 129); + y2_pos = g_new0(int, 129); + + step = round((gfloat)pn_image_data->height / 128.0); /* calculate the line. */ - for (i = 0; i < pn_image_data->height; i++) + for (i = 0; i < 128; i++) { if (opts[0].val.ival != 0) { x_pos[i] = (pn_image_data->width>>1) - CAP (pn_sound_data->pcm_data[channel] - [i*512/pn_image_data->height]>>8, + [i*4]>>8, (pn_image_data->width>>1)-1); - y_pos[i] = i; + y_pos[i] = i * step; } else { x_pos[i] = (pn_image_data->width>>2) - CAP (pn_sound_data->pcm_data[0] - [i*512/pn_image_data->height]>>9, + [i*4]>>9, (pn_image_data->width>>2)-1); - y_pos[i] = i; + y_pos[i] = i * step; x2_pos[i] = 3*(pn_image_data->width>>2) - CAP (pn_sound_data->pcm_data[1] - [i*512/pn_image_data->height]>>9, + [i*4]>>9, (pn_image_data->width>>2)-1); - y2_pos[i] = i; + y2_pos[i] = i * step; } } /* draw the line. */ - for (i = 1; i < pn_image_data->width; i++) + for (i = 1; i < 128; i++) { pn_draw_line(x_pos[i - 1], y_pos[i - 1], x_pos[i], y_pos[i], value);