2005-09-25 14:42:24 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2004 Paul Davis
|
|
|
|
|
|
|
|
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>
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
#include <ardour/automation_event.h>
|
|
|
|
#include <ardour/curve.h>
|
|
|
|
#include <ardour/crossfade.h>
|
|
|
|
#include <ardour/session.h>
|
|
|
|
#include <ardour/auditioner.h>
|
|
|
|
#include <ardour/audioplaylist.h>
|
2006-06-14 21:34:54 -04:00
|
|
|
#include <ardour/audiosource.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
#include <ardour/playlist_templates.h>
|
2006-08-29 17:21:48 -04:00
|
|
|
#include <ardour/region_factory.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"
|
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;
|
2005-09-25 16:33:00 -04:00
|
|
|
using namespace sigc;
|
2005-09-25 14:42:24 -04:00
|
|
|
using namespace Editing;
|
|
|
|
|
|
|
|
#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 ()
|
|
|
|
: line (0),
|
2007-07-03 14:39:09 -04:00
|
|
|
normative_curve (Parameter(GainAutomation), 0.0, 1.0, 1.0), // FIXME: GainAutomation?
|
|
|
|
gain_curve (Parameter(GainAutomation), 0.0, 2.0, 1.0)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-01-11 14:50:49 -05:00
|
|
|
CrossfadeEditor::CrossfadeEditor (Session& s, boost::shared_ptr<Crossfade> xf, double my, double mxy)
|
2005-11-27 16:17:41 -05:00
|
|
|
: ArdourDialog (_("ardour: x-fade edit")),
|
2005-09-25 14:42:24 -04:00
|
|
|
xfade (xf),
|
|
|
|
session (s),
|
|
|
|
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")),
|
|
|
|
|
|
|
|
miny (my),
|
|
|
|
maxy (mxy),
|
|
|
|
|
|
|
|
fade_in_table (3, 3),
|
|
|
|
fade_out_table (3, 3),
|
|
|
|
|
|
|
|
select_in_button (_("Fade In")),
|
|
|
|
select_out_button (_("Fade Out"))
|
|
|
|
{
|
2007-01-09 18:24:54 -05:00
|
|
|
set_wmclass (X_("ardour_automationedit"), "Ardour");
|
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
|
|
|
|
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 ();
|
2005-10-09 01:03:29 -04:00
|
|
|
canvas->signal_size_allocate().connect (mem_fun(*this, &CrossfadeEditor::canvas_allocation));
|
2005-09-25 16:33:00 -04:00
|
|
|
canvas->set_size_request (425, 200);
|
2005-09-25 14:42:24 -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;
|
|
|
|
toplevel->signal_event().connect (mem_fun (*this, &CrossfadeEditor::canvas_event));
|
2005-09-25 14:42:24 -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();
|
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();
|
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();
|
2005-11-14 22:12:16 -05:00
|
|
|
|
|
|
|
fade[In].shading->signal_event().connect (mem_fun (*this, &CrossfadeEditor::canvas_event));
|
|
|
|
fade[In].line->signal_event().connect (mem_fun (*this, &CrossfadeEditor::curve_event));
|
|
|
|
fade[Out].shading->signal_event().connect (mem_fun (*this, &CrossfadeEditor::canvas_event));
|
|
|
|
fade[Out].line->signal_event().connect (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"));
|
|
|
|
|
2005-09-25 17:19:23 -04:00
|
|
|
select_in_button.signal_clicked().connect (bind (mem_fun (*this, &CrossfadeEditor::curve_select_clicked), In));
|
|
|
|
select_out_button.signal_clicked().connect (bind (mem_fun (*this, &CrossfadeEditor::curve_select_clicked), Out));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
HBox* acbox = manage (new HBox);
|
|
|
|
|
|
|
|
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")));
|
|
|
|
|
|
|
|
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");
|
2005-10-09 01:03:29 -04:00
|
|
|
pbutton->signal_clicked().connect (bind (mem_fun(*this, &CrossfadeEditor::apply_preset), *i));
|
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");
|
2005-10-09 01:03:29 -04:00
|
|
|
pbutton->signal_clicked().connect (bind (mem_fun(*this, &CrossfadeEditor::apply_preset), *i));
|
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");
|
|
|
|
|
2005-09-25 17:19:23 -04:00
|
|
|
clear_button.signal_clicked().connect (mem_fun(*this, &CrossfadeEditor::clear));
|
|
|
|
revert_button.signal_clicked().connect (mem_fun(*this, &CrossfadeEditor::reset));
|
2005-10-09 01:03:29 -04:00
|
|
|
audition_both_button.signal_toggled().connect (mem_fun(*this, &CrossfadeEditor::audition_toggled));
|
|
|
|
audition_right_button.signal_toggled().connect (mem_fun(*this, &CrossfadeEditor::audition_right_toggled));
|
|
|
|
audition_right_dry_button.signal_toggled().connect (mem_fun(*this, &CrossfadeEditor::audition_right_dry_toggled));
|
|
|
|
audition_left_button.signal_toggled().connect (mem_fun(*this, &CrossfadeEditor::audition_left_toggled));
|
|
|
|
audition_left_dry_button.signal_toggled().connect (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);
|
|
|
|
|
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"));
|
2005-09-25 17:19:23 -04:00
|
|
|
// foobut-.signal_clicked().connect (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);
|
|
|
|
|
2007-01-11 14:50:49 -05:00
|
|
|
xfade->StateChanged.connect (mem_fun(*this, &CrossfadeEditor::xfade_changed));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-09-25 17:19:23 -04:00
|
|
|
session.AuditionActive.connect (mem_fun(*this, &CrossfadeEditor::audition_state_changed));
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2005-09-25 17:19:23 -04:00
|
|
|
ENSURE_GUI_THREAD (bind (mem_fun(*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;
|
|
|
|
}
|
|
|
|
|
|
|
|
fade[which].points.clear ();
|
|
|
|
fade[which].gain_curve.clear ();
|
|
|
|
fade[which].normative_curve.clear ();
|
|
|
|
|
|
|
|
if (curve.empty()) {
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
the_end = curve.const_end();
|
|
|
|
--the_end;
|
|
|
|
|
|
|
|
firstx = (*curve.const_begin())->when;
|
|
|
|
endx = (*the_end)->when;
|
|
|
|
|
2007-06-27 11:51:50 -04:00
|
|
|
for (ARDOUR::AutomationList::const_iterator i = curve.const_begin(); i != curve.const_end(); ++i) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
double xfract = ((*i)->when - firstx) / (endx - firstx);
|
|
|
|
double yfract = ((*i)->value - miny) / (maxy - miny);
|
|
|
|
|
|
|
|
Point* p = make_point ();
|
|
|
|
|
|
|
|
p->move_to (x_coordinate (xfract), y_coordinate (yfract),
|
|
|
|
xfract, yfract);
|
|
|
|
|
|
|
|
fade[which].points.push_back (p);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no need to sort because curve is already time-ordered */
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
redraw ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_MOTION_NOTIFY:
|
|
|
|
if (point_grabbed) {
|
|
|
|
double new_x, new_y;
|
|
|
|
|
|
|
|
/* can't drag first or last points horizontally */
|
|
|
|
|
|
|
|
if (point == fade[current].points.front() || point == fade[current].points.back()) {
|
|
|
|
new_x = point->x;
|
|
|
|
} else {
|
|
|
|
new_x = (event->motion.x - canvas_border)/effective_width();
|
|
|
|
}
|
|
|
|
|
|
|
|
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 ();
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
|
2005-11-14 22:12:16 -05:00
|
|
|
p->box->signal_event().connect (bind (mem_fun (*this, &CrossfadeEditor::point_event), p));
|
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 */
|
|
|
|
|
|
|
|
if (fade[current].points.empty()) {
|
|
|
|
x = 0.0;
|
|
|
|
} else if (fade[current].points.size() == 1) {
|
|
|
|
x = 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
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
|
2005-11-12 17:07:07 -05: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
|
|
|
}
|
2005-11-14 22:12:16 -05:00
|
|
|
|
|
|
|
canvas->set_scroll_region (0.0, 0.0,
|
|
|
|
canvas->get_allocation().get_width(),
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
end = make_point ();
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
CrossfadeEditor::xfade_changed (Change ignored)
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2007-01-11 14:50:49 -05:00
|
|
|
nframes_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);
|
2005-09-25 14:42:24 -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
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/* upper left */
|
|
|
|
|
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];
|
|
|
|
|
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) {
|
2005-11-14 22:12:16 -05:00
|
|
|
(*i)->property_gain_src() = &fade[current].gain_curve;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::apply_preset (Preset *preset)
|
|
|
|
{
|
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;
|
|
|
|
|
|
|
|
if (current != wf) {
|
|
|
|
|
|
|
|
if (wf == In) {
|
|
|
|
select_in_button.clicked();
|
|
|
|
} else {
|
|
|
|
select_out_button.clicked();
|
|
|
|
}
|
|
|
|
|
|
|
|
curve_select_clicked (wf);
|
|
|
|
}
|
|
|
|
|
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 ()
|
|
|
|
{
|
2007-01-11 14:50:49 -05:00
|
|
|
_apply_to (xfade);
|
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 */
|
|
|
|
|
|
|
|
|
2007-06-27 11:51:50 -04:00
|
|
|
ARDOUR::AutomationList::const_iterator the_end = in.const_end();
|
2005-09-25 14:42:24 -04:00
|
|
|
--the_end;
|
|
|
|
|
|
|
|
double firstx = (*in.begin())->when;
|
|
|
|
double endx = (*the_end)->when;
|
|
|
|
double miny = in.get_min_y ();
|
|
|
|
double maxy = in.get_max_y ();
|
|
|
|
|
|
|
|
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));
|
|
|
|
double value = (*i)->y; // miny + ((*i)->y * (maxy - miny));
|
|
|
|
in.add (when, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* OUT */
|
|
|
|
|
|
|
|
the_end = out.const_end();
|
|
|
|
--the_end;
|
|
|
|
|
|
|
|
firstx = (*out.begin())->when;
|
|
|
|
endx = (*the_end)->when;
|
|
|
|
miny = out.get_min_y ();
|
|
|
|
maxy = out.get_max_y ();
|
|
|
|
|
|
|
|
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));
|
|
|
|
double value = (*i)->y; // miny + ((*i)->y * (maxy - miny));
|
|
|
|
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
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
/* FADE OUT */
|
2007-03-18 02:07:08 -04:00
|
|
|
// p = new Preset ("hiin.xpm");
|
|
|
|
p = new Preset ("crossfade_in_fast-cut");
|
2005-09-25 14:42:24 -04:00
|
|
|
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);
|
|
|
|
|
2007-03-18 02:07:08 -04:00
|
|
|
// p = new Preset ("loin.xpm");
|
|
|
|
p = new Preset ("crossfade_in_transition");
|
2005-09-25 14:42:24 -04: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);
|
|
|
|
|
2007-03-18 02:07:08 -04:00
|
|
|
// p = new Preset ("regin.xpm");
|
|
|
|
p = new Preset ("crossfade_in_constant");
|
2005-09-25 14:42:24 -04:00
|
|
|
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);
|
|
|
|
|
2007-03-18 02:07:08 -04:00
|
|
|
// p = new Preset ("regin2.xpm");
|
|
|
|
p = new Preset ("crossfade_in_slow-cut");
|
2005-09-25 14:42:24 -04: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);
|
|
|
|
|
2007-03-18 02:07:08 -04:00
|
|
|
// p = new Preset ("linin.xpm");
|
|
|
|
p = new Preset ("crossfade_in_dipped");
|
2005-09-25 14:42:24 -04:00
|
|
|
p->push_back (PresetPoint (0, 0));
|
|
|
|
p->push_back (PresetPoint (1, 1));
|
|
|
|
fade_in_presets->push_back (p);
|
|
|
|
|
2007-05-21 18:12:06 -04:00
|
|
|
p = new Preset ("crossfade_in_default");
|
|
|
|
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);
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
/* FADE OUT */
|
|
|
|
|
2007-03-18 02:07:08 -04:00
|
|
|
// p = new Preset ("hiout.xpm");
|
|
|
|
p = new Preset ("crossfade_out_fast-cut");
|
2005-09-25 14:42:24 -04: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);
|
|
|
|
|
2007-03-18 02:07:08 -04:00
|
|
|
// p = new Preset ("loout.xpm");
|
|
|
|
p = new Preset ("crossfade_out_transition");
|
2005-09-25 14:42:24 -04:00
|
|
|
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);
|
|
|
|
|
2008-03-17 16:54:03 -04:00
|
|
|
// p = new Preset ("regout.xpm");
|
|
|
|
p = new Preset ("crossfade_out_constant");
|
|
|
|
p->push_back (PresetPoint (0, 1));
|
|
|
|
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));
|
|
|
|
p->push_back (PresetPoint (1, 0));
|
|
|
|
fade_out_presets->push_back (p);
|
|
|
|
|
2007-03-18 02:07:08 -04:00
|
|
|
// p = new Preset ("regout2.xpm");
|
|
|
|
p = new Preset ("crossfade_out_slow-fade");
|
2005-09-25 14:42:24 -04: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);
|
|
|
|
|
2007-03-18 02:07:08 -04:00
|
|
|
// p = new Preset ("linout.xpm");
|
|
|
|
p = new Preset ("crossfade_out_dipped");
|
2005-09-25 14:42:24 -04:00
|
|
|
p->push_back (PresetPoint (0, 1));
|
|
|
|
p->push_back (PresetPoint (1, 0));
|
|
|
|
fade_out_presets->push_back (p);
|
2007-05-21 18:12:06 -04:00
|
|
|
|
|
|
|
p = new Preset ("crossfade_out_default");
|
|
|
|
p->push_back (PresetPoint (0, 1));
|
|
|
|
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));
|
|
|
|
p->push_back (PresetPoint (1, 0));
|
|
|
|
fade_out_presets->push_back (p);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::curve_select_clicked (WhichFade wf)
|
|
|
|
{
|
|
|
|
current = wf;
|
2005-11-14 22:12:16 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (wf == In) {
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
double
|
|
|
|
CrossfadeEditor::x_coordinate (double& xfract) const
|
|
|
|
{
|
|
|
|
xfract = min (1.0, xfract);
|
|
|
|
xfract = max (0.0, xfract);
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
for (uint32_t n = 0; n < nchans; ++n) {
|
|
|
|
|
|
|
|
gdouble yoff = n * ht;
|
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
if (region->audio_source(n)->peaks_ready (bind (mem_fun(*this, &CrossfadeEditor::peaks_ready), region, which), peaks_ready_connection)) {
|
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;
|
|
|
|
waveview->property_gain_src() = &fade[which].gain_curve;
|
|
|
|
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;
|
2005-09-25 14:42:24 -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
|
2006-08-29 17:21:48 -04:00
|
|
|
CrossfadeEditor::peaks_ready (boost::shared_ptr<AudioRegion> r, WhichFade which)
|
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 ..
|
|
|
|
*/
|
2006-03-01 22:45:26 -05:00
|
|
|
peaks_ready_connection.disconnect ();
|
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
|
|
|
{
|
2006-07-27 21:08:57 -04:00
|
|
|
AudioPlaylist& pl (session.the_auditioner()->prepare_playlist());
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t preroll;
|
|
|
|
nframes_t postroll;
|
|
|
|
nframes_t left_start_offset;
|
|
|
|
nframes_t right_length;
|
|
|
|
nframes_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()) {
|
2008-01-10 16:20:59 -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()) {
|
2008-01-10 16:20:59 -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
|
|
|
}
|
|
|
|
|
2007-01-11 14:50:49 -05:00
|
|
|
boost::shared_ptr<AudioRegion> left (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (xfade->out(), left_start_offset, left_length, "xfade out",
|
2006-08-29 17:21:48 -04:00
|
|
|
0, Region::DefaultFlags, false)));
|
2007-01-11 14:50:49 -05:00
|
|
|
boost::shared_ptr<AudioRegion> right (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (xfade->in(), 0, right_length, "xfade in",
|
2006-08-29 17:21:48 -04:00
|
|
|
0, Region::DefaultFlags, false)));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
//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);
|
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
pl.add_region (left, 0);
|
2008-04-11 10:06:50 -04:00
|
|
|
pl.add_region (right, 1 + preroll);
|
|
|
|
|
|
|
|
if (which == Left) {
|
|
|
|
right->set_scale_amplitude (0.0);
|
|
|
|
} else if (which == Right) {
|
|
|
|
left->set_scale_amplitude (0.0);
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* there is only one ... */
|
|
|
|
pl.foreach_crossfade (this, &CrossfadeEditor::setup);
|
|
|
|
|
|
|
|
session.audition_playlist ();
|
|
|
|
}
|
|
|
|
|
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 ()
|
|
|
|
{
|
2007-01-11 14:50:49 -05:00
|
|
|
boost::shared_ptr<AudioRegion> left (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (xfade->out(), xfade->out()->length() - xfade->length(), xfade->length(), "xfade left",
|
2006-08-29 17:21:48 -04:00
|
|
|
0, Region::DefaultFlags, false)));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-29 17:21:48 -04: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 ()
|
|
|
|
{
|
2007-01-11 14:50:49 -05:00
|
|
|
boost::shared_ptr<AudioRegion> right (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (xfade->in(), 0, xfade->length(), "xfade in",
|
2006-08-29 17:21:48 -04:00
|
|
|
0, Region::DefaultFlags, false)));
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::cancel_audition ()
|
|
|
|
{
|
|
|
|
session.cancel_audition ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::audition_toggled ()
|
|
|
|
{
|
|
|
|
bool x;
|
|
|
|
|
|
|
|
if ((x = audition_both_button.get_active ()) != session.is_auditioning()) {
|
|
|
|
|
|
|
|
if (x) {
|
|
|
|
audition_both ();
|
|
|
|
} else {
|
|
|
|
cancel_audition ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::audition_right_toggled ()
|
|
|
|
{
|
|
|
|
bool x;
|
|
|
|
|
|
|
|
if ((x = audition_right_button.get_active ()) != session.is_auditioning()) {
|
|
|
|
|
|
|
|
if (x) {
|
|
|
|
audition_right ();
|
|
|
|
} else {
|
|
|
|
cancel_audition ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::audition_right_dry_toggled ()
|
|
|
|
{
|
|
|
|
bool x;
|
|
|
|
|
|
|
|
if ((x = audition_right_dry_button.get_active ()) != session.is_auditioning()) {
|
|
|
|
|
|
|
|
if (x) {
|
|
|
|
audition_right_dry ();
|
|
|
|
} else {
|
|
|
|
cancel_audition ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::audition_left_toggled ()
|
|
|
|
{
|
|
|
|
bool x;
|
|
|
|
|
|
|
|
if ((x = audition_left_button.get_active ()) != session.is_auditioning()) {
|
|
|
|
|
|
|
|
if (x) {
|
|
|
|
audition_left ();
|
|
|
|
} else {
|
|
|
|
cancel_audition ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEditor::audition_left_dry_toggled ()
|
|
|
|
{
|
|
|
|
bool x;
|
|
|
|
|
|
|
|
if ((x = audition_left_dry_button.get_active ()) != session.is_auditioning()) {
|
|
|
|
|
|
|
|
if (x) {
|
|
|
|
audition_left_dry ();
|
|
|
|
} else {
|
|
|
|
cancel_audition ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|