diff src/paranormal/wave.c @ 304:3d0b7ca9c8eb trunk

[svn] - add pn_draw_dot() and convert some functions to use that instead of redundant checks all over the code.
author nenolod
date Thu, 23 Nov 2006 00:02:25 -0800
parents 44ad758c2d98
children 3b034150d31e
line wrap: on
line diff
--- 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);