From 732a482f439f6df818b90634a5abb1b5d64ff05e Mon Sep 17 00:00:00 2001 From: Jesse Chappell Date: Sat, 16 Dec 2006 05:14:34 +0000 Subject: added logarithmic option for waveform scaling. added save/restore of rectified and logscale waveform options in session. modified sconstruct to look for certain libs in some common locations, this should be usable controllable but isnt yet. deals better with the libsndfile build when flac is installed. git-svn-id: svn://localhost/ardour2/trunk@1219 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/canvas-waveview.c | 49 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'gtk2_ardour/canvas-waveview.c') diff --git a/gtk2_ardour/canvas-waveview.c b/gtk2_ardour/canvas-waveview.c index 080f6871fa..747761ea9a 100644 --- a/gtk2_ardour/canvas-waveview.c +++ b/gtk2_ardour/canvas-waveview.c @@ -26,6 +26,7 @@ #include +#include "logmeter.h" #include "canvas-waveview.h" #include "rgb_macros.h" @@ -49,7 +50,8 @@ enum { PROP_HEIGHT, PROP_WAVE_COLOR, PROP_RECTIFIED, - PROP_REGION_START + PROP_REGION_START, + PROP_LOGSCALED, }; static void gnome_canvas_waveview_class_init (GnomeCanvasWaveViewClass *class); @@ -253,6 +255,13 @@ gnome_canvas_waveview_class_init (GnomeCanvasWaveViewClass *class) g_param_spec_boolean ("rectified", NULL, NULL, FALSE, (G_PARAM_READABLE | G_PARAM_WRITABLE))); + + g_object_class_install_property + (gobject_class, + PROP_LOGSCALED, + g_param_spec_boolean ("logscaled", NULL, NULL, + FALSE, + (G_PARAM_READABLE | G_PARAM_WRITABLE))); g_object_class_install_property (gobject_class, @@ -308,6 +317,7 @@ gnome_canvas_waveview_init (GnomeCanvasWaveView *waveview) waveview->gain_curve_function = NULL; waveview->gain_src = NULL; waveview->rectified = FALSE; + waveview->logscaled = FALSE; waveview->region_start = 0; waveview->samples_per_unit = 1.0; waveview->amplitude_above_axis = 1.0; @@ -577,7 +587,29 @@ gnome_canvas_waveview_ensure_cache (GnomeCanvasWaveView *waveview, gulong start_ free (gain); } + + /* do optional log scaling. this implementation is not particularly efficient */ + if (waveview->logscaled) { + guint32 n; + GnomeCanvasWaveViewCacheEntry* buf = cache->data; + + for (n = 0; n < cache->data_size; ++n) { + + if (buf[n].max > 0.0f) { + buf[n].max = alt_log_meter(coefficient_to_dB(buf[n].max)); + } else if (buf[n].max < 0.0f) { + buf[n].max = -alt_log_meter(coefficient_to_dB(-buf[n].max)); + } + + if (buf[n].min > 0.0f) { + buf[n].min = alt_log_meter(coefficient_to_dB(buf[n].min)); + } else if (buf[n].min < 0.0f) { + buf[n].min = -alt_log_meter(coefficient_to_dB(-buf[n].min)); + } + } + } + cache->start = ostart; cache->end = new_cache_end; @@ -770,6 +802,17 @@ gnome_canvas_waveview_set_property (GObject *object, redraw = TRUE; } break; + case PROP_LOGSCALED: + if (waveview->logscaled != g_value_get_boolean(value)) { + waveview->logscaled = g_value_get_boolean(value); + if (waveview->cache_updater) { + waveview->cache->start = 0; + waveview->cache->end = 0; + } + redraw = TRUE; + calc_bounds = TRUE; + } + break; case PROP_REGION_START: waveview->region_start = g_value_get_uint(value); redraw = TRUE; @@ -869,6 +912,10 @@ gnome_canvas_waveview_get_property (GObject *object, g_value_set_boolean (value, waveview->rectified); break; + case PROP_LOGSCALED: + g_value_set_boolean (value, waveview->logscaled); + break; + case PROP_REGION_START: g_value_set_uint (value, waveview->region_start); break; -- cgit v1.2.3