summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2012-05-01 03:22:04 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2012-05-01 03:22:04 +0000
commita47ec8ba590d1fe663a64a50b02b1f6b61fd5743 (patch)
tree50889cd8a5b0c6c9e09ddea7b932cf6d761a9b09 /gtk2_ardour
parent01659c1d73ea30de8d0eb455b0182122798b578b (diff)
mostly backup-oriented commit to preserve very initial pass at rendering fades-as-xfades in a more useful way. quite a bit of work to do here
git-svn-id: svn://localhost/ardour2/branches/3.0@12129 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/audio_region_view.cc196
-rw-r--r--gtk2_ardour/audio_region_view.h11
2 files changed, 207 insertions, 0 deletions
diff --git a/gtk2_ardour/audio_region_view.cc b/gtk2_ardour/audio_region_view.cc
index 70966b1dff..885af4cd38 100644
--- a/gtk2_ardour/audio_region_view.cc
+++ b/gtk2_ardour/audio_region_view.cc
@@ -20,6 +20,8 @@
#include <cassert>
#include <algorithm>
+#include <boost/scoped_ptr.hpp>
+
#include <gtkmm.h>
#include <gtkmm2ext/gtk_ui.h>
@@ -73,6 +75,12 @@ AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView
, fade_in_handle(0)
, fade_out_handle(0)
, fade_position_line(0)
+ , start_xfade_in (0)
+ , start_xfade_out (0)
+ , start_xfade_rect (0)
+ , end_xfade_in (0)
+ , end_xfade_out (0)
+ , end_xfade_rect (0)
, _amplitude_above_axis(1.0)
, _flags(0)
, fade_color(0)
@@ -89,6 +97,12 @@ AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView
, fade_in_handle(0)
, fade_out_handle(0)
, fade_position_line(0)
+ , start_xfade_in (0)
+ , start_xfade_out (0)
+ , start_xfade_rect (0)
+ , end_xfade_in (0)
+ , end_xfade_out (0)
+ , end_xfade_rect (0)
, _amplitude_above_axis(1.0)
, _flags(0)
, fade_color(0)
@@ -102,6 +116,12 @@ AudioRegionView::AudioRegionView (const AudioRegionView& other, boost::shared_pt
, fade_in_handle(0)
, fade_out_handle(0)
, fade_position_line(0)
+ , start_xfade_in (0)
+ , start_xfade_out (0)
+ , start_xfade_rect (0)
+ , end_xfade_in (0)
+ , end_xfade_out (0)
+ , end_xfade_rect (0)
, _amplitude_above_axis (other._amplitude_above_axis)
, _flags (other._flags)
, fade_color(0)
@@ -534,10 +554,24 @@ AudioRegionView::reset_fade_in_shape ()
void
AudioRegionView::reset_fade_in_shape_width (framecnt_t width)
{
+ if (audio_region()->fade_in_is_xfade()) {
+ fade_in_handle->hide ();
+ fade_in_shape->hide ();
+ redraw_start_xfade ();
+ return;
+ } else {
+ if (start_xfade_in) {
+ start_xfade_in->hide ();
+ start_xfade_out->hide ();
+ }
+ }
+
if (fade_in_handle == 0) {
return;
}
+ fade_in_handle->show ();
+
/* smallest size for a fade is 64 frames */
width = std::max ((framecnt_t) 64, width);
@@ -621,10 +655,24 @@ AudioRegionView::reset_fade_out_shape ()
void
AudioRegionView::reset_fade_out_shape_width (framecnt_t width)
{
+ if (audio_region()->fade_out_is_xfade()) {
+ fade_out_handle->hide ();
+ fade_out_shape->hide ();
+ redraw_end_xfade ();
+ return;
+ } else {
+ if (end_xfade_in) {
+ end_xfade_in->hide ();
+ end_xfade_out->hide ();
+ }
+ }
+
if (fade_out_handle == 0) {
return;
}
+ fade_out_handle->show ();
+
/* smallest size for a fade is 64 frames */
width = std::max ((framecnt_t) 64, width);
@@ -1465,3 +1513,151 @@ AudioRegionView::thaw_after_trim ()
unhide_envelope ();
}
+
+void
+AudioRegionView::redraw_start_xfade ()
+{
+ boost::shared_ptr<AudioRegion> ar (audio_region());
+
+ if (!ar->fade_in() || ar->fade_in()->empty()) {
+ return;
+ }
+
+ int32_t const npoints = trackview.editor().frame_to_pixel (ar->fade_in()->back()->when);
+
+ if (npoints < 3) {
+ return;
+ }
+
+ if (!start_xfade_in) {
+ start_xfade_in = new ArdourCanvas::Line (*group);
+ start_xfade_in->property_width_pixels() = 1;
+ start_xfade_in->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GainLine.get();
+ }
+
+ if (!start_xfade_out) {
+ start_xfade_out = new ArdourCanvas::Line (*group);
+ start_xfade_out->property_width_pixels() = 1;
+ start_xfade_out->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GainLine.get();
+ }
+
+ Points* points = get_canvas_points ("xfade edit redraw", npoints);
+ boost::scoped_ptr<float> vec (new float[npoints]);
+
+ ar->fade_in()->curve().get_vector (0, ar->fade_in()->back()->when, vec.get(), npoints);
+
+ for (int i = 0, pci = 0; i < npoints; ++i) {
+ Gnome::Art::Point &p ((*points)[pci++]);
+ p.set_x (i);
+ p.set_y (_height - (_height * vec.get()[i]));
+ }
+
+ start_xfade_in->property_points() = *points;
+ start_xfade_in->show ();
+ start_xfade_in->raise_to_top ();
+
+ /* fade out line */
+
+ boost::shared_ptr<AutomationList> inverse = ar->inverse_fade_in();
+
+ if (!inverse) {
+
+ for (int i = 0, pci = 0; i < npoints; ++i) {
+ Gnome::Art::Point &p ((*points)[pci++]);
+ p.set_x (i);
+ p.set_y (_height - (_height * (1.0 - vec.get()[i])));
+ }
+
+ } else {
+
+ inverse->curve().get_vector (0, inverse->back()->when, vec.get(), npoints);
+
+ for (int i = 0, pci = 0; i < npoints; ++i) {
+ Gnome::Art::Point &p ((*points)[pci++]);
+ p.set_x (i);
+ p.set_y (_height - (_height * vec.get()[i]));
+ }
+ }
+
+ start_xfade_out->property_points() = *points;
+ start_xfade_out->show ();
+ start_xfade_out->raise_to_top ();
+
+ delete points;
+}
+
+void
+AudioRegionView::redraw_end_xfade ()
+{
+ boost::shared_ptr<AudioRegion> ar (audio_region());
+
+ if (!ar->fade_out() || ar->fade_out()->empty()) {
+ return;
+ }
+
+ int32_t const npoints = trackview.editor().frame_to_pixel (ar->fade_out()->back()->when);
+
+ if (npoints < 3) {
+ return;
+ }
+
+ if (!end_xfade_in) {
+ end_xfade_in = new ArdourCanvas::Line (*group);
+ end_xfade_in->property_width_pixels() = 1;
+ end_xfade_in->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GainLine.get();
+ }
+
+ if (!end_xfade_out) {
+ end_xfade_out = new ArdourCanvas::Line (*group);
+ end_xfade_out->property_width_pixels() = 1;
+ end_xfade_out->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GainLine.get();
+ }
+
+ Points* points = get_canvas_points ("xfade edit redraw", npoints);
+ boost::scoped_ptr<float> vec (new float[npoints]);
+
+ ar->fade_out()->curve().get_vector (0, ar->fade_out()->back()->when, vec.get(), npoints);
+
+ double rend = trackview.editor().frame_to_pixel (_region->length() - ar->fade_out()->back()->when);
+
+ for (int i = 0, pci = 0; i < npoints; ++i) {
+ Gnome::Art::Point &p ((*points)[pci++]);
+ p.set_x (rend + i);
+ p.set_y (_height - (_height * vec.get()[i]));
+ }
+
+ end_xfade_in->property_points() = *points;
+ end_xfade_in->show ();
+ end_xfade_in->raise_to_top ();
+
+ /* fade in line */
+
+ boost::shared_ptr<AutomationList> inverse = ar->inverse_fade_out ();
+
+ if (!inverse) {
+
+ for (int i = 0, pci = 0; i < npoints; ++i) {
+ Gnome::Art::Point &p ((*points)[pci++]);
+ p.set_x (rend + i);
+ p.set_y (_height - (_height * (1.0 - vec.get()[i])));
+ }
+
+ } else {
+
+ rend = trackview.editor().frame_to_pixel (_region->length() - inverse->back()->when);
+ inverse->curve().get_vector (inverse->front()->when, inverse->back()->when, vec.get(), npoints);
+
+ for (int i = 0, pci = 0; i < npoints; ++i) {
+ Gnome::Art::Point &p ((*points)[pci++]);
+ p.set_x (rend + i);
+ p.set_y (_height - (_height * vec.get()[i]));
+ }
+ }
+
+ end_xfade_out->property_points() = *points;
+ end_xfade_out->show ();
+ end_xfade_out->raise_to_top ();
+
+
+ delete points;
+}
diff --git a/gtk2_ardour/audio_region_view.h b/gtk2_ardour/audio_region_view.h
index 9dc7e507a1..53070c85d3 100644
--- a/gtk2_ardour/audio_region_view.h
+++ b/gtk2_ardour/audio_region_view.h
@@ -142,6 +142,14 @@ class AudioRegionView : public RegionView
ArdourCanvas::SimpleRect* fade_out_handle; ///< fade out handle, or 0
ArdourCanvas::SimpleLine* fade_position_line;
+ ArdourCanvas::Line *start_xfade_in;
+ ArdourCanvas::Line *start_xfade_out;
+ ArdourCanvas::SimpleRect* start_xfade_rect;
+
+ ArdourCanvas::Line *end_xfade_in;
+ ArdourCanvas::Line *end_xfade_out;
+ ArdourCanvas::SimpleRect* end_xfade_rect;
+
boost::shared_ptr<AudioRegionGainLine> gain_line;
double _amplitude_above_axis;
@@ -179,6 +187,9 @@ class AudioRegionView : public RegionView
void transients_changed();
+ void redraw_start_xfade ();
+ void redraw_end_xfade ();
+
private:
void setup_fade_handle_positions ();