2007-04-26 16:54:31 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2005-2013 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
|
|
|
|
* Copyright (C) 2006 Doug McLain <doug@nostar.net>
|
|
|
|
* Copyright (C) 2007-2009 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2009-2010 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2017 Robin Gareus <robin@gareus.org>
|
|
|
|
*
|
|
|
|
* 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.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2007-04-26 16:54:31 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
#ifndef __gtk_ardour_xfade_edit_h__
|
|
|
|
#define __gtk_ardour_xfade_edit_h__
|
|
|
|
|
|
|
|
#include <list>
|
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
#include <gtkmm/box.h>
|
|
|
|
#include <gtkmm/button.h>
|
|
|
|
#include <gtkmm/radiobutton.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
#include "canvas/canvas.h"
|
|
|
|
|
2019-10-25 15:13:51 -04:00
|
|
|
#include "evoral/Curve.h"
|
2009-12-17 13:24:23 -05:00
|
|
|
#include "ardour/session_handle.h"
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "ardour_dialog.h"
|
|
|
|
|
|
|
|
namespace ARDOUR
|
|
|
|
{
|
|
|
|
class Session;
|
2007-06-27 11:51:50 -04:00
|
|
|
class AutomationList;
|
2005-09-25 14:42:24 -04:00
|
|
|
class Crossfade;
|
|
|
|
}
|
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
namespace ArdourCanvas {
|
|
|
|
class Rectangle;
|
|
|
|
class Line;
|
|
|
|
class Polygon;
|
2017-07-17 14:12:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace ArdourWaveview {
|
2013-04-04 00:32:52 -04:00
|
|
|
class WaveView;
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
class CrossfadeEditor : public ArdourDialog
|
|
|
|
{
|
2017-07-01 15:11:14 -04:00
|
|
|
public:
|
2023-02-16 18:33:28 -05:00
|
|
|
CrossfadeEditor (ARDOUR::Session*, std::shared_ptr<ARDOUR::Crossfade>, double miny, double maxy);
|
2007-01-10 11:19:13 -05:00
|
|
|
~CrossfadeEditor ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
void apply ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
static const double canvas_border;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2017-07-01 15:11:14 -04:00
|
|
|
/* these are public so that a caller/subclass can make them do the right thing. */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
Gtk::Button* cancel_button;
|
|
|
|
Gtk::Button* ok_button;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
struct PresetPoint {
|
2017-07-01 12:42:24 -04:00
|
|
|
double x;
|
|
|
|
double y;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
PresetPoint (double a, double b)
|
|
|
|
: x (a), y (b) {}
|
2007-01-10 11:19:13 -05:00
|
|
|
};
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-12 13:03:42 -04:00
|
|
|
struct Preset : public std::list<PresetPoint> {
|
2017-07-01 12:42:24 -04:00
|
|
|
const char* name;
|
|
|
|
const char* image_name;
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
Preset (const char* n, const char* x) : name (n), image_name (x) {}
|
2007-01-10 11:19:13 -05:00
|
|
|
};
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-12 13:03:42 -04:00
|
|
|
typedef std::list<Preset*> Presets;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
static Presets* fade_in_presets;
|
|
|
|
static Presets* fade_out_presets;
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2017-07-01 15:11:14 -04:00
|
|
|
protected:
|
2008-12-12 09:43:24 -05:00
|
|
|
bool on_key_press_event (GdkEventKey*);
|
|
|
|
bool on_key_release_event (GdkEventKey*);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2017-07-01 15:11:14 -04:00
|
|
|
private:
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<ARDOUR::Crossfade> xfade;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
Gtk::VBox vpacker;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
struct Point {
|
2017-07-01 12:42:24 -04:00
|
|
|
~Point();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
ArdourCanvas::Rectangle* box;
|
|
|
|
ArdourCanvas::PolyLine* curve;
|
|
|
|
double x;
|
|
|
|
double y;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
static const int32_t size;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
void move_to (double x, double y, double xfract, double yfract);
|
2007-01-10 11:19:13 -05:00
|
|
|
};
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-02-19 14:42:25 -05:00
|
|
|
struct PointSorter {
|
2017-07-01 12:42:24 -04:00
|
|
|
bool operator() (const CrossfadeEditor::Point* a, const CrossfadeEditor::Point *b) {
|
|
|
|
return a->x < b->x;
|
|
|
|
}
|
2007-01-10 11:19:13 -05:00
|
|
|
};
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
ArdourCanvas::Rectangle* toplevel;
|
|
|
|
ArdourCanvas::GtkCanvas* canvas;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
struct Half {
|
2017-07-01 12:42:24 -04:00
|
|
|
ArdourCanvas::PolyLine* line;
|
|
|
|
ArdourCanvas::Polygon* shading;
|
|
|
|
std::list<Point*> points;
|
|
|
|
ARDOUR::AutomationList normative_curve; /* 0 - 1.0, linear */
|
|
|
|
ARDOUR::AutomationList gain_curve; /* 0 - 2.0, gain mapping */
|
2017-07-17 14:12:33 -04:00
|
|
|
std::vector<ArdourWaveView::WaveView*> waves;
|
2017-07-01 12:42:24 -04:00
|
|
|
|
|
|
|
Half();
|
2007-01-10 11:19:13 -05:00
|
|
|
};
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
enum WhichFade {
|
|
|
|
In = 0,
|
|
|
|
Out = 1
|
|
|
|
};
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
Half fade[2];
|
|
|
|
WhichFade current;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
bool point_grabbed;
|
2009-05-12 13:03:42 -04:00
|
|
|
std::vector<Gtk::Button*> fade_out_buttons;
|
|
|
|
std::vector<Gtk::Button*> fade_in_buttons;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
Gtk::VBox vpacker2;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
Gtk::Button clear_button;
|
|
|
|
Gtk::Button revert_button;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
Gtk::ToggleButton audition_both_button;
|
|
|
|
Gtk::ToggleButton audition_left_dry_button;
|
|
|
|
Gtk::ToggleButton audition_left_button;
|
|
|
|
Gtk::ToggleButton audition_right_dry_button;
|
|
|
|
Gtk::ToggleButton audition_right_button;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
Gtk::ToggleButton preroll_button;
|
|
|
|
Gtk::ToggleButton postroll_button;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
Gtk::HBox roll_box;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
gint event_handler (GdkEvent*);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
bool canvas_event (GdkEvent* event);
|
|
|
|
bool point_event (GdkEvent* event, Point*);
|
|
|
|
bool curve_event (GdkEvent* event);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
void canvas_allocation (Gtk::Allocation&);
|
|
|
|
void add_control_point (double x, double y);
|
|
|
|
Point* make_point ();
|
|
|
|
void redraw ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
double effective_width () const { return canvas->get_allocation().get_width() - (2.0 * canvas_border); }
|
|
|
|
double effective_height () const { return canvas->get_allocation().get_height() - (2.0 * canvas_border); }
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
void clear ();
|
|
|
|
void reset ();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
double miny;
|
|
|
|
double maxy;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
Gtk::Table fade_in_table;
|
|
|
|
Gtk::Table fade_out_table;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
void build_presets ();
|
|
|
|
void apply_preset (Preset*);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
Gtk::RadioButton select_in_button;
|
|
|
|
Gtk::RadioButton select_out_button;
|
|
|
|
Gtk::HBox curve_button_box;
|
|
|
|
Gtk::HBox audition_box;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
void curve_select_clicked (WhichFade);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
double x_coordinate (double& xfract) const;
|
|
|
|
double y_coordinate (double& yfract) const;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-06-27 11:51:50 -04:00
|
|
|
void set (const ARDOUR::AutomationList& alist, WhichFade);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2010-04-21 21:40:33 -04:00
|
|
|
PBD::ScopedConnection* _peaks_ready_connection;
|
2009-12-19 15:26:31 -05:00
|
|
|
PBD::ScopedConnection state_connection;
|
2006-03-01 22:45:26 -05:00
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
void make_waves (std::shared_ptr<ARDOUR::AudioRegion>, WhichFade);
|
|
|
|
void peaks_ready (std::weak_ptr<ARDOUR::AudioRegion> r, WhichFade);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
void _apply_to (std::shared_ptr<ARDOUR::Crossfade> xf);
|
|
|
|
void setup (std::shared_ptr<ARDOUR::Crossfade>);
|
2007-01-10 11:19:13 -05:00
|
|
|
void cancel_audition ();
|
|
|
|
void audition_state_changed (bool);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
enum Audition {
|
|
|
|
Both,
|
|
|
|
Left,
|
|
|
|
Right
|
|
|
|
};
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
void audition_toggled ();
|
|
|
|
void audition_right_toggled ();
|
|
|
|
void audition_right_dry_toggled ();
|
|
|
|
void audition_left_toggled ();
|
|
|
|
void audition_left_dry_toggled ();
|
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
void audition (Audition);
|
2007-01-10 11:19:13 -05:00
|
|
|
void audition_both ();
|
|
|
|
void audition_left_dry ();
|
|
|
|
void audition_left ();
|
|
|
|
void audition_right_dry ();
|
|
|
|
void audition_right ();
|
|
|
|
|
2010-02-19 13:09:08 -05:00
|
|
|
void xfade_changed (const PBD::PropertyChange&);
|
2007-01-10 11:19:13 -05:00
|
|
|
|
|
|
|
void dump ();
|
2005-09-25 14:42:24 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* __gtk_ardour_xfade_edit_h__ */
|