#include <cairo.h>
#include <string.h>
#include <limits.h>
+#include <unistd.h>
#include "ardour/dB.h"
#include "canvas-waveview.h"
#include "rgb_macros.h"
+/* POSIX guarantees casting between void* and function pointers, ISO C doesn't
+ * We can work around warnings by going one step deeper in our casts
+ */
+#ifdef _POSIX_VERSION
+#define POSIX_FUNC_PTR_CAST(type, object) *((type*) &(object))
+#endif // _POSIX_VERSION
extern void c_stacktrace();
static void
gnome_canvas_waveview_destroy (GtkObject *object)
{
- GnomeCanvasWaveView *waveview;
-
g_return_if_fail (object != NULL);
g_return_if_fail (GNOME_IS_CANVAS_WAVEVIEW (object));
- waveview = GNOME_CANVAS_WAVEVIEW (object);
-
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
item = GNOME_CANVAS_ITEM (object);
waveview = GNOME_CANVAS_WAVEVIEW (object);
+ void * ptr;
switch (prop_id) {
case PROP_DATA_SRC:
gnome_canvas_waveview_set_data_src (waveview, g_value_get_pointer(value));
break;
case PROP_LENGTH_FUNCTION:
- waveview->length_function = (gulong (*)(void*)) g_value_get_pointer(value);
+ ptr = g_value_get_pointer(value);
+ waveview->length_function = POSIX_FUNC_PTR_CAST(waveview_length_function_t, ptr);
redraw = TRUE;
break;
case PROP_SOURCEFILE_LENGTH_FUNCTION:
- waveview->sourcefile_length_function = (gulong (*)(void*,double)) g_value_get_pointer(value);
+ ptr = g_value_get_pointer(value);
+ waveview->sourcefile_length_function = POSIX_FUNC_PTR_CAST(waveview_sourcefile_length_function_t, ptr);
redraw = TRUE;
break;
case PROP_PEAK_FUNCTION:
- waveview->peak_function =
- (void (*)(void*,gulong,gulong,gulong,gpointer,guint32,double))
- g_value_get_pointer(value);
+ ptr = g_value_get_pointer(value);
+ waveview->peak_function = POSIX_FUNC_PTR_CAST(waveview_peak_function_t, ptr);
redraw = TRUE;
break;
case PROP_GAIN_FUNCTION:
- waveview->gain_curve_function =
- (void (*)(void *arg, double start, double end, float* vector, gint64 veclen))
- g_value_get_pointer(value);
+ ptr = g_value_get_pointer(value);
+ waveview->gain_curve_function = POSIX_FUNC_PTR_CAST(waveview_gain_curve_function_t, ptr);
redraw = TRUE;
break;
break;
case PROP_LENGTH_FUNCTION:
- g_value_set_pointer(value, (void*) waveview->length_function);
+ g_value_set_pointer(value, POSIX_FUNC_PTR_CAST(void*, waveview->length_function));
break;
case PROP_SOURCEFILE_LENGTH_FUNCTION:
- g_value_set_pointer(value, (void*) waveview->sourcefile_length_function);
+ g_value_set_pointer(value, POSIX_FUNC_PTR_CAST(void*, waveview->sourcefile_length_function));
break;
case PROP_PEAK_FUNCTION:
- g_value_set_pointer(value, (void*) waveview->peak_function);
+ g_value_set_pointer(value, POSIX_FUNC_PTR_CAST(void*, waveview->peak_function));
break;
case PROP_GAIN_FUNCTION:
- g_value_set_pointer(value, (void*) waveview->gain_curve_function);
+ g_value_set_pointer(value, POSIX_FUNC_PTR_CAST(void*, waveview->gain_curve_function));
break;
case PROP_GAIN_SRC:
int next_clip_max = 0;
int next_clip_min = 0;
+ int wave_middle = (int) rint ((item->y1 + origin) * item->canvas->pixels_per_unit);
+ int wave_top = (int) rint ((item->y1) * item->canvas->pixels_per_unit);
+
if (s1 < waveview->samples_per_unit) {
/* we haven't got a prev vars to compare with, so outline the whole line here */
prev_pymax = (int) rint ((item->y1 + origin) * item->canvas->pixels_per_unit);
++fill_max;
}
else {
- PAINT_VERTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymax, fill_max);
- }
+ PAINT_VERTA_GR(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymax, fill_max, wave_middle, wave_top); }
}
if((prev_pymin > pymin && next_pymin > pymin) ||
PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymin);
}
else {
- PAINT_VERTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, fill_min, pymin);
+ PAINT_VERTA_GR(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, fill_min, pymin, wave_middle, wave_top);
}
}
if(fill_max < fill_min) {
- PAINT_VERTA(buf, waveview->fill_r, waveview->fill_g, waveview->fill_b, waveview->fill_a, x, fill_max, fill_min);
+ PAINT_VERTA_GR(buf, waveview->fill_r, waveview->fill_g, waveview->fill_b, waveview->fill_a, x, fill_max, fill_min, wave_middle, wave_top);
}
else if(fill_max == fill_min) {
PAINT_DOTA(buf, waveview->fill_r, waveview->fill_g, waveview->fill_b, waveview->fill_a, x, fill_max);
}
if (clip_max) {
- PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a, x, pymax, pymax+clip_length);
+ PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a, x, pymax, pymax + clip_length);
+ PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a >> 1, x + 1, pymax, pymax + (clip_length -1));
+ PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a >> 1, x - 1, pymax, pymax + (clip_length - 1));
+
}
if (clip_min) {
- PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a, x, pymin-clip_length, pymin);
+ PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a , x, pymin - clip_length, pymin);
+ PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a >> 1, x + 1, pymin - (clip_length - 1), pymin);
+ PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a >> 1, x - 1, pymin - (clip_length - 1), pymin);
}
prev_pymax = pymax;
int next_clip_max = 0;
int next_clip_min = 0;
+ int wave_middle = (int) rint ((item->y1 + waveview->height) * item->canvas->pixels_per_unit);
+ int wave_top = (int) rint ((item->y1) * item->canvas->pixels_per_unit);
+
// for rectified, this stays constant throughout the loop
pymin = (int) rint ((item->y1 + waveview->height) * item->canvas->pixels_per_unit);
++fill_max;
}
else {
- PAINT_VERTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymax, fill_max);
+ PAINT_VERTA_GR(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymax, fill_max, wave_middle, wave_top);
}
}
}
if (clip_max) {
- PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a, x, pymax, pymax+clip_length);
+ PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a, x, pymax, pymax + clip_length);
+ PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a >> 1, x + 1, pymax, pymax + (clip_length -1));
+ PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a >> 1, x - 1, pymax, pymax + (clip_length - 1));
}
- if (clip_min) {
- PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a, x, pymin-clip_length, pymin);
+ if (clip_min) {
+ PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a , x, pymin - clip_length, pymin);
+ PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a >> 1, x + 1, pymin - (clip_length - 1), pymin);
+ PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a >> 1, x - 1, pymin - (clip_length - 1), pymin);
}
prev_pymax = pymax;
}
}
- if (!waveview->rectified && waveview->zero_line) {
+ if (!waveview->rectified && waveview->zero_line && waveview->height >= 100) {
// Paint zeroline.
- //PAINT_HORIZA(buf, waveview->zero_r, waveview->zero_g, waveview->zero_b, waveview->zero_a, begin, endi-1, origin );
unsigned char zero_r, zero_g, zero_b, zero_a;
- UINT_TO_RGBA( waveview->zero_color, &zero_r, &zero_g, &zero_b, &zero_a );
+ UINT_TO_RGBA( waveview->zero_color, &zero_r, &zero_g, &zero_b, &zero_a);
int zeroline_y = (int) rint ((item->y1 + origin) * item->canvas->pixels_per_unit);
PAINT_HORIZA(buf, zero_r, zero_g, zero_b, zero_a, zbegin, zend, zeroline_y);
}
int cache_index;
gboolean rectify;
double origin;
- double clip_length;
double xoff;
double yoff = 0.0;
double ulx;
rectify = FALSE;
}
- clip_length = MIN(5,(waveview->height/4));
-
cr = gdk_cairo_create (drawable);
cairo_set_line_width (cr, 0.5);