#include <boost/shared_ptr.hpp>
#include <boost/shared_array.hpp>
+#include <boost/scoped_array.hpp>
#include "pbd/properties.h"
Rectified,
};
+ /* 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).
+ */
+
+
WaveView (Group *, boost::shared_ptr<ARDOUR::AudioRegion>);
+ ~WaveView ();
void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
void compute_bounding_box () const;
double gradient_depth() const { return _gradient_depth; }
void set_shape (Shape);
-
/* currently missing because we don't need them (yet):
set_shape_independent();
set_logscaled_independent()
static void set_global_gradient_depth (double);
static void set_global_logscaled (bool);
static void set_global_shape (Shape);
+ static void set_global_show_waveform_clipping (bool);
static double global_gradient_depth() { return _global_gradient_depth; }
static bool global_logscaled() { return _global_logscaled; }
#endif
- /** A cached, pre-rendered image of some section of a waveform.
-
- It spans a range given relative to the start of the source
- of the waveform data, so a range from N..M corresponds
- to the sample range N..M within the source.
-
- Invalidated by a changes to:
-
- samples_per_pixel
- colors
- height
-
- */
+ friend class ::WaveViewTest;
- class CacheEntry
- {
- public:
- CacheEntry (WaveView const *, double, double, int);
- ~CacheEntry ();
-
- double start () const {
- return _start;
- }
-
- double end () const {
- return _end;
- }
-
- boost::shared_array<ARDOUR::PeakData> peaks () const {
- return _peaks;
- }
-
- Cairo::RefPtr<Cairo::ImageSurface> image();
- void clear_image ();
-
- private:
- Coord position (Coord) const;
-
- WaveView const * _wave_view;
-
- double _start;
- double _end;
- int _n_peaks;
-
- boost::shared_array<ARDOUR::PeakData> _peaks;
- Cairo::RefPtr<Cairo::ImageSurface> _image;
- };
-
- friend class CacheEntry;
- friend class ::WaveViewTest;
-
- void invalidate_whole_cache ();
- void invalidate_image_cache ();
+ void invalidate_image ();
boost::shared_ptr<ARDOUR::AudioRegion> _region;
int _channel;
* value as the crossfade editor needs to alter it.
*/
ARDOUR::frameoffset_t _region_start;
+
+
+ mutable ARDOUR::framepos_t _sample_start;
+ mutable ARDOUR::framepos_t _sample_end;
+ mutable Cairo::RefPtr<Cairo::ImageSurface> _image;
- mutable std::list<CacheEntry*> _cache;
-
PBD::ScopedConnection invalidation_connection;
static double _global_gradient_depth;
static bool _global_logscaled;
static Shape _global_shape;
+ static bool _global_show_waveform_clipping;
static PBD::Signal0<void> VisualPropertiesChanged;
void handle_visual_property_change ();
+
+ 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;
};
}