2013-04-10 15:27:55 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2011-2013 Paul Davis
|
|
|
|
Author: Carl Hetherington <cth@carlh.net>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
#include <boost/shared_ptr.hpp>
|
2013-04-10 15:27:55 -04:00
|
|
|
#include <boost/shared_array.hpp>
|
2013-06-27 17:23:34 -04:00
|
|
|
#include <boost/scoped_array.hpp>
|
2013-04-04 18:45:27 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
#include "pbd/properties.h"
|
2013-04-04 18:45:27 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
#include "ardour/types.h"
|
2013-04-04 18:45:27 -04:00
|
|
|
|
|
|
|
#include <glibmm/refptr.h>
|
|
|
|
|
2013-12-27 16:24:58 -05:00
|
|
|
#include "canvas/visibility.h"
|
2013-04-04 00:32:52 -04:00
|
|
|
#include "canvas/item.h"
|
|
|
|
#include "canvas/fill.h"
|
|
|
|
#include "canvas/outline.h"
|
|
|
|
|
|
|
|
namespace ARDOUR {
|
|
|
|
class AudioRegion;
|
|
|
|
}
|
|
|
|
|
2013-04-04 18:45:27 -04:00
|
|
|
namespace Gdk {
|
|
|
|
class Pixbuf;
|
|
|
|
}
|
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
class WaveViewTest;
|
|
|
|
|
|
|
|
namespace ArdourCanvas {
|
|
|
|
|
2013-12-27 16:24:58 -05:00
|
|
|
class LIBCANVAS_API WaveView : virtual public Item, public Outline, public Fill
|
2013-04-04 00:32:52 -04:00
|
|
|
{
|
|
|
|
public:
|
2013-04-16 10:07:52 -04:00
|
|
|
enum Shape {
|
|
|
|
Normal,
|
|
|
|
Rectified,
|
|
|
|
};
|
|
|
|
|
2013-06-18 23:03:20 -04:00
|
|
|
/* Displays a single channel of waveform data for the given Region.
|
|
|
|
|
|
|
|
x = 0 in the waveview corresponds to the first waveform datum taken
|
|
|
|
from region->start() samples into the source data.
|
|
|
|
|
|
|
|
x = N in the waveview corresponds to the (N * spp)'th sample
|
|
|
|
measured from region->start() into the source data.
|
|
|
|
|
|
|
|
when drawing, we will map the zeroth-pixel of the waveview
|
|
|
|
into a window.
|
|
|
|
|
|
|
|
The waveview itself contains a set of pre-rendered Cairo::ImageSurfaces
|
|
|
|
that cache sections of the display. This is filled on-demand and
|
|
|
|
never cleared until something explicitly marks the cache invalid
|
|
|
|
(such as a change in samples_per_pixel, the log scaling, rectified or
|
|
|
|
other view parameters).
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
WaveView (Group *, boost::shared_ptr<ARDOUR::AudioRegion>);
|
2013-06-20 14:37:31 -04:00
|
|
|
~WaveView ();
|
2013-04-04 00:32:52 -04:00
|
|
|
|
|
|
|
void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
|
|
|
|
void compute_bounding_box () const;
|
2013-04-16 14:04:59 -04:00
|
|
|
|
2013-04-12 11:31:17 -04:00
|
|
|
void set_samples_per_pixel (double);
|
2013-04-04 00:32:52 -04:00
|
|
|
void set_height (Distance);
|
|
|
|
void set_channel (int);
|
|
|
|
void set_region_start (ARDOUR::frameoffset_t);
|
2013-04-16 20:38:10 -04:00
|
|
|
|
|
|
|
void set_fill_color (Color);
|
|
|
|
void set_outline_color (Color);
|
2013-04-04 00:32:52 -04:00
|
|
|
|
|
|
|
void region_resized ();
|
2013-04-17 15:22:09 -04:00
|
|
|
void gain_changed ();
|
2013-04-04 00:32:52 -04:00
|
|
|
|
2013-04-16 10:07:52 -04:00
|
|
|
void set_show_zero_line (bool);
|
|
|
|
bool show_zero_line() const { return _show_zero; }
|
|
|
|
void set_zero_color (Color);
|
|
|
|
void set_clip_color (Color);
|
|
|
|
void set_logscaled (bool);
|
2013-04-16 21:23:50 -04:00
|
|
|
void set_gradient_depth (double);
|
|
|
|
double gradient_depth() const { return _gradient_depth; }
|
2013-04-16 10:07:52 -04:00
|
|
|
void set_shape (Shape);
|
2013-04-17 15:22:09 -04:00
|
|
|
|
2013-04-16 18:02:12 -04:00
|
|
|
/* currently missing because we don't need them (yet):
|
|
|
|
set_shape_independent();
|
|
|
|
set_logscaled_independent()
|
|
|
|
*/
|
2013-04-04 00:32:52 -04:00
|
|
|
|
2013-04-16 21:23:50 -04:00
|
|
|
static void set_global_gradient_depth (double);
|
2013-04-16 18:02:12 -04:00
|
|
|
static void set_global_logscaled (bool);
|
|
|
|
static void set_global_shape (Shape);
|
2013-06-28 20:21:30 -04:00
|
|
|
static void set_global_show_waveform_clipping (bool);
|
2013-04-16 18:02:12 -04:00
|
|
|
|
2013-04-16 21:23:50 -04:00
|
|
|
static double global_gradient_depth() { return _global_gradient_depth; }
|
|
|
|
static bool global_logscaled() { return _global_logscaled; }
|
|
|
|
static Shape global_shape() { return _global_shape; }
|
2013-04-16 14:04:59 -04:00
|
|
|
|
2013-04-17 15:22:09 -04:00
|
|
|
void set_amplitude_above_axis (double v);
|
|
|
|
double amplitude_above_axis () const { return _amplitude_above_axis; }
|
|
|
|
|
2013-12-30 15:46:44 -05:00
|
|
|
static void set_clip_level (double dB);
|
|
|
|
static PBD::Signal0<void> ClipLevelChanged;
|
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
#ifdef CANVAS_COMPATIBILITY
|
|
|
|
void*& property_gain_src () {
|
|
|
|
return _foo_void;
|
|
|
|
}
|
|
|
|
void*& property_gain_function () {
|
|
|
|
return _foo_void;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
void* _foo_void;
|
2013-04-17 15:22:09 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
#endif
|
|
|
|
|
2013-06-27 17:23:34 -04:00
|
|
|
friend class ::WaveViewTest;
|
2013-04-04 00:32:52 -04:00
|
|
|
|
2013-06-27 17:23:34 -04:00
|
|
|
void invalidate_image ();
|
2013-04-04 00:32:52 -04:00
|
|
|
|
|
|
|
boost::shared_ptr<ARDOUR::AudioRegion> _region;
|
2013-04-16 18:02:12 -04:00
|
|
|
int _channel;
|
2013-04-12 11:31:17 -04:00
|
|
|
double _samples_per_pixel;
|
2013-04-16 18:02:12 -04:00
|
|
|
Coord _height;
|
|
|
|
bool _show_zero;
|
|
|
|
Color _zero_color;
|
|
|
|
Color _clip_color;
|
|
|
|
bool _logscaled;
|
|
|
|
Shape _shape;
|
2013-04-16 21:23:50 -04:00
|
|
|
double _gradient_depth;
|
2013-04-16 18:02:12 -04:00
|
|
|
bool _shape_independent;
|
|
|
|
bool _logscaled_independent;
|
2013-04-16 21:23:50 -04:00
|
|
|
bool _gradient_depth_independent;
|
2013-04-17 15:22:09 -04:00
|
|
|
double _amplitude_above_axis;
|
2013-04-16 10:07:52 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
/** The `start' value to use for the region; we can't use the region's
|
|
|
|
* value as the crossfade editor needs to alter it.
|
|
|
|
*/
|
|
|
|
ARDOUR::frameoffset_t _region_start;
|
2013-06-20 14:37:31 -04:00
|
|
|
|
2013-06-27 17:23:34 -04:00
|
|
|
|
|
|
|
mutable ARDOUR::framepos_t _sample_start;
|
|
|
|
mutable ARDOUR::framepos_t _sample_end;
|
|
|
|
mutable Cairo::RefPtr<Cairo::ImageSurface> _image;
|
|
|
|
|
2013-04-16 14:04:59 -04:00
|
|
|
PBD::ScopedConnection invalidation_connection;
|
|
|
|
|
2013-04-16 21:23:50 -04:00
|
|
|
static double _global_gradient_depth;
|
|
|
|
static bool _global_logscaled;
|
|
|
|
static Shape _global_shape;
|
2013-06-28 20:21:30 -04:00
|
|
|
static bool _global_show_waveform_clipping;
|
2013-12-30 15:46:44 -05:00
|
|
|
static double _clip_level;
|
2013-04-16 18:02:12 -04:00
|
|
|
|
|
|
|
static PBD::Signal0<void> VisualPropertiesChanged;
|
|
|
|
|
|
|
|
void handle_visual_property_change ();
|
2013-06-27 17:23:34 -04:00
|
|
|
|
|
|
|
void ensure_cache (ARDOUR::framepos_t sample_start, ARDOUR::framepos_t sample_end) const;
|
|
|
|
ArdourCanvas::Coord position (double) const;
|
|
|
|
void draw_image (ARDOUR::PeakData*, int npeaks) const;
|
2013-04-04 00:32:52 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|