2007-04-26 16:54:31 -04:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 2000-2007 Paul Davis
|
2007-04-26 16:54:31 -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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "evoral/Curve.hpp"
|
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"
|
2005-11-14 22:12:16 -05:00
|
|
|
#include "canvas.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
namespace ARDOUR
|
|
|
|
{
|
|
|
|
class Session;
|
2007-06-27 11:51:50 -04:00
|
|
|
class AutomationList;
|
2005-09-25 14:42:24 -04:00
|
|
|
class Crossfade;
|
|
|
|
}
|
|
|
|
|
|
|
|
class CrossfadeEditor : public ArdourDialog
|
|
|
|
{
|
|
|
|
public:
|
2009-12-17 13:24:23 -05:00
|
|
|
CrossfadeEditor (ARDOUR::Session*, boost::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
|
|
|
|
2007-01-10 11:19:13 -05: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 {
|
|
|
|
double x;
|
|
|
|
double y;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
|
|
|
PresetPoint (double a, double b)
|
2007-01-10 11:19:13 -05:00
|
|
|
: x (a), y (b) {}
|
|
|
|
};
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-12 13:03:42 -04:00
|
|
|
struct Preset : public std::list<PresetPoint> {
|
2008-12-12 09:43:24 -05:00
|
|
|
const char* name;
|
2007-04-11 09:07:51 -04:00
|
|
|
const char* image_name;
|
2008-12-12 09:43:24 -05: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
|
|
|
|
|
|
|
protected:
|
|
|
|
bool on_key_press_event (GdkEventKey*);
|
|
|
|
bool on_key_release_event (GdkEventKey*);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
private:
|
2007-01-10 11:19:13 -05:00
|
|
|
boost::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 {
|
|
|
|
~Point();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
ArdourCanvas::SimpleRect* box;
|
|
|
|
ArdourCanvas::Line* curve;
|
|
|
|
double x;
|
|
|
|
double y;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
static const int32_t size;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
void move_to (double x, double y, double xfract, double yfract);
|
|
|
|
};
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-02-19 14:42:25 -05:00
|
|
|
struct PointSorter {
|
2007-01-10 11:19:13 -05:00
|
|
|
bool operator() (const CrossfadeEditor::Point* a, const CrossfadeEditor::Point *b) {
|
|
|
|
return a->x < b->x;
|
|
|
|
}
|
|
|
|
};
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
ArdourCanvas::SimpleRect* toplevel;
|
|
|
|
ArdourCanvas::Canvas* canvas;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
struct Half {
|
|
|
|
ArdourCanvas::Line* line;
|
|
|
|
ArdourCanvas::Polygon* shading;
|
2009-05-12 13:03:42 -04:00
|
|
|
std::list<Point*> points;
|
2007-06-27 11:51:50 -04:00
|
|
|
ARDOUR::AutomationList normative_curve; /* 0 - 1.0, linear */
|
|
|
|
ARDOUR::AutomationList gain_curve; /* 0 - 2.0, gain mapping */
|
2009-05-12 13:03:42 -04:00
|
|
|
std::vector<ArdourCanvas::WaveView*> waves;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
Half();
|
|
|
|
};
|
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
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
void make_waves (boost::shared_ptr<ARDOUR::AudioRegion>, WhichFade);
|
2009-12-17 13:24:23 -05:00
|
|
|
void peaks_ready (boost::weak_ptr<ARDOUR::AudioRegion> r, WhichFade);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-10 11:19:13 -05:00
|
|
|
void _apply_to (boost::shared_ptr<ARDOUR::Crossfade> xf);
|
|
|
|
void setup (boost::shared_ptr<ARDOUR::Crossfade>);
|
|
|
|
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__ */
|