#include <libgnomecanvasmm/line.h>
+#include "pbd/memento_command.h"
#include "ardour/automation_list.h"
#include "evoral/Curve.hpp"
#include "ardour/crossfade.h"
}
CrossfadeEditor::CrossfadeEditor (Session* s, boost::shared_ptr<Crossfade> xf, double my, double mxy)
- : ArdourDialog (_("ardour: x-fade edit")),
+ : ArdourDialog (_("Edit Crossfade")),
xfade (xf),
clear_button (_("Clear")),
revert_button (_("Reset")),
fade_out_table (3, 3),
select_in_button (_("Fade In")),
- select_out_button (_("Fade Out"))
+ select_out_button (_("Fade Out")),
+
+ _peaks_ready_connection (0)
+
{
set_session (s);
- set_wmclass (X_("ardour_automationedit"), "Ardour");
+ set_wmclass (X_("ardour_automationedit"), PROGRAM_NAME);
set_name ("CrossfadeEditWindow");
set_position (Gtk::WIN_POS_MOUSE);
curve_select_clicked (In);
- xfade->StateChanged.connect (state_connection, boost::bind (&CrossfadeEditor::xfade_changed, this, _1));
+ xfade->PropertyChanged.connect (state_connection, invalidator (*this), ui_bind (&CrossfadeEditor::xfade_changed, this, _1), gui_context());
- _session->AuditionActive.connect (_session_connections, sigc::mem_fun(*this, &CrossfadeEditor::audition_state_changed));
+ _session->AuditionActive.connect (_session_connections, invalidator (*this), ui_bind (&CrossfadeEditor::audition_state_changed, this, _1), gui_context());
show_all_children();
}
for (list<Point*>::iterator i = fade[Out].points.begin(); i != fade[Out].points.end(); ++i) {
delete *i;
}
+
+ delete _peaks_ready_connection;
}
void
if (point_grabbed) {
double new_x, new_y;
- /* can't drag first or last points horizontally */
+ /* can't drag first or last points horizontally or vertically */
if (point == fade[current].points.front() || point == fade[current].points.back()) {
new_x = point->x;
+ new_y = point->y;
} else {
new_x = (event->motion.x - canvas_border)/effective_width();
+ new_y = 1.0 - ((event->motion.y - canvas_border)/effective_height());
}
- new_y = 1.0 - ((event->motion.y - canvas_border)/effective_height());
point->move_to (x_coordinate (new_x), y_coordinate (new_y),
new_x, new_y);
redraw ();
void
CrossfadeEditor::Point::move_to (double nx, double ny, double xfract, double yfract)
{
+ if ( xfract < 0.0 ) {
+ xfract = 0.0;
+ } else if ( xfract > 1.0 ) {
+ xfract = 1.0;
+ }
+
+ if ( yfract < 0.0 ) {
+ yfract = 0.0;
+ } else if ( yfract > 1.0 ) {
+ yfract = 1.0;
+ }
+
const double half_size = rint(size/2.0);
double x1 = nx - half_size;
double x2 = nx + half_size;
void
-CrossfadeEditor::xfade_changed (Change)
+CrossfadeEditor::xfade_changed (const PropertyChange&)
{
set (xfade->fade_in(), In);
set (xfade->fade_out(), Out);
void
CrossfadeEditor::apply ()
{
+ _session->begin_reversible_command (_("Edit crossfade"));
+
+ XMLNode& before = xfade->get_state ();
+
_apply_to (xfade);
+
+ _session->add_command (new MementoCommand<Crossfade> (*xfade.get(), &before, &xfade->get_state ()));
+ _session->commit_reversible_command ();
}
void
ht = canvas->get_allocation().get_height() / (double) nchans;
spu = xfade->length() / (double) effective_width();
+ delete _peaks_ready_connection;
+ _peaks_ready_connection = 0;
+
for (uint32_t n = 0; n < nchans; ++n) {
gdouble yoff = n * ht;
- if (region->audio_source(n)->peaks_ready (boost::bind (&CrossfadeEditor::peaks_ready, this, boost::weak_ptr<AudioRegion>(region), which), peaks_ready_connection)) {
+ if (region->audio_source(n)->peaks_ready (boost::bind (&CrossfadeEditor::peaks_ready, this, boost::weak_ptr<AudioRegion>(region), which), &_peaks_ready_connection, gui_context())) {
WaveView* waveview = new WaveView (*(canvas->root()));
waveview->property_data_src() = region.get();
will be ready by the time we want them. but our API forces us
to provide this, so ..
*/
- peaks_ready_connection.disconnect ();
+ delete _peaks_ready_connection;
+ _peaks_ready_connection = 0;
+
make_waves (r, which);
}
right_length = xfade->in()->length();
}
- boost::shared_ptr<AudioRegion> left (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (xfade->out(), left_start_offset, left_length, "xfade out",
- 0, Region::DefaultFlags, false)));
- boost::shared_ptr<AudioRegion> right (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (xfade->in(), 0, right_length, "xfade in",
- 0, Region::DefaultFlags, false)));
-
- //apply a 20ms declicking fade at the start and end of auditioning
- left->set_fade_in_active(true);
- left->set_fade_in_length(_session->frame_rate() / 50);
- right->set_fade_out_active(true);
- right->set_fade_out_length(_session->frame_rate() / 50);
-
- pl.add_region (left, 0);
- pl.add_region (right, 1 + preroll);
+ PropertyList left_plist;
+ PropertyList right_plist;
+
+
+ left_plist.add (ARDOUR::Properties::start, left_start_offset);
+ left_plist.add (ARDOUR::Properties::length, left_length);
+ left_plist.add (ARDOUR::Properties::name, string ("xfade out"));
+ left_plist.add (ARDOUR::Properties::layer, 0);
+ left_plist.add (ARDOUR::Properties::fade_in_active, true);
+
+ right_plist.add (ARDOUR::Properties::start, 0);
+ right_plist.add (ARDOUR::Properties::length, right_length);
+ right_plist.add (ARDOUR::Properties::name, string("xfade in"));
+ right_plist.add (ARDOUR::Properties::layer, 0);
+ right_plist.add (ARDOUR::Properties::fade_out_active, true);
if (which == Left) {
- right->set_scale_amplitude (0.0);
+ right_plist.add (ARDOUR::Properties::scale_amplitude, 0.0f);
} else if (which == Right) {
- left->set_scale_amplitude (0.0);
+ left_plist.add (ARDOUR::Properties::scale_amplitude, 0.0f);
}
+ boost::shared_ptr<AudioRegion> left (boost::dynamic_pointer_cast<AudioRegion>
+ (RegionFactory::create (xfade->out(), left_plist, false)));
+ boost::shared_ptr<AudioRegion> right (boost::dynamic_pointer_cast<AudioRegion>
+ (RegionFactory::create (xfade->in(), right_plist, false)));
+
+ // apply a 20ms declicking fade at the start and end of auditioning
+ // XXX this should really be a property
+
+ left->set_fade_in_length (_session->frame_rate() / 50);
+ right->set_fade_out_length (_session->frame_rate() / 50);
+
+ pl.add_region (left, 0);
+ pl.add_region (right, 1 + preroll);
+
/* there is only one ... */
pl.foreach_crossfade (sigc::mem_fun (*this, &CrossfadeEditor::setup));
void
CrossfadeEditor::audition_left_dry ()
{
- boost::shared_ptr<AudioRegion> left (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (xfade->out(), xfade->out()->length() - xfade->length(), xfade->length(), "xfade left",
- 0, Region::DefaultFlags, false)));
+ PropertyList plist;
+
+ plist.add (ARDOUR::Properties::start, xfade->out()->length() - xfade->length());
+ plist.add (ARDOUR::Properties::length, xfade->length());
+ plist.add (ARDOUR::Properties::name, string("xfade left"));
+ plist.add (ARDOUR::Properties::layer, 0);
+
+ boost::shared_ptr<AudioRegion> left (boost::dynamic_pointer_cast<AudioRegion>
+ (RegionFactory::create (xfade->out(), plist, false)));
_session->audition_region (left);
}
void
CrossfadeEditor::audition_right_dry ()
{
- boost::shared_ptr<AudioRegion> right (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (xfade->in(), 0, xfade->length(), "xfade in",
- 0, Region::DefaultFlags, false)));
+ PropertyList plist;
+
+ plist.add (ARDOUR::Properties::start, 0);
+ plist.add (ARDOUR::Properties::length, xfade->length());
+ plist.add (ARDOUR::Properties::name, string ("xfade right"));
+ plist.add (ARDOUR::Properties::layer, 0);
+
+ boost::shared_ptr<AudioRegion> right (boost::dynamic_pointer_cast<AudioRegion>
+ (RegionFactory::create (xfade->in(), plist, false)));
+
_session->audition_region (right);
}