2005-09-25 14:42:24 -04:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 2004 Paul Davis
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
#include <sigc++/bind.h>
|
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
#include <gtkmm/frame.h>
|
2005-10-09 01:03:29 -04:00
|
|
|
#include <gtkmm/image.h>
|
2005-09-25 16:33:00 -04:00
|
|
|
#include <gtkmm/scrolledwindow.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
#include <libgnomecanvasmm/line.h>
|
|
|
|
|
2010-06-27 22:40:09 -04:00
|
|
|
#include "pbd/memento_command.h"
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/automation_list.h"
|
|
|
|
#include "evoral/Curve.hpp"
|
|
|
|
#include "ardour/crossfade.h"
|
|
|
|
#include "ardour/session.h"
|
|
|
|
#include "ardour/auditioner.h"
|
|
|
|
#include "ardour/audioplaylist.h"
|
|
|
|
#include "ardour/audiosource.h"
|
|
|
|
#include "ardour/region_factory.h"
|
|
|
|
#include "ardour/profile.h"
|
2011-09-21 11:54:19 -04:00
|
|
|
#include "ardour/crossfade_binder.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
#include <gtkmm2ext/gtk_ui.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include "ardour_ui.h"
|
|
|
|
#include "crossfade_edit.h"
|
|
|
|
#include "rgb_macros.h"
|
|
|
|
#include "keyboard.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "gui_thread.h"
|
2005-11-14 22:12:16 -05:00
|
|
|
#include "canvas_impl.h"
|
|
|
|
#include "simplerect.h"
|
|
|
|
#include "waveview.h"
|
2008-12-12 09:43:24 -05:00
|
|
|
#include "actions.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace ARDOUR;
|
Large nasty commit in the form of a 5000 line patch chock-full of completely
unecessary changes. (Sorry, doing a "sprint" based thing, this is the end of the first one)
Achieved MIDI track and bus creation, associated Jack port and diskstream creation, and minimal GUI stuff for creating them. Should be set to start work on actually recording and playing midi to/from disk now.
Relevant (significant) changes:
- Creation of a Buffer class. Base class is type agnostic so things can point to a buffer but not care what kind it is (otherwise it'd be a template). Derived into AudioBuffer and MidiBuffer, with a type tag because checking type is necessary in parts of the code where dynamic_cast wouldn't be wise. Originally I considered this a hack, but passing around a type proved to be a very good solution to all the other problems (below). There is a 1:1 mapping between jack port data types and ardour Buffer types (with a conversion function), but that's easily removed if it ever becomes necessary. Having the type scoped in the Buffer class is maybe not the best spot for it, but whatever (this is proof of concept kinda stuff right now...)
- IO now has a "default" port type (passed to the constructor and stored as a member), used by ensure_io (and similar) to create n ports. IO::register_***_port has a type argument that defaults to the default type if not passed. Rationale: previous IO API is identical, no changes needed to existing code, but path is paved for multiple port types in one IO, which we will need for eg synth plugin inserts, among other things. This is not quite ideal (best would be to only have the two port register functions and have them take a type), but the alternative is a lot of work (namely destroying the 'ensure' functions and everything that uses them) for very little gain. (I am convinced after quite a few tries at the whiteboard that subclassing IO in any way is not a feasible option, look at it's inheritance diagram in Doxygen and you can see why)
- AudioEngine::register_audio_input_port is now register_input_port and takes a type argument. Ditto for output.
- (Most significant change) AudioDiskstream abstracted into Distream, and sibling MidiDiskstream created. Very much still a work in progress, but Diskstream is there to switch references over to (most already are), which is the important part. It is still unclear what the MIDI diskstream's relation to channels is, but I'm pretty sure they will be single channel only (so SMF Type 0) since noone can come up with a reason otherwise.
- MidiTrack creation. Same thing as AudioTrack but with a different default type basically. No big deal here.
- Random cleanups and variable renamings etc. because I have OCD and can't help myself. :)
Known broken: Loading of sessions containing MIDI tracks.
git-svn-id: svn://localhost/ardour2/branches/midi@641 d708f5d6-7413-0410-9779-e7cbd77b26cf
2006-06-26 12:01:34 -04:00
|
|
|
using namespace PBD;
|
2005-09-25 14:42:24 -04:00
|
|
|
using namespace Gtk;
|
|
|
|
using namespace Editing;
|
|
|
|
|
2009-12-04 17:51:32 -05:00
|
|
|
using Gtkmm2ext::Keyboard;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
const int32_t CrossfadeEditor::Point::size = 7;
|
|
|
|
const double CrossfadeEditor::canvas_border = 10;
|
|
|
|
CrossfadeEditor::Presets* CrossfadeEditor::fade_in_presets = 0;
|
|
|
|
CrossfadeEditor::Presets* CrossfadeEditor::fade_out_presets = 0;
|
|
|
|
|
|
|
|
CrossfadeEditor::Half::Half ()
|
2009-02-19 14:42:25 -05:00
|
|
|
: line (0)
|
|
|
|
, normative_curve (Evoral::Parameter(GainAutomation))
|
|
|
|
, gain_curve (Evoral::Parameter(GainAutomation))
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
CrossfadeEditor::CrossfadeEditor (Session* s, boost::shared_ptr<Crossfade> xf, double my, double mxy)
|
2010-04-29 20:16:45 -04:00
|
|
|
: ArdourDialog (_("Edit Crossfade")),
|
2005-09-25 14:42:24 -04:00
|
|
|
xfade (xf),
|
|
|
|
clear_button (_("Clear")),
|
|
|
|
revert_button (_("Reset")),
|
|
|
|
audition_both_button (_("Fade")),
|
|
|
|
audition_left_dry_button (_("Out (dry)")),
|
|
|
|
audition_left_button (_("Out")),
|
|
|
|
audition_right_dry_button (_("In (dry)")),
|
|
|
|
audition_right_button (_("In")),
|
|
|
|
|
|
|
|
preroll_button (_("With Pre-roll")),
|
|
|
|
postroll_button (_("With Post-roll")),
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
miny (my),
|
|
|
|
maxy (mxy),
|
|
|
|
|
|
|
|
fade_in_table (3, 3),
|
|
|
|
fade_out_table (3, 3),
|
|
|
|
|
|
|
|
select_in_button (_("Fade In")),
|
2010-04-21 21:40:33 -04:00
|
|
|
select_out_button (_("Fade Out")),
|
|
|
|
|
|
|
|
_peaks_ready_connection (0)
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
set_session (s);
|
|
|
|
|
2010-08-16 20:28:20 -04:00
|
|
|
set_wmclass (X_("ardour_automationedit"), PROGRAM_NAME);
|
2005-09-25 14:42:24 -04:00
|
|
|
set_name ("CrossfadeEditWindow");
|
2005-09-25 16:33:00 -04:00
|
|
|
set_position (Gtk::WIN_POS_MOUSE);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2008-12-12 09:43:24 -05:00
|
|
|
add_accel_group (ActionManager::ui_manager->get_accel_group());
|
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-10-09 01:03:29 -04:00
|
|
|
RadioButtonGroup sel_but_group = select_in_button.get_group();
|
|
|
|
select_out_button.set_group (sel_but_group);
|
2005-09-25 14:42:24 -04:00
|
|
|
select_out_button.set_mode (false);
|
|
|
|
select_in_button.set_mode (false);
|
|
|
|
|
2006-01-03 11:59:11 -05:00
|
|
|
get_action_area()->set_layout(BUTTONBOX_SPREAD);
|
|
|
|
get_action_area()->pack_start(clear_button);
|
|
|
|
get_action_area()->pack_start(revert_button);
|
|
|
|
cancel_button = add_button ("Cancel", RESPONSE_CANCEL);
|
|
|
|
ok_button = add_button ("OK", RESPONSE_ACCEPT);
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (fade_in_presets == 0) {
|
|
|
|
build_presets ();
|
|
|
|
}
|
|
|
|
|
|
|
|
point_grabbed = false;
|
|
|
|
toplevel = 0;
|
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
canvas = new ArdourCanvas::CanvasAA ();
|
2009-12-11 18:29:48 -05:00
|
|
|
canvas->signal_size_allocate().connect (sigc::mem_fun(*this, &CrossfadeEditor::canvas_allocation));
|
2005-09-25 16:33:00 -04:00
|
|
|
canvas->set_size_request (425, 200);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
toplevel = new ArdourCanvas::SimpleRect (*(canvas->root()));
|
|
|
|
toplevel->property_x1() = 0.0;
|
|
|
|
toplevel->property_y1() = 0.0;
|
|
|
|
toplevel->property_x2() = 10.0;
|
|
|
|
toplevel->property_y2() = 10.0;
|
|
|
|
toplevel->property_fill() = true;
|
2007-06-29 13:13:09 -04:00
|
|
|
toplevel->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_CrossfadeEditorBase.get();
|
2005-11-14 22:12:16 -05:00
|
|
|
toplevel->property_outline_pixels() = 0;
|
2009-12-11 18:29:48 -05:00
|
|
|
toplevel->signal_event().connect (sigc::mem_fun (*this, &CrossfadeEditor::canvas_event));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
fade[Out].line = new ArdourCanvas::Line (*(canvas->root()));
|
|
|
|
fade[Out].line->property_width_pixels() = 1;
|
2007-06-29 13:13:09 -04:00
|
|
|
fade[Out].line->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_CrossfadeEditorLine.get();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
fade[Out].shading = new ArdourCanvas::Polygon (*(canvas->root()));
|
2007-06-29 13:13:09 -04:00
|
|
|
fade[Out].shading->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_CrossfadeEditorLineShading.get();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
fade[In].line = new ArdourCanvas::Line (*(canvas->root()));
|
|
|
|
fade[In].line->property_width_pixels() = 1;
|
2007-06-29 13:13:09 -04:00
|
|
|
fade[In].line->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_CrossfadeEditorLine.get();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
fade[In].shading = new ArdourCanvas::Polygon (*(canvas->root()));
|
2007-06-29 13:13:09 -04:00
|
|
|
fade[In].shading->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_CrossfadeEditorLineShading.get();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-12-11 18:29:48 -05:00
|
|
|
fade[In].shading->signal_event().connect (sigc::mem_fun (*this, &CrossfadeEditor::canvas_event));
|
|
|
|
fade[In].line->signal_event().connect (sigc::mem_fun (*this, &CrossfadeEditor::curve_event));
|
|
|
|
fade[Out].shading->signal_event().connect (sigc::mem_fun (*this, &CrossfadeEditor::canvas_event));
|
|
|
|
fade[Out].line->signal_event().connect (sigc::mem_fun (*this, &CrossfadeEditor::curve_event));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
select_in_button.set_name (X_("CrossfadeEditCurveButton"));
|
|
|
|
select_out_button.set_name (X_("CrossfadeEditCurveButton"));
|
|
|
|
|
2009-12-11 18:29:48 -05:00
|
|
|
select_in_button.signal_clicked().connect (sigc::bind (sigc::mem_fun (*this, &CrossfadeEditor::curve_select_clicked), In));
|
|
|
|
select_out_button.signal_clicked().connect (sigc::bind (sigc::mem_fun (*this, &CrossfadeEditor::curve_select_clicked), Out));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
HBox* acbox = manage (new HBox);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
audition_box.set_border_width (7);
|
|
|
|
audition_box.set_spacing (5);
|
|
|
|
audition_box.set_homogeneous (false);
|
|
|
|
audition_box.pack_start (audition_left_dry_button, false, false);
|
|
|
|
audition_box.pack_start (audition_left_button, false, false);
|
|
|
|
audition_box.pack_start (audition_both_button, false, false);
|
|
|
|
audition_box.pack_start (audition_right_button, false, false);
|
|
|
|
audition_box.pack_start (audition_right_dry_button, false, false);
|
|
|
|
|
|
|
|
Frame* audition_frame = manage (new Frame (_("Audition")));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
audition_frame->set_name (X_("CrossfadeEditFrame"));
|
|
|
|
audition_frame->add (audition_box);
|
|
|
|
|
|
|
|
acbox->pack_start (*audition_frame, true, false);
|
|
|
|
|
|
|
|
Frame* canvas_frame = manage (new Frame);
|
|
|
|
canvas_frame->add (*canvas);
|
2005-09-25 16:33:00 -04:00
|
|
|
canvas_frame->set_shadow_type (Gtk::SHADOW_IN);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
fade_in_table.attach (select_in_button, 0, 2, 0, 1, Gtk::FILL|Gtk::EXPAND);
|
|
|
|
fade_out_table.attach (select_out_button, 0, 2, 0, 1, Gtk::FILL|Gtk::EXPAND);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-10-09 01:03:29 -04:00
|
|
|
Image *pxmap;
|
2005-09-25 14:42:24 -04:00
|
|
|
Button* pbutton;
|
|
|
|
int row;
|
|
|
|
int col;
|
|
|
|
|
|
|
|
row = 1;
|
|
|
|
col = 0;
|
|
|
|
|
|
|
|
for (list<Preset*>::iterator i = fade_in_presets->begin(); i != fade_in_presets->end(); ++i) {
|
|
|
|
|
2007-03-18 02:07:08 -04:00
|
|
|
pxmap = manage (new Image (::get_icon ((*i)->image_name)));
|
2005-09-25 14:42:24 -04:00
|
|
|
pbutton = manage (new Button);
|
|
|
|
pbutton->add (*pxmap);
|
|
|
|
pbutton->set_name ("CrossfadeEditButton");
|
2009-12-11 18:29:48 -05:00
|
|
|
pbutton->signal_clicked().connect (sigc::bind (sigc::mem_fun(*this, &CrossfadeEditor::apply_preset), *i));
|
2008-12-12 09:43:24 -05:00
|
|
|
ARDOUR_UI::instance()->set_tip (pbutton, (*i)->name, "");
|
2005-09-25 14:42:24 -04:00
|
|
|
fade_in_table.attach (*pbutton, col, col+1, row, row+1);
|
|
|
|
fade_in_buttons.push_back (pbutton);
|
|
|
|
|
|
|
|
col++;
|
|
|
|
|
|
|
|
if (col == 2) {
|
|
|
|
col = 0;
|
|
|
|
row++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
row = 1;
|
|
|
|
col = 0;
|
|
|
|
|
|
|
|
for (list<Preset*>::iterator i = fade_out_presets->begin(); i != fade_out_presets->end(); ++i) {
|
|
|
|
|
2007-03-18 02:07:08 -04:00
|
|
|
pxmap = manage (new Image (::get_icon ((*i)->image_name)));
|
2005-09-25 14:42:24 -04:00
|
|
|
pbutton = manage (new Button);
|
|
|
|
pbutton->add (*pxmap);
|
|
|
|
pbutton->set_name ("CrossfadeEditButton");
|
2009-12-11 18:29:48 -05:00
|
|
|
pbutton->signal_clicked().connect (sigc::bind (sigc::mem_fun(*this, &CrossfadeEditor::apply_preset), *i));
|
2008-12-12 09:43:24 -05:00
|
|
|
ARDOUR_UI::instance()->set_tip (pbutton, (*i)->name, "");
|
2005-09-25 14:42:24 -04:00
|
|
|
fade_out_table.attach (*pbutton, col, col+1, row, row+1);
|
|
|
|
fade_out_buttons.push_back (pbutton);
|
|
|
|
|
|
|
|
col++;
|
|
|
|
|
|
|
|
if (col == 2) {
|
|
|
|
col = 0;
|
|
|
|
row++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
clear_button.set_name ("CrossfadeEditButton");
|
|
|
|
revert_button.set_name ("CrossfadeEditButton");
|
2006-01-03 11:59:11 -05:00
|
|
|
ok_button->set_name ("CrossfadeEditButton");
|
|
|
|
cancel_button->set_name ("CrossfadeEditButton");
|
2005-09-25 14:42:24 -04:00
|
|
|
preroll_button.set_name ("CrossfadeEditButton");
|
|
|
|
postroll_button.set_name ("CrossfadeEditButton");
|
|
|
|
audition_both_button.set_name ("CrossfadeEditAuditionButton");
|
|
|
|
audition_left_dry_button.set_name ("CrossfadeEditAuditionButton");
|
|
|
|
audition_left_button.set_name ("CrossfadeEditAuditionButton");
|
|
|
|
audition_right_dry_button.set_name ("CrossfadeEditAuditionButton");
|
|
|
|
audition_right_button.set_name ("CrossfadeEditAuditionButton");
|
|
|
|
|
2009-12-11 18:29:48 -05:00
|
|
|
clear_button.signal_clicked().connect (sigc::mem_fun(*this, &CrossfadeEditor::clear));
|
|
|
|
revert_button.signal_clicked().connect (sigc::mem_fun(*this, &CrossfadeEditor::reset));
|
|
|
|
audition_both_button.signal_toggled().connect (sigc::mem_fun(*this, &CrossfadeEditor::audition_toggled));
|
|
|
|
audition_right_button.signal_toggled().connect (sigc::mem_fun(*this, &CrossfadeEditor::audition_right_toggled));
|
|
|
|
audition_right_dry_button.signal_toggled().connect (sigc::mem_fun(*this, &CrossfadeEditor::audition_right_dry_toggled));
|
|
|
|
audition_left_button.signal_toggled().connect (sigc::mem_fun(*this, &CrossfadeEditor::audition_left_toggled));
|
|
|
|
audition_left_dry_button.signal_toggled().connect (sigc::mem_fun(*this, &CrossfadeEditor::audition_left_dry_toggled));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
roll_box.pack_start (preroll_button, false, false);
|
|
|
|
roll_box.pack_start (postroll_button, false, false);
|
|
|
|
|
|
|
|
Gtk::HBox* rcenter_box = manage (new HBox);
|
|
|
|
rcenter_box->pack_start (roll_box, true, false);
|
|
|
|
|
|
|
|
VBox* vpacker2 = manage (new (VBox));
|
|
|
|
|
|
|
|
vpacker2->set_border_width (12);
|
|
|
|
vpacker2->set_spacing (7);
|
|
|
|
vpacker2->pack_start (*acbox, false, false);
|
|
|
|
vpacker2->pack_start (*rcenter_box, false, false);
|
|
|
|
|
|
|
|
curve_button_box.set_spacing (7);
|
|
|
|
curve_button_box.pack_start (fade_out_table, false, false, 12);
|
|
|
|
curve_button_box.pack_start (*vpacker2, false, false, 12);
|
|
|
|
curve_button_box.pack_start (fade_in_table, false, false, 12);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-11-27 16:17:41 -05:00
|
|
|
get_vbox()->pack_start (*canvas_frame, true, true);
|
|
|
|
get_vbox()->pack_start (curve_button_box, false, false);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* button to allow hackers to check the actual curve values */
|
|
|
|
|
|
|
|
// Button* foobut = manage (new Button ("dump"));
|
2009-12-11 18:29:48 -05:00
|
|
|
// foobut-.signal_clicked().connect (sigc::mem_fun(*this, &CrossfadeEditor::dump));
|
2005-09-25 14:42:24 -04:00
|
|
|
// vpacker.pack_start (*foobut, false, false);
|
|
|
|
|
|
|
|
current = In;
|
2007-01-11 14:50:49 -05:00
|
|
|
set (xfade->fade_in(), In);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
current = Out;
|
2007-01-11 14:50:49 -05:00
|
|
|
set (xfade->fade_out(), Out);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
curve_select_clicked (In);
|
|
|
|
|
2010-03-30 11:18:43 -04:00
|
|
|
xfade->PropertyChanged.connect (state_connection, invalidator (*this), ui_bind (&CrossfadeEditor::xfade_changed, this, _1), gui_context());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2010-03-30 11:18:43 -04:00
|
|
|
_session->AuditionActive.connect (_session_connections, invalidator (*this), ui_bind (&CrossfadeEditor::audition_state_changed, this, _1), gui_context());
|
2006-01-03 11:59:11 -05:00
|
|
|
show_all_children();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
CrossfadeEditor::~CrossfadeEditor()
|
|
|
|
{
|
|
|
|
/* most objects will be destroyed when the toplevel window is. */
|
|
|
|
|
|
|
|
for (list<Point*>::iterator i = fade[In].points.begin(); i != fade[In].points.end(); ++i) {
|
|
|
|
delete *i;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (list<Point*>::iterator i = fade[Out].points.begin(); i != fade[Out].points.end(); ++i) {
|
|
|
|
delete *i;
|
|
|
|
}
|
2010-04-21 21:40:33 -04:00
|
|
|
|
|
|
|
delete _peaks_ready_connection;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::dump ()
|
|
|
|
{
|
|
|
|
for (AutomationList::iterator i = fade[Out].normative_curve.begin(); i != fade[Out].normative_curve.end(); ++i) {
|
|
|
|
cerr << (*i)->when << ' ' << (*i)->value << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::audition_state_changed (bool yn)
|
|
|
|
{
|
2009-12-11 18:29:48 -05:00
|
|
|
ENSURE_GUI_THREAD (*this, &CrossfadeEditor::audition_state_changed, yn)
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (!yn) {
|
|
|
|
audition_both_button.set_active (false);
|
|
|
|
audition_left_button.set_active (false);
|
|
|
|
audition_right_button.set_active (false);
|
|
|
|
audition_left_dry_button.set_active (false);
|
|
|
|
audition_right_dry_button.set_active (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-06-27 11:51:50 -04:00
|
|
|
CrossfadeEditor::set (const ARDOUR::AutomationList& curve, WhichFade which)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
double firstx, endx;
|
2007-06-27 11:51:50 -04:00
|
|
|
ARDOUR::AutomationList::const_iterator the_end;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
for (list<Point*>::iterator i = fade[which].points.begin(); i != fade[which].points.end(); ++i) {
|
|
|
|
delete *i;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
fade[which].points.clear ();
|
|
|
|
fade[which].gain_curve.clear ();
|
|
|
|
fade[which].normative_curve.clear ();
|
|
|
|
|
|
|
|
if (curve.empty()) {
|
|
|
|
goto out;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-18 20:47:49 -04:00
|
|
|
the_end = curve.end();
|
2005-09-25 14:42:24 -04:00
|
|
|
--the_end;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-18 20:47:49 -04:00
|
|
|
firstx = (*curve.begin())->when;
|
2005-09-25 14:42:24 -04:00
|
|
|
endx = (*the_end)->when;
|
|
|
|
|
2008-09-18 20:47:49 -04:00
|
|
|
for (ARDOUR::AutomationList::const_iterator i = curve.begin(); i != curve.end(); ++i) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
double xfract = ((*i)->when - firstx) / (endx - firstx);
|
|
|
|
double yfract = ((*i)->value - miny) / (maxy - miny);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
Point* p = make_point ();
|
|
|
|
|
|
|
|
p->move_to (x_coordinate (xfract), y_coordinate (yfract),
|
|
|
|
xfract, yfract);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
fade[which].points.push_back (p);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no need to sort because curve is already time-ordered */
|
|
|
|
|
|
|
|
out:
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
swap (which, current);
|
|
|
|
redraw ();
|
|
|
|
swap (which, current);
|
|
|
|
}
|
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
bool
|
|
|
|
CrossfadeEditor::curve_event (GdkEvent* event)
|
|
|
|
{
|
|
|
|
/* treat it like a toplevel event */
|
|
|
|
|
|
|
|
return canvas_event (event);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CrossfadeEditor::point_event (GdkEvent* event, Point* point)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-11-14 22:12:16 -05:00
|
|
|
|
|
|
|
if (point->curve != fade[current].line) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (event->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
point_grabbed = true;
|
|
|
|
break;
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
point_grabbed = false;
|
|
|
|
|
|
|
|
if (Keyboard::is_delete_event (&event->button)) {
|
|
|
|
fade[current].points.remove (point);
|
|
|
|
delete point;
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2005-11-14 22:12:16 -05:00
|
|
|
|
|
|
|
redraw ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_MOTION_NOTIFY:
|
|
|
|
if (point_grabbed) {
|
|
|
|
double new_x, new_y;
|
|
|
|
|
2010-08-16 22:48:24 -04:00
|
|
|
/* can't drag first or last points horizontally or vertically */
|
2005-11-14 22:12:16 -05:00
|
|
|
|
|
|
|
if (point == fade[current].points.front() || point == fade[current].points.back()) {
|
|
|
|
new_x = point->x;
|
2010-11-25 15:37:39 -05:00
|
|
|
new_y = point->y;
|
2005-11-14 22:12:16 -05:00
|
|
|
} else {
|
|
|
|
new_x = (event->motion.x - canvas_border)/effective_width();
|
2010-11-25 15:37:39 -05:00
|
|
|
new_y = 1.0 - ((event->motion.y - canvas_border)/effective_height());
|
2005-11-14 22:12:16 -05:00
|
|
|
}
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
point->move_to (x_coordinate (new_x), y_coordinate (new_y),
|
2005-11-14 22:12:16 -05:00
|
|
|
new_x, new_y);
|
|
|
|
redraw ();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
bool
|
|
|
|
CrossfadeEditor::canvas_event (GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
switch (event->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
add_control_point ((event->button.x - canvas_border)/effective_width(),
|
|
|
|
1.0 - ((event->button.y - canvas_border)/effective_height()));
|
2008-04-14 02:23:11 -04:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-04-14 02:23:11 -04:00
|
|
|
return false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
CrossfadeEditor::Point::~Point()
|
|
|
|
{
|
2005-11-28 17:36:26 -05:00
|
|
|
delete box;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
CrossfadeEditor::Point*
|
|
|
|
CrossfadeEditor::make_point ()
|
|
|
|
{
|
|
|
|
Point* p = new Point;
|
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
p->box = new ArdourCanvas::SimpleRect (*(canvas->root()));
|
|
|
|
p->box->property_fill() = true;
|
2007-06-29 13:13:09 -04:00
|
|
|
p->box->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_CrossfadeEditorPointFill.get();
|
|
|
|
p->box->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_CrossfadeEditorPointOutline.get();
|
2005-11-14 22:12:16 -05:00
|
|
|
p->box->property_outline_pixels() = 1;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
p->curve = fade[current].line;
|
|
|
|
|
2009-12-11 18:29:48 -05:00
|
|
|
p->box->signal_event().connect (sigc::bind (sigc::mem_fun (*this, &CrossfadeEditor::point_event), p));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::add_control_point (double x, double y)
|
|
|
|
{
|
|
|
|
PointSorter cmp;
|
|
|
|
|
|
|
|
/* enforce end point x location */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (fade[current].points.empty()) {
|
|
|
|
x = 0.0;
|
|
|
|
} else if (fade[current].points.size() == 1) {
|
|
|
|
x = 1.0;
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
Point* p = make_point ();
|
|
|
|
|
|
|
|
p->move_to (x_coordinate (x), y_coordinate (y), x, y);
|
|
|
|
|
|
|
|
fade[current].points.push_back (p);
|
|
|
|
fade[current].points.sort (cmp);
|
|
|
|
|
|
|
|
redraw ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::Point::move_to (double nx, double ny, double xfract, double yfract)
|
|
|
|
{
|
2010-11-25 15:37:39 -05:00
|
|
|
if ( xfract < 0.0 ) {
|
|
|
|
xfract = 0.0;
|
|
|
|
} else if ( xfract > 1.0 ) {
|
|
|
|
xfract = 1.0;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
if ( yfract < 0.0 ) {
|
|
|
|
yfract = 0.0;
|
|
|
|
} else if ( yfract > 1.0 ) {
|
|
|
|
yfract = 1.0;
|
|
|
|
}
|
2010-03-16 11:33:04 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
const double half_size = rint(size/2.0);
|
|
|
|
double x1 = nx - half_size;
|
|
|
|
double x2 = nx + half_size;
|
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
box->property_x1() = x1;
|
|
|
|
box->property_x2() = x2;
|
|
|
|
|
|
|
|
box->property_y1() = ny - half_size;
|
|
|
|
box->property_y2() = ny + half_size;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
x = xfract;
|
|
|
|
y = yfract;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-07-21 11:55:17 -04:00
|
|
|
CrossfadeEditor::canvas_allocation (Gtk::Allocation& /*alloc*/)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (toplevel) {
|
2005-11-14 22:12:16 -05:00
|
|
|
toplevel->property_x1() = 0.0;
|
|
|
|
toplevel->property_y1() = 0.0;
|
|
|
|
toplevel->property_x2() = (double) canvas->get_allocation().get_width() + canvas_border;
|
|
|
|
toplevel->property_y2() = (double) canvas->get_allocation().get_height() + canvas_border;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
|
|
|
canvas->set_scroll_region (0.0, 0.0,
|
|
|
|
canvas->get_allocation().get_width(),
|
2005-11-14 22:12:16 -05:00
|
|
|
canvas->get_allocation().get_height());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
Point* end = make_point ();
|
|
|
|
PointSorter cmp;
|
|
|
|
|
|
|
|
if (fade[In].points.size() > 1) {
|
|
|
|
Point* old_end = fade[In].points.back();
|
|
|
|
fade[In].points.pop_back ();
|
|
|
|
end->move_to (x_coordinate (old_end->x),
|
|
|
|
y_coordinate (old_end->y),
|
|
|
|
old_end->x, old_end->y);
|
|
|
|
delete old_end;
|
|
|
|
} else {
|
|
|
|
double x = 1.0;
|
|
|
|
double y = 0.5;
|
|
|
|
end->move_to (x_coordinate (x), y_coordinate (y), x, y);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fade[In].points.push_back (end);
|
|
|
|
fade[In].points.sort (cmp);
|
|
|
|
|
|
|
|
for (list<Point*>::iterator i = fade[In].points.begin(); i != fade[In].points.end(); ++i) {
|
|
|
|
(*i)->move_to (x_coordinate((*i)->x), y_coordinate((*i)->y),
|
|
|
|
(*i)->x, (*i)->y);
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
end = make_point ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (fade[Out].points.size() > 1) {
|
|
|
|
Point* old_end = fade[Out].points.back();
|
|
|
|
fade[Out].points.pop_back ();
|
|
|
|
end->move_to (x_coordinate (old_end->x),
|
|
|
|
y_coordinate (old_end->y),
|
|
|
|
old_end->x, old_end->y);
|
|
|
|
delete old_end;
|
|
|
|
} else {
|
|
|
|
double x = 1.0;
|
|
|
|
double y = 0.5;
|
|
|
|
end->move_to (x_coordinate (x), y_coordinate (y), x, y);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fade[Out].points.push_back (end);
|
|
|
|
fade[Out].points.sort (cmp);
|
|
|
|
|
|
|
|
for (list<Point*>::iterator i = fade[Out].points.begin(); i != fade[Out].points.end(); ++i) {
|
|
|
|
(*i)->move_to (x_coordinate ((*i)->x),
|
|
|
|
y_coordinate ((*i)->y),
|
|
|
|
(*i)->x, (*i)->y);
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
WhichFade old_current = current;
|
|
|
|
current = In;
|
|
|
|
redraw ();
|
|
|
|
current = Out;
|
|
|
|
redraw ();
|
|
|
|
current = old_current;
|
|
|
|
|
2007-01-11 14:50:49 -05:00
|
|
|
double spu = xfade->length() / (double) effective_width();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (fade[In].waves.empty()) {
|
2007-01-11 14:50:49 -05:00
|
|
|
make_waves (xfade->in(), In);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fade[Out].waves.empty()) {
|
2007-01-11 14:50:49 -05:00
|
|
|
make_waves (xfade->out(), Out);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
double ht;
|
2005-11-14 22:12:16 -05:00
|
|
|
vector<ArdourCanvas::WaveView*>::iterator i;
|
2005-09-25 14:42:24 -04:00
|
|
|
uint32_t n;
|
|
|
|
|
2007-01-11 14:50:49 -05:00
|
|
|
ht = canvas->get_allocation().get_height() / xfade->in()->n_channels();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
for (n = 0, i = fade[In].waves.begin(); i != fade[In].waves.end(); ++i, ++n) {
|
|
|
|
double yoff;
|
|
|
|
|
|
|
|
yoff = n * ht;
|
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
(*i)->property_y() = yoff;
|
|
|
|
(*i)->property_height() = ht;
|
|
|
|
(*i)->property_samples_per_unit() = spu;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2007-01-11 14:50:49 -05:00
|
|
|
ht = canvas->get_allocation().get_height() / xfade->out()->n_channels();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
for (n = 0, i = fade[Out].waves.begin(); i != fade[Out].waves.end(); ++i, ++n) {
|
|
|
|
double yoff;
|
|
|
|
|
|
|
|
yoff = n * ht;
|
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
(*i)->property_y() = yoff;
|
|
|
|
(*i)->property_height() = ht;
|
|
|
|
(*i)->property_samples_per_unit() = spu;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2010-02-19 13:09:08 -05:00
|
|
|
CrossfadeEditor::xfade_changed (const PropertyChange&)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2007-01-11 14:50:49 -05:00
|
|
|
set (xfade->fade_in(), In);
|
|
|
|
set (xfade->fade_out(), Out);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::redraw ()
|
|
|
|
{
|
2005-11-14 22:12:16 -05:00
|
|
|
if (canvas->get_allocation().get_width() < 2) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-12-03 17:26:29 -05:00
|
|
|
framecnt_t len = xfade->length ();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
fade[current].normative_curve.clear ();
|
|
|
|
fade[current].gain_curve.clear ();
|
|
|
|
|
|
|
|
for (list<Point*>::iterator i = fade[current].points.begin(); i != fade[current].points.end(); ++i) {
|
|
|
|
fade[current].normative_curve.add ((*i)->x, (*i)->y);
|
2008-01-10 16:20:59 -05:00
|
|
|
double offset;
|
|
|
|
if (current==In)
|
|
|
|
offset = xfade->in()->start();
|
|
|
|
else
|
|
|
|
offset = xfade->out()->start()+xfade->out()->length()-xfade->length();
|
|
|
|
fade[current].gain_curve.add (((*i)->x * len) + offset, (*i)->y);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
size_t npoints = (size_t) effective_width();
|
|
|
|
float vec[npoints];
|
|
|
|
|
2007-06-27 11:51:50 -04:00
|
|
|
fade[current].normative_curve.curve().get_vector (0, 1.0, vec, npoints);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-11-23 12:21:12 -05:00
|
|
|
ArdourCanvas::Points pts;
|
|
|
|
ArdourCanvas::Points spts;
|
2005-11-14 22:12:16 -05:00
|
|
|
|
|
|
|
while (pts.size() < npoints) {
|
|
|
|
pts.push_back (Gnome::Art::Point (0,0));
|
|
|
|
}
|
|
|
|
|
|
|
|
while (spts.size() < npoints + 3) {
|
|
|
|
spts.push_back (Gnome::Art::Point (0,0));
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* the shade coordinates *MUST* be in anti-clockwise order.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (current == In) {
|
|
|
|
|
|
|
|
/* lower left */
|
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
spts[0].set_x (canvas_border);
|
|
|
|
spts[0].set_y (effective_height() + canvas_border);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* lower right */
|
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
spts[1].set_x (effective_width() + canvas_border);
|
|
|
|
spts[1].set_y (effective_height() + canvas_border);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* upper right */
|
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
spts[2].set_x (effective_width() + canvas_border);
|
|
|
|
spts[2].set_y (canvas_border);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
|
|
|
|
|
|
|
/* upper left */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
spts[0].set_x (canvas_border);
|
|
|
|
spts[0].set_y (canvas_border);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* lower left */
|
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
spts[1].set_x (canvas_border);
|
|
|
|
spts[1].set_y (effective_height() + canvas_border);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* lower right */
|
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
spts[2].set_x (effective_width() + canvas_border);
|
|
|
|
spts[2].set_y (effective_height() + canvas_border);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
size_t last_spt = (npoints + 3) - 1;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
for (size_t i = 0; i < npoints; ++i) {
|
|
|
|
|
|
|
|
double y = vec[i];
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
pts[i].set_x (canvas_border + i);
|
|
|
|
pts[i].set_y (y_coordinate (y));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
spts[last_spt - i].set_x (canvas_border + i);
|
|
|
|
spts[last_spt - i].set_y (pts[i].get_y());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
fade[current].line->property_points() = pts;
|
|
|
|
fade[current].shading->property_points() = spts;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-11-23 12:21:12 -05:00
|
|
|
for (vector<ArdourCanvas::WaveView*>::iterator i = fade[current].waves.begin(); i != fade[current].waves.end(); ++i) {
|
2009-02-19 14:42:25 -05:00
|
|
|
(*i)->property_gain_src() = static_cast<Evoral::Curve*>(&fade[current].gain_curve.curve());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::apply_preset (Preset *preset)
|
|
|
|
{
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-05-31 17:15:28 -04:00
|
|
|
WhichFade wf = find(fade_in_presets->begin(), fade_in_presets->end(), preset) != fade_in_presets->end() ? In : Out;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-05-31 17:15:28 -04:00
|
|
|
if (current != wf) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-05-31 17:15:28 -04:00
|
|
|
if (wf == In) {
|
|
|
|
select_in_button.clicked();
|
|
|
|
} else {
|
|
|
|
select_out_button.clicked();
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-05-31 17:15:28 -04:00
|
|
|
curve_select_clicked (wf);
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
for (list<Point*>::iterator i = fade[current].points.begin(); i != fade[current].points.end(); ++i) {
|
|
|
|
delete *i;
|
|
|
|
}
|
|
|
|
|
|
|
|
fade[current].points.clear ();
|
|
|
|
|
|
|
|
for (Preset::iterator i = preset->begin(); i != preset->end(); ++i) {
|
|
|
|
Point* p = make_point ();
|
|
|
|
p->move_to (x_coordinate ((*i).x), y_coordinate ((*i).y),
|
|
|
|
(*i).x, (*i).y);
|
|
|
|
fade[current].points.push_back (p);
|
|
|
|
}
|
|
|
|
|
|
|
|
redraw ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::apply ()
|
|
|
|
{
|
2010-06-27 22:40:09 -04:00
|
|
|
_session->begin_reversible_command (_("Edit crossfade"));
|
|
|
|
|
|
|
|
XMLNode& before = xfade->get_state ();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2007-01-11 14:50:49 -05:00
|
|
|
_apply_to (xfade);
|
2010-06-27 22:40:09 -04:00
|
|
|
|
2011-09-21 11:54:19 -04:00
|
|
|
_session->add_command (
|
|
|
|
new MementoCommand<Crossfade> (
|
|
|
|
new ARDOUR::CrossfadeBinder (_session->playlists, xfade->id ()),
|
|
|
|
&before, &xfade->get_state ()
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2010-06-27 22:40:09 -04:00
|
|
|
_session->commit_reversible_command ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-01-11 14:50:49 -05:00
|
|
|
CrossfadeEditor::_apply_to (boost::shared_ptr<Crossfade> xf)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2007-06-27 11:51:50 -04:00
|
|
|
ARDOUR::AutomationList& in (xf->fade_in());
|
|
|
|
ARDOUR::AutomationList& out (xf->fade_out());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* IN */
|
|
|
|
|
|
|
|
|
2008-09-18 20:47:49 -04:00
|
|
|
ARDOUR::AutomationList::const_iterator the_end = in.end();
|
2005-09-25 14:42:24 -04:00
|
|
|
--the_end;
|
|
|
|
|
|
|
|
double firstx = (*in.begin())->when;
|
|
|
|
double endx = (*the_end)->when;
|
|
|
|
|
|
|
|
in.freeze ();
|
|
|
|
in.clear ();
|
|
|
|
|
|
|
|
for (list<Point*>::iterator i = fade[In].points.begin(); i != fade[In].points.end(); ++i) {
|
|
|
|
|
|
|
|
double when = firstx + ((*i)->x * (endx - firstx));
|
2011-07-02 13:16:46 -04:00
|
|
|
double value = (*i)->y;
|
2005-09-25 14:42:24 -04:00
|
|
|
in.add (when, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* OUT */
|
|
|
|
|
2008-09-18 20:47:49 -04:00
|
|
|
the_end = out.end();
|
2005-09-25 14:42:24 -04:00
|
|
|
--the_end;
|
|
|
|
|
|
|
|
firstx = (*out.begin())->when;
|
|
|
|
endx = (*the_end)->when;
|
|
|
|
|
|
|
|
out.freeze ();
|
|
|
|
out.clear ();
|
|
|
|
|
|
|
|
for (list<Point*>::iterator i = fade[Out].points.begin(); i != fade[Out].points.end(); ++i) {
|
|
|
|
|
|
|
|
double when = firstx + ((*i)->x * (endx - firstx));
|
2011-07-02 13:16:46 -04:00
|
|
|
double value = (*i)->y;
|
2005-09-25 14:42:24 -04:00
|
|
|
out.add (when, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
in.thaw ();
|
|
|
|
out.thaw ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-01-11 14:50:49 -05:00
|
|
|
CrossfadeEditor::setup (boost::shared_ptr<Crossfade> xfade)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
_apply_to (xfade);
|
|
|
|
xfade->set_active (true);
|
2007-06-27 11:51:50 -04:00
|
|
|
xfade->fade_in().curve().solve ();
|
|
|
|
xfade->fade_out().curve().solve ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::clear ()
|
|
|
|
{
|
|
|
|
for (list<Point*>::iterator i = fade[current].points.begin(); i != fade[current].points.end(); ++i) {
|
|
|
|
delete *i;
|
|
|
|
}
|
|
|
|
|
|
|
|
fade[current].points.clear ();
|
|
|
|
|
|
|
|
redraw ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::reset ()
|
|
|
|
{
|
2007-01-11 14:50:49 -05:00
|
|
|
set (xfade->fade_in(), In);
|
|
|
|
set (xfade->fade_out(), Out);
|
2007-05-31 17:15:28 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
curve_select_clicked (current);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::build_presets ()
|
|
|
|
{
|
|
|
|
Preset* p;
|
|
|
|
|
|
|
|
fade_in_presets = new Presets;
|
|
|
|
fade_out_presets = new Presets;
|
|
|
|
|
2009-03-06 10:18:33 -05:00
|
|
|
/* FADE IN */
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-03-06 10:18:33 -05:00
|
|
|
p = new Preset ("Linear (-6dB)", "crossfade-in-linear");
|
2005-09-25 14:42:24 -04:00
|
|
|
p->push_back (PresetPoint (0, 0));
|
2008-12-12 09:43:24 -05:00
|
|
|
p->push_back (PresetPoint (0.000000, 0.000000));
|
|
|
|
p->push_back (PresetPoint (0.166667, 0.166366));
|
|
|
|
p->push_back (PresetPoint (0.333333, 0.332853));
|
|
|
|
p->push_back (PresetPoint (0.500000, 0.499459));
|
|
|
|
p->push_back (PresetPoint (0.666667, 0.666186));
|
|
|
|
p->push_back (PresetPoint (0.833333, 0.833033));
|
|
|
|
p->push_back (PresetPoint (1.000000, 1.000000));
|
2005-09-25 14:42:24 -04:00
|
|
|
fade_in_presets->push_back (p);
|
|
|
|
|
2009-03-06 10:18:33 -05:00
|
|
|
p = new Preset ("S(1)-curve", "crossfade-in-S1");
|
2007-05-21 18:12:06 -04:00
|
|
|
p->push_back (PresetPoint (0, 0));
|
|
|
|
p->push_back (PresetPoint (0.1, 0.01));
|
|
|
|
p->push_back (PresetPoint (0.2, 0.03));
|
|
|
|
p->push_back (PresetPoint (0.8, 0.97));
|
|
|
|
p->push_back (PresetPoint (0.9, 0.99));
|
|
|
|
p->push_back (PresetPoint (1, 1));
|
|
|
|
fade_in_presets->push_back (p);
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2009-03-06 10:18:33 -05:00
|
|
|
p = new Preset ("S(2)-curve", "crossfade-in-S2");
|
2008-12-12 09:43:24 -05:00
|
|
|
p->push_back (PresetPoint (0.0, 0.0));
|
|
|
|
p->push_back (PresetPoint (0.055, 0.222));
|
|
|
|
p->push_back (PresetPoint (0.163, 0.35));
|
|
|
|
p->push_back (PresetPoint (0.837, 0.678));
|
|
|
|
p->push_back (PresetPoint (0.945, 0.783));
|
|
|
|
p->push_back (PresetPoint (1.0, 1.0));
|
|
|
|
fade_in_presets->push_back (p);
|
|
|
|
|
2009-03-06 10:18:33 -05:00
|
|
|
p = new Preset ("Constant Power (-3dB)", "crossfade-in-constant-power");
|
2008-12-12 09:43:24 -05:00
|
|
|
|
|
|
|
p->push_back (PresetPoint (0.000000, 0.000000));
|
|
|
|
p->push_back (PresetPoint (0.166667, 0.282192));
|
|
|
|
p->push_back (PresetPoint (0.333333, 0.518174));
|
|
|
|
p->push_back (PresetPoint (0.500000, 0.707946));
|
|
|
|
p->push_back (PresetPoint (0.666667, 0.851507));
|
|
|
|
p->push_back (PresetPoint (0.833333, 0.948859));
|
|
|
|
p->push_back (PresetPoint (1.000000, 1.000000));
|
|
|
|
|
|
|
|
fade_in_presets->push_back (p);
|
|
|
|
|
|
|
|
if (!Profile->get_sae()) {
|
2009-03-06 10:18:33 -05:00
|
|
|
|
|
|
|
p = new Preset ("Short cut", "crossfade-in-short-cut");
|
2008-12-12 09:43:24 -05:00
|
|
|
p->push_back (PresetPoint (0, 0));
|
|
|
|
p->push_back (PresetPoint (0.389401, 0.0333333));
|
|
|
|
p->push_back (PresetPoint (0.629032, 0.0861111));
|
|
|
|
p->push_back (PresetPoint (0.829493, 0.233333));
|
|
|
|
p->push_back (PresetPoint (0.9447, 0.483333));
|
|
|
|
p->push_back (PresetPoint (0.976959, 0.697222));
|
|
|
|
p->push_back (PresetPoint (1, 1));
|
|
|
|
fade_in_presets->push_back (p);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-03-06 10:18:33 -05:00
|
|
|
p = new Preset ("Slow cut", "crossfade-in-slow-cut");
|
2008-12-12 09:43:24 -05:00
|
|
|
p->push_back (PresetPoint (0, 0));
|
|
|
|
p->push_back (PresetPoint (0.304147, 0.0694444));
|
|
|
|
p->push_back (PresetPoint (0.529954, 0.152778));
|
|
|
|
p->push_back (PresetPoint (0.725806, 0.333333));
|
|
|
|
p->push_back (PresetPoint (0.847926, 0.558333));
|
|
|
|
p->push_back (PresetPoint (0.919355, 0.730556));
|
|
|
|
p->push_back (PresetPoint (1, 1));
|
|
|
|
fade_in_presets->push_back (p);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-03-06 10:18:33 -05:00
|
|
|
p = new Preset ("Fast cut", "crossfade-in-fast-cut");
|
|
|
|
p->push_back (PresetPoint (0, 0));
|
|
|
|
p->push_back (PresetPoint (0.0737327, 0.308333));
|
|
|
|
p->push_back (PresetPoint (0.246544, 0.658333));
|
|
|
|
p->push_back (PresetPoint (0.470046, 0.886111));
|
|
|
|
p->push_back (PresetPoint (0.652074, 0.972222));
|
|
|
|
p->push_back (PresetPoint (0.771889, 0.988889));
|
|
|
|
p->push_back (PresetPoint (1, 1));
|
|
|
|
fade_in_presets->push_back (p);
|
|
|
|
|
|
|
|
p = new Preset ("Long cut", "crossfade-in-long-cut");
|
|
|
|
p->push_back (PresetPoint (0, 0));
|
|
|
|
p->push_back (PresetPoint (0.0207373, 0.197222));
|
|
|
|
p->push_back (PresetPoint (0.0645161, 0.525));
|
|
|
|
p->push_back (PresetPoint (0.152074, 0.802778));
|
|
|
|
p->push_back (PresetPoint (0.276498, 0.919444));
|
|
|
|
p->push_back (PresetPoint (0.481567, 0.980556));
|
|
|
|
p->push_back (PresetPoint (0.767281, 1));
|
|
|
|
p->push_back (PresetPoint (1, 1));
|
|
|
|
fade_in_presets->push_back (p);
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
/* FADE OUT */
|
|
|
|
|
2008-12-12 09:43:24 -05:00
|
|
|
// p = new Preset ("regout.xpm");
|
2009-03-06 10:18:33 -05:00
|
|
|
p = new Preset ("Linear (-6dB cut)", "crossfade-out-linear");
|
2005-09-25 14:42:24 -04:00
|
|
|
p->push_back (PresetPoint (0, 1));
|
2008-12-12 09:43:24 -05:00
|
|
|
p->push_back (PresetPoint (0.000000, 1.000000));
|
|
|
|
p->push_back (PresetPoint (0.166667, 0.833033));
|
|
|
|
p->push_back (PresetPoint (0.333333, 0.666186));
|
|
|
|
p->push_back (PresetPoint (0.500000, 0.499459));
|
|
|
|
p->push_back (PresetPoint (0.666667, 0.332853));
|
|
|
|
p->push_back (PresetPoint (0.833333, 0.166366));
|
|
|
|
p->push_back (PresetPoint (1.000000, 0.000000));
|
2005-09-25 14:42:24 -04:00
|
|
|
fade_out_presets->push_back (p);
|
|
|
|
|
2009-03-06 10:18:33 -05:00
|
|
|
p = new Preset ("S(1)-Curve", "crossfade-out-S1");
|
2008-03-17 16:54:03 -04:00
|
|
|
p->push_back (PresetPoint (0, 1));
|
2008-12-12 09:43:24 -05:00
|
|
|
p->push_back (PresetPoint (0.1, 0.99));
|
|
|
|
p->push_back (PresetPoint (0.2, 0.97));
|
|
|
|
p->push_back (PresetPoint (0.8, 0.03));
|
|
|
|
p->push_back (PresetPoint (0.9, 0.01));
|
2008-03-17 16:54:03 -04:00
|
|
|
p->push_back (PresetPoint (1, 0));
|
|
|
|
fade_out_presets->push_back (p);
|
|
|
|
|
2009-03-06 10:18:33 -05:00
|
|
|
p = new Preset ("S(2)-Curve", "crossfade-out-S2");
|
2008-12-12 09:43:24 -05:00
|
|
|
p->push_back (PresetPoint (0.0, 1.0));
|
|
|
|
p->push_back (PresetPoint (0.163, 0.678));
|
|
|
|
p->push_back (PresetPoint (0.055, 0.783));
|
|
|
|
p->push_back (PresetPoint (0.837, 0.35));
|
|
|
|
p->push_back (PresetPoint (0.945, 0.222));
|
|
|
|
p->push_back (PresetPoint (1.0, 0.0));
|
2005-09-25 14:42:24 -04:00
|
|
|
fade_out_presets->push_back (p);
|
|
|
|
|
2007-03-18 02:07:08 -04:00
|
|
|
// p = new Preset ("linout.xpm");
|
2009-03-06 10:18:33 -05:00
|
|
|
p = new Preset ("Constant Power (-3dB cut)", "crossfade-out-constant-power");
|
2008-12-12 09:43:24 -05:00
|
|
|
p->push_back (PresetPoint (0.000000, 1.000000));
|
|
|
|
p->push_back (PresetPoint (0.166667, 0.948859));
|
|
|
|
p->push_back (PresetPoint (0.333333, 0.851507));
|
|
|
|
p->push_back (PresetPoint (0.500000, 0.707946));
|
|
|
|
p->push_back (PresetPoint (0.666667, 0.518174));
|
|
|
|
p->push_back (PresetPoint (0.833333, 0.282192));
|
|
|
|
p->push_back (PresetPoint (1.000000, 0.000000));
|
2005-09-25 14:42:24 -04:00
|
|
|
fade_out_presets->push_back (p);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-12-12 09:43:24 -05:00
|
|
|
if (!Profile->get_sae()) {
|
|
|
|
// p = new Preset ("hiout.xpm");
|
2009-03-06 10:18:33 -05:00
|
|
|
p = new Preset ("Short cut", "crossfade-out-short-cut");
|
2008-12-12 09:43:24 -05:00
|
|
|
p->push_back (PresetPoint (0, 1));
|
|
|
|
p->push_back (PresetPoint (0.305556, 1));
|
|
|
|
p->push_back (PresetPoint (0.548611, 0.991736));
|
|
|
|
p->push_back (PresetPoint (0.759259, 0.931129));
|
|
|
|
p->push_back (PresetPoint (0.918981, 0.68595));
|
|
|
|
p->push_back (PresetPoint (0.976852, 0.22865));
|
|
|
|
p->push_back (PresetPoint (1, 0));
|
|
|
|
fade_out_presets->push_back (p);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-03-06 10:18:33 -05:00
|
|
|
p = new Preset ("Slow cut", "crossfade-out-slow-cut");
|
2008-12-12 09:43:24 -05:00
|
|
|
p->push_back (PresetPoint (0, 1));
|
2009-03-06 10:18:33 -05:00
|
|
|
p->push_back (PresetPoint (0.228111, 0.988889));
|
|
|
|
p->push_back (PresetPoint (0.347926, 0.972222));
|
|
|
|
p->push_back (PresetPoint (0.529954, 0.886111));
|
|
|
|
p->push_back (PresetPoint (0.753456, 0.658333));
|
|
|
|
p->push_back (PresetPoint (0.9262673, 0.308333));
|
2008-12-12 09:43:24 -05:00
|
|
|
p->push_back (PresetPoint (1, 0));
|
|
|
|
fade_out_presets->push_back (p);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-03-06 10:18:33 -05:00
|
|
|
p = new Preset ("Fast cut", "crossfade-out-fast-cut");
|
2008-12-12 09:43:24 -05:00
|
|
|
p->push_back (PresetPoint (0, 1));
|
|
|
|
p->push_back (PresetPoint (0.080645, 0.730556));
|
|
|
|
p->push_back (PresetPoint (0.277778, 0.289256));
|
|
|
|
p->push_back (PresetPoint (0.470046, 0.152778));
|
|
|
|
p->push_back (PresetPoint (0.695853, 0.0694444));
|
|
|
|
p->push_back (PresetPoint (1, 0));
|
|
|
|
fade_out_presets->push_back (p);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-03-06 10:18:33 -05:00
|
|
|
// p = new Preset ("loout.xpm");
|
|
|
|
p = new Preset ("Long cut", "crossfade-out-long-cut");
|
|
|
|
p->push_back (PresetPoint (0, 1));
|
|
|
|
p->push_back (PresetPoint (0.023041, 0.697222));
|
|
|
|
p->push_back (PresetPoint (0.0553, 0.483333));
|
|
|
|
p->push_back (PresetPoint (0.170507, 0.233333));
|
|
|
|
p->push_back (PresetPoint (0.370968, 0.0861111));
|
|
|
|
p->push_back (PresetPoint (0.610599, 0.0333333));
|
|
|
|
p->push_back (PresetPoint (1, 0));
|
|
|
|
fade_out_presets->push_back (p);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::curve_select_clicked (WhichFade wf)
|
|
|
|
{
|
|
|
|
current = wf;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (wf == In) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
for (vector<ArdourCanvas::WaveView*>::iterator i = fade[In].waves.begin(); i != fade[In].waves.end(); ++i) {
|
2007-06-29 13:13:09 -04:00
|
|
|
(*i)->property_wave_color() = ARDOUR_UI::config()->canvasvar_SelectedCrossfadeEditorWave.get();
|
2008-02-01 22:57:35 -05:00
|
|
|
(*i)->property_fill_color() = ARDOUR_UI::config()->canvasvar_SelectedCrossfadeEditorWave.get();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
for (vector<ArdourCanvas::WaveView*>::iterator i = fade[Out].waves.begin(); i != fade[Out].waves.end(); ++i) {
|
2007-06-29 13:13:09 -04:00
|
|
|
(*i)->property_wave_color() = ARDOUR_UI::config()->canvasvar_CrossfadeEditorWave.get();
|
2008-02-01 22:57:35 -05:00
|
|
|
(*i)->property_fill_color() = ARDOUR_UI::config()->canvasvar_CrossfadeEditorWave.get();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2007-06-29 13:13:09 -04:00
|
|
|
fade[In].line->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_SelectedCrossfadeEditorLine.get();
|
|
|
|
fade[Out].line->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_CrossfadeEditorLine.get();
|
2005-11-14 22:12:16 -05:00
|
|
|
fade[Out].shading->hide();
|
|
|
|
fade[In].shading->show();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
for (list<Point*>::iterator i = fade[Out].points.begin(); i != fade[Out].points.end(); ++i) {
|
2005-11-14 22:12:16 -05:00
|
|
|
(*i)->box->hide();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
for (list<Point*>::iterator i = fade[In].points.begin(); i != fade[In].points.end(); ++i) {
|
2005-11-14 22:12:16 -05:00
|
|
|
(*i)->box->show ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
for (vector<ArdourCanvas::WaveView*>::iterator i = fade[In].waves.begin(); i != fade[In].waves.end(); ++i) {
|
2007-06-29 13:13:09 -04:00
|
|
|
(*i)->property_wave_color() = ARDOUR_UI::config()->canvasvar_CrossfadeEditorWave.get();
|
2008-02-01 22:57:35 -05:00
|
|
|
(*i)->property_fill_color() = ARDOUR_UI::config()->canvasvar_CrossfadeEditorWave.get();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
for (vector<ArdourCanvas::WaveView*>::iterator i = fade[Out].waves.begin(); i != fade[Out].waves.end(); ++i) {
|
2007-06-29 13:13:09 -04:00
|
|
|
(*i)->property_wave_color() = ARDOUR_UI::config()->canvasvar_SelectedCrossfadeEditorWave.get();
|
2008-02-01 22:57:35 -05:00
|
|
|
(*i)->property_fill_color() = ARDOUR_UI::config()->canvasvar_SelectedCrossfadeEditorWave.get();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2007-06-29 13:13:09 -04:00
|
|
|
fade[Out].line->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_SelectedCrossfadeEditorLine.get();
|
|
|
|
fade[In].line->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_CrossfadeEditorLine.get();
|
2005-11-14 22:12:16 -05:00
|
|
|
fade[In].shading->hide();
|
|
|
|
fade[Out].shading->show();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
for (list<Point*>::iterator i = fade[In].points.begin(); i != fade[In].points.end(); ++i) {
|
2005-11-14 22:12:16 -05:00
|
|
|
(*i)->box->hide();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
for (list<Point*>::iterator i = fade[Out].points.begin(); i != fade[Out].points.end(); ++i) {
|
2006-03-26 06:27:01 -05:00
|
|
|
(*i)->box->show();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
double
|
2005-09-25 14:42:24 -04:00
|
|
|
CrossfadeEditor::x_coordinate (double& xfract) const
|
|
|
|
{
|
|
|
|
xfract = min (1.0, xfract);
|
|
|
|
xfract = max (0.0, xfract);
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
return canvas_border + (xfract * effective_width());
|
|
|
|
}
|
|
|
|
|
|
|
|
double
|
|
|
|
CrossfadeEditor::y_coordinate (double& yfract) const
|
|
|
|
{
|
|
|
|
yfract = min (1.0, yfract);
|
|
|
|
yfract = max (0.0, yfract);
|
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
return (canvas->get_allocation().get_height() - (canvas_border)) - (yfract * effective_height());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-08-29 17:21:48 -04:00
|
|
|
CrossfadeEditor::make_waves (boost::shared_ptr<AudioRegion> region, WhichFade which)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
gdouble ht;
|
2006-08-29 17:21:48 -04:00
|
|
|
uint32_t nchans = region->n_channels();
|
2005-09-25 14:42:24 -04:00
|
|
|
guint32 color;
|
|
|
|
double spu;
|
|
|
|
|
|
|
|
if (which == In) {
|
2007-06-29 13:13:09 -04:00
|
|
|
color = ARDOUR_UI::config()->canvasvar_SelectedCrossfadeEditorWave.get();
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2007-06-29 13:13:09 -04:00
|
|
|
color = ARDOUR_UI::config()->canvasvar_CrossfadeEditorWave.get();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
ht = canvas->get_allocation().get_height() / (double) nchans;
|
2007-01-11 14:50:49 -05:00
|
|
|
spu = xfade->length() / (double) effective_width();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2010-04-21 21:40:33 -04:00
|
|
|
delete _peaks_ready_connection;
|
|
|
|
_peaks_ready_connection = 0;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
for (uint32_t n = 0; n < nchans; ++n) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
gdouble yoff = n * ht;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-04-21 21:40:33 -04:00
|
|
|
if (region->audio_source(n)->peaks_ready (boost::bind (&CrossfadeEditor::peaks_ready, this, boost::weak_ptr<AudioRegion>(region), which), &_peaks_ready_connection, gui_context())) {
|
2005-11-14 22:12:16 -05:00
|
|
|
WaveView* waveview = new WaveView (*(canvas->root()));
|
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
waveview->property_data_src() = region.get();
|
2005-11-14 22:12:16 -05:00
|
|
|
waveview->property_cache_updater() = true;
|
|
|
|
waveview->property_cache() = WaveView::create_cache();
|
|
|
|
waveview->property_channel() = n;
|
|
|
|
waveview->property_length_function() = (void*) region_length_from_c;
|
|
|
|
waveview->property_sourcefile_length_function() = (void*) sourcefile_length_from_c;
|
|
|
|
waveview->property_peak_function() = (void*) region_read_peaks_from_c;
|
|
|
|
waveview->property_gain_function() = (void*) curve_get_vector_from_c;
|
2009-02-19 14:42:25 -05:00
|
|
|
waveview->property_gain_src() = static_cast<Evoral::Curve*>(&fade[which].gain_curve.curve());
|
2005-11-14 22:12:16 -05:00
|
|
|
waveview->property_x() = canvas_border;
|
|
|
|
waveview->property_y() = yoff;
|
|
|
|
waveview->property_height() = ht;
|
|
|
|
waveview->property_samples_per_unit() = spu;
|
|
|
|
waveview->property_amplitude_above_axis() = 2.0;
|
|
|
|
waveview->property_wave_color() = color;
|
2008-02-01 22:57:35 -05:00
|
|
|
waveview->property_fill_color() = color;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
if (which==In)
|
|
|
|
waveview->property_region_start() = region->start();
|
|
|
|
else
|
|
|
|
waveview->property_region_start() = region->start()+region->length()-xfade->length();
|
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
waveview->lower_to_bottom();
|
|
|
|
fade[which].waves.push_back (waveview);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
toplevel->lower_to_bottom();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-12-17 13:24:23 -05:00
|
|
|
CrossfadeEditor::peaks_ready (boost::weak_ptr<AudioRegion> wr, WhichFade which)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
boost::shared_ptr<AudioRegion> r (wr.lock());
|
|
|
|
|
|
|
|
if (!r) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
/* this should never be called, because the peak files for an xfade
|
|
|
|
will be ready by the time we want them. but our API forces us
|
|
|
|
to provide this, so ..
|
|
|
|
*/
|
2010-04-21 21:40:33 -04:00
|
|
|
delete _peaks_ready_connection;
|
|
|
|
_peaks_ready_connection = 0;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
make_waves (r, which);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-04-11 10:06:50 -04:00
|
|
|
CrossfadeEditor::audition (Audition which)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
AudioPlaylist& pl (_session->the_auditioner()->prepare_playlist());
|
2010-12-03 17:26:29 -05:00
|
|
|
framecnt_t preroll;
|
|
|
|
framecnt_t postroll;
|
|
|
|
framecnt_t left_start_offset;
|
|
|
|
framecnt_t right_length;
|
|
|
|
framecnt_t left_length;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
if (which != Right && preroll_button.get_active()) {
|
2009-12-17 13:24:23 -05:00
|
|
|
preroll = _session->frame_rate() * 2; //2 second hardcoded preroll for now
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
|
|
|
preroll = 0;
|
|
|
|
}
|
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
if (which != Left && postroll_button.get_active()) {
|
2009-12-17 13:24:23 -05:00
|
|
|
postroll = _session->frame_rate() * 2; //2 second hardcoded postroll for now
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
|
|
|
postroll = 0;
|
|
|
|
}
|
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
// Is there enough data for the whole preroll?
|
|
|
|
left_length = xfade->length();
|
|
|
|
if ((left_start_offset = xfade->out()->length() - xfade->length()) > preroll) {
|
|
|
|
left_start_offset -= preroll;
|
|
|
|
} else {
|
|
|
|
preroll = left_start_offset;
|
|
|
|
left_start_offset = 0;
|
|
|
|
}
|
|
|
|
left_length += preroll;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
// Is there enough data for the whole postroll?
|
2007-01-11 14:50:49 -05:00
|
|
|
right_length = xfade->length();
|
2008-04-11 10:06:50 -04:00
|
|
|
if ((xfade->in()->length() - right_length) > postroll) {
|
2005-09-25 14:42:24 -04:00
|
|
|
right_length += postroll;
|
2008-04-11 10:06:50 -04:00
|
|
|
} else {
|
|
|
|
right_length = xfade->in()->length();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2011-06-01 13:00:29 -04:00
|
|
|
PropertyList left_plist;
|
|
|
|
PropertyList right_plist;
|
|
|
|
|
2010-02-18 08:59:49 -05:00
|
|
|
|
|
|
|
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);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-02-18 08:59:49 -05:00
|
|
|
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);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
if (which == Left) {
|
2010-02-18 08:59:49 -05:00
|
|
|
right_plist.add (ARDOUR::Properties::scale_amplitude, 0.0f);
|
2008-04-11 10:06:50 -04:00
|
|
|
} else if (which == Right) {
|
2010-02-18 08:59:49 -05:00
|
|
|
left_plist.add (ARDOUR::Properties::scale_amplitude, 0.0f);
|
2008-04-11 10:06:50 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2011-06-01 13:00:29 -04:00
|
|
|
boost::shared_ptr<AudioRegion> left (boost::dynamic_pointer_cast<AudioRegion>
|
2010-02-18 08:59:49 -05:00
|
|
|
(RegionFactory::create (xfade->out(), left_plist, false)));
|
2011-06-01 13:00:29 -04:00
|
|
|
boost::shared_ptr<AudioRegion> right (boost::dynamic_pointer_cast<AudioRegion>
|
2010-02-18 08:59:49 -05:00
|
|
|
(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);
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
/* there is only one ... */
|
2009-06-02 20:23:34 -04:00
|
|
|
pl.foreach_crossfade (sigc::mem_fun (*this, &CrossfadeEditor::setup));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
_session->audition_playlist ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
void
|
|
|
|
CrossfadeEditor::audition_both ()
|
|
|
|
{
|
|
|
|
audition (Both);
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
CrossfadeEditor::audition_left_dry ()
|
|
|
|
{
|
2011-06-01 13:00:29 -04:00
|
|
|
PropertyList plist;
|
2010-02-18 08:59:49 -05:00
|
|
|
|
|
|
|
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);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
|
|
|
boost::shared_ptr<AudioRegion> left (boost::dynamic_pointer_cast<AudioRegion>
|
2010-02-18 08:59:49 -05:00
|
|
|
(RegionFactory::create (xfade->out(), plist, false)));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
_session->audition_region (left);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::audition_left ()
|
|
|
|
{
|
2008-04-11 10:06:50 -04:00
|
|
|
audition (Left);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::audition_right_dry ()
|
|
|
|
{
|
2011-06-01 13:00:29 -04:00
|
|
|
PropertyList plist;
|
2010-02-18 08:59:49 -05:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2011-06-01 13:00:29 -04:00
|
|
|
boost::shared_ptr<AudioRegion> right (boost::dynamic_pointer_cast<AudioRegion>
|
2010-02-18 08:59:49 -05:00
|
|
|
(RegionFactory::create (xfade->in(), plist, false)));
|
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
_session->audition_region (right);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::audition_right ()
|
|
|
|
{
|
2008-04-11 10:06:50 -04:00
|
|
|
audition (Right);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
CrossfadeEditor::cancel_audition ()
|
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
_session->cancel_audition ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::audition_toggled ()
|
|
|
|
{
|
|
|
|
bool x;
|
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if ((x = audition_both_button.get_active ()) != _session->is_auditioning()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (x) {
|
|
|
|
audition_both ();
|
|
|
|
} else {
|
|
|
|
cancel_audition ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::audition_right_toggled ()
|
|
|
|
{
|
|
|
|
bool x;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if ((x = audition_right_button.get_active ()) != _session->is_auditioning()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (x) {
|
|
|
|
audition_right ();
|
|
|
|
} else {
|
|
|
|
cancel_audition ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::audition_right_dry_toggled ()
|
|
|
|
{
|
|
|
|
bool x;
|
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if ((x = audition_right_dry_button.get_active ()) != _session->is_auditioning()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (x) {
|
|
|
|
audition_right_dry ();
|
|
|
|
} else {
|
|
|
|
cancel_audition ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::audition_left_toggled ()
|
|
|
|
{
|
|
|
|
bool x;
|
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if ((x = audition_left_button.get_active ()) != _session->is_auditioning()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (x) {
|
|
|
|
audition_left ();
|
|
|
|
} else {
|
|
|
|
cancel_audition ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::audition_left_dry_toggled ()
|
|
|
|
{
|
|
|
|
bool x;
|
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if ((x = audition_left_dry_button.get_active ()) != _session->is_auditioning()) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (x) {
|
|
|
|
audition_left_dry ();
|
|
|
|
} else {
|
|
|
|
cancel_audition ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
|
|
|
bool
|
2009-07-21 11:55:17 -04:00
|
|
|
CrossfadeEditor::on_key_press_event (GdkEventKey */*ev*/)
|
2008-12-12 09:43:24 -05:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CrossfadeEditor::on_key_release_event (GdkEventKey* ev)
|
|
|
|
{
|
|
|
|
switch (ev->keyval) {
|
|
|
|
case GDK_Right:
|
|
|
|
if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
|
|
|
|
audition_right_dry_button.set_active (!audition_right_dry_button.get_active());
|
|
|
|
} else {
|
|
|
|
audition_right_button.set_active (!audition_right_button.get_active());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_Left:
|
|
|
|
if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
|
|
|
|
audition_left_dry_button.set_active (!audition_left_dry_button.get_active());
|
|
|
|
} else {
|
|
|
|
audition_left_button.set_active (!audition_left_button.get_active());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_space:
|
2009-12-17 13:24:23 -05:00
|
|
|
if (_session->is_auditioning()) {
|
2008-12-12 09:43:24 -05:00
|
|
|
cancel_audition ();
|
|
|
|
} else {
|
|
|
|
audition_both_button.set_active (!audition_both_button.get_active());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|