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
This commit is contained in:
Paul Davis 2012-05-01 03:22:04 +00:00
parent 01659c1d73
commit a47ec8ba59
5 changed files with 222 additions and 11 deletions

View File

@ -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;
}

View File

@ -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 ();

View File

@ -95,7 +95,9 @@ class AudioRegion : public Region
void set_fade_out_is_xfade (bool yn);
boost::shared_ptr<AutomationList> fade_in() { return _fade_in; }
boost::shared_ptr<AutomationList> inverse_fade_in() { return _inverse_fade_in; }
boost::shared_ptr<AutomationList> fade_out() { return _fade_out; }
boost::shared_ptr<AutomationList> inverse_fade_out() { return _inverse_fade_out; }
boost::shared_ptr<AutomationList> envelope() { return _envelope; }
Evoral::Range<framepos_t> body_range () const;

View File

@ -329,6 +329,9 @@ AudioPlaylist::check_crossfades (Evoral::Range<framepos_t> range)
break;
}
top->set_fade_in_active (true);
top->set_fade_in_is_xfade (true);
switch (_session.config.get_xfade_choice ()) {
case ConstantPowerMinus3dB:
top->set_fade_in (FadeConstantPowerMinus3dB, len);
@ -340,8 +343,6 @@ AudioPlaylist::check_crossfades (Evoral::Range<framepos_t> range)
top->set_fade_in_length (len);
break;
}
top->set_fade_in_active (true);
top->set_fade_in_is_xfade (true);
done_start.insert (top);
}
@ -367,6 +368,9 @@ AudioPlaylist::check_crossfades (Evoral::Range<framepos_t> range)
break;
}
top->set_fade_out_active (true);
top->set_fade_out_is_xfade (true);
switch (_session.config.get_xfade_choice ()) {
case ConstantPowerMinus3dB:
top->set_fade_out (FadeConstantPowerMinus3dB, len);
@ -378,8 +382,6 @@ AudioPlaylist::check_crossfades (Evoral::Range<framepos_t> range)
top->set_fade_out_length (len);
break;
}
top->set_fade_out_active (true);
top->set_fade_out_is_xfade (true);
done_end.insert (top);
}

View File

@ -1042,16 +1042,16 @@ AudioRegion::set_fade_out (FadeShape shape, framecnt_t len)
/* setup complementary fade in for lower layers */
if (!_inverse_fade_out) {
_inverse_fade_out.reset (new AutomationList (Evoral::Parameter (FadeInAutomation)));
_inverse_fade_out.reset (new AutomationList (Evoral::Parameter (FadeOutAutomation)));
}
_inverse_fade_out->clear ();
_inverse_fade_out->fast_simple_add (0.0, 0.0);
_inverse_fade_out->fast_simple_add ((len * 0.166667), 0.166366);
_inverse_fade_out->fast_simple_add ((len * 0.333333), 0.332853);
_inverse_fade_out->fast_simple_add ((len * 0.500000), 0.499459);
_inverse_fade_out->fast_simple_add ((len * 0.666667), 0.666186);
_inverse_fade_out->fast_simple_add ((len * 0.833333), 0.833033);
_inverse_fade_out->fast_simple_add ((len * 0.166667), 0.282192);
_inverse_fade_out->fast_simple_add ((len * 0.333333), 0.518174);
_inverse_fade_out->fast_simple_add ((len * 0.500000), 0.707946);
_inverse_fade_out->fast_simple_add ((len * 0.666667), 0.851507);
_inverse_fade_out->fast_simple_add ((len * 0.833333), 0.948859);
_inverse_fade_out->fast_simple_add (len, 1.0);
break;
@ -1068,7 +1068,7 @@ AudioRegion::set_fade_out (FadeShape shape, framecnt_t len)
/* setup complementary fade in for lower layers */
if (!_inverse_fade_out) {
_inverse_fade_out.reset (new AutomationList (Evoral::Parameter (FadeInAutomation)));
_inverse_fade_out.reset (new AutomationList (Evoral::Parameter (FadeOutAutomation)));
}
_inverse_fade_out->clear ();