24 #include <boost/scoped_array.hpp>
41 #include "canvas/rectangle.h"
42 #include "canvas/polygon.h"
43 #include "canvas/poly_line.h"
44 #include "canvas/line.h"
45 #include "canvas/text.h"
46 #include "canvas/xfade_curve.h"
47 #include "canvas/debug.h"
48 #include "canvas/utils.h"
49 #include "canvas/colors.h"
67 #define MUTED_ALPHA 48
83 , fade_in_trim_handle(0)
84 , fade_out_trim_handle(0)
85 , start_xfade_curve (0)
86 , start_xfade_rect (0)
87 , _start_xfade_visible (false)
90 , _end_xfade_visible (false)
91 , _amplitude_above_axis(1.0)
92 , trim_fade_in_drag_active(false)
93 , trim_fade_out_drag_active(false)
100 :
RegionView (parent, tv, r, spu, basic_color, recording, visibility)
104 , fade_in_trim_handle(0)
105 , fade_out_trim_handle(0)
106 , start_xfade_curve (0)
107 , start_xfade_rect (0)
108 , _start_xfade_visible (false)
109 , end_xfade_curve (0)
111 , _end_xfade_visible (false)
112 , _amplitude_above_axis(1.0)
113 , trim_fade_in_drag_active(false)
114 , trim_fade_out_drag_active(false)
123 , fade_in_trim_handle(0)
124 , fade_out_trim_handle(0)
125 , start_xfade_curve (0)
126 , start_xfade_rect (0)
127 , _start_xfade_visible (false)
128 , end_xfade_curve (0)
130 , _end_xfade_visible (false)
131 , _amplitude_above_axis (other._amplitude_above_axis)
132 , trim_fade_in_drag_active(false)
133 , trim_fade_out_drag_active(false)
155 fade_in_handle->set_outline_color (ArdourCanvas::rgba_to_color (0, 0, 0, 1.0));
162 fade_out_handle->set_outline_color (ArdourCanvas::rgba_to_color (0, 0, 0, 1.0));
188 const string line_name =
_region->
name() +
":gain";
204 for (vector<GhostRegion*>::iterator i =
ghosts.begin(); i !=
ghosts.end(); ++i) {
256 delete ((*i).second);
341 for (uint32_t n = 0; n <
waves.size(); ++n) {
342 waves[n]->gain_changed ();
352 str = string (
"*") + str;
356 str = string (
"!") + str;
374 if (what_changed.
contains (interesting_stuff)) {
376 for (uint32_t n = 0; n <
waves.size(); ++n) {
377 waves[n]->region_resized ();
380 for (vector<GhostRegion*>::iterator i =
ghosts.begin(); i !=
ghosts.end(); ++i) {
381 if ((agr = dynamic_cast<AudioGhostRegion*>(*i)) != 0) {
383 for (vector<WaveView*>::iterator w = agr->
waves.begin(); w != agr->
waves.end(); ++w) {
384 (*w)->region_resized ();
391 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
419 AnalysisFeatureList::const_iterator i;
421 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
423 for (i = analysis_features.begin(), l =
feature_lines.begin(); i != analysis_features.end() && l !=
feature_lines.end(); ++i, ++l) {
427 (*l).second->set (ArdourCanvas::Duple (x_pos, 2.0),
432 (*l).second->set (ArdourCanvas::Duple (x_pos, 2.0),
450 double const handle_pos = 0.0;
478 uint32_t wcnt =
waves.size();
480 for (uint32_t n = 0; n < wcnt; ++n) {
484 ht = ((height - 2 * wcnt) / (
double) wcnt);
489 gdouble yoff = n * (ht + 1);
491 waves[n]->set_height (ht);
492 waves[n]->set_y_position (yoff + 2);
509 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
516 (*l).second->set (ArdourCanvas::Duple (pos_x, 2.0),
519 (*l).second->set (ArdourCanvas::Duple (pos_x, 2.0),
520 ArdourCanvas::Duple (pos_x,
_height - 1));
558 double const handle_left = pwidth;
584 double effective_height;
595 Points::size_type pi;
600 points.assign (list->
size(), Duple());
602 for (x = list->
begin(), pi = 0; x != list->
end(); ++x, ++pi) {
603 points[pi].x = (pwidth * ((*x)->when/
length));
604 points[pi].y = effective_height - ((*x)->value * (effective_height - 1.));
670 double effective_height;
681 Points::size_type pi;
686 points.assign (list->
size(), Duple());
688 for (x = list->
begin(), pi = 0; x != list->
end(); ++x, ++pi) {
690 points[pi].y = effective_height - ((*x)->value * (effective_height - 1.));
733 if (points.size() < 2) {
754 start_xfade_rect->set (ArdourCanvas::Rect (0.0, 0.0, rect_width, effective_height));
760 Points::size_type npoints;
769 npoints = points.size();
770 ipoints.assign (npoints, Duple());
772 for (Points::size_type i = 0, pci = 0; i < npoints; ++i, ++pci) {
773 ArdourCanvas::Duple &p (ipoints[pci]);
775 p.y = effective_height - points[pci].y;
785 npoints = inverse->
size();
786 ipoints.assign (npoints, Duple());
789 Points::size_type pi;
792 for (x = inverse->
begin(), pi = 0; x != inverse->
end(); ++x, ++pi) {
793 ArdourCanvas::Duple& p (ipoints[pi]);
794 p.x = (rect_width * ((*x)->when/
length));
795 p.y = effective_height - ((*x)->value * (effective_height));
820 double rect_edge,
double rect_width)
822 if (points.size() < 2) {
844 end_xfade_rect->set (ArdourCanvas::Rect (rect_edge, 0.0, rect_edge + rect_width, effective_height));
850 Points::size_type npoints;
859 npoints = points.size();
860 ipoints.assign (npoints, Duple());
862 Points::size_type pci;
864 for (pci = 0; pci < npoints; ++pci) {
865 ArdourCanvas::Duple &p (ipoints[pci]);
866 p.y = effective_height - points[pci].y;
876 npoints = inverse->
size();
877 ipoints.assign (npoints, Duple());
882 Points::size_type pi;
885 for (x = inverse->
begin(), pi = 0; x != inverse->
end(); ++x, ++pi) {
886 ArdourCanvas::Duple& p (ipoints[pi]);
887 p.x = (rect_width * ((*x)->when/
length)) + rend;
888 p.y = effective_height - ((*x)->value * (effective_height));
962 for (uint32_t n = 0; n <
waves.size(); ++n) {
963 waves[n]->set_samples_per_pixel (fpp);
977 for (uint32_t n=0; n <
waves.size(); ++n) {
978 waves[n]->set_amplitude_above_axis (a);
1016 for (uint32_t n = 0; n <
waves.size(); ++n) {
1025 for (uint32_t n = 0; n <
waves.size(); ++n) {
1077 for (uint32_t n = 0; n < nchans.
n_audio(); ++n) {
1087 for (uint32_t i = 0; i < nchans.
n_audio(); ++i) {
1091 for (uint32_t n = 0; n < nchans.
n_audio(); ++n) {
1124 uint32_t nwaves = std::min (nchans,
audio_region()->n_channels());
1133 gdouble yoff = which * ht;
1138 wave->set_channel (which);
1139 wave->set_y_position (yoff);
1140 wave->set_height (ht);
1142 wave->set_show_zero_line (
true);
1144 wave->set_start_shift (1.0);
1158 vector<ArdourCanvas::WaveView*> v;
1172 if (which < nchans) {
1180 for (n = 0; n < nchans; ++n) {
1186 if (n == nwaves &&
waves.empty()) {
1222 item->canvas_to_item (x, y);
1278 for (uint32_t n = 0; n < nchans; ++n) {
1287 wave->set_channel (n);
1291 ghost->
waves.push_back(wave);
1297 ghosts.push_back (ghost);
1399 ArdourCanvas::Color fill;
1400 ArdourCanvas::Color outline;
1429 for (vector<ArdourCanvas::WaveView*>::iterator w = waves_to_color.begin(); w != waves_to_color.end(); ++w) {
1430 (*w)->set_fill_color (fill);
1431 (*w)->set_outline_color (outline);
1432 (*w)->set_clip_color (clip);
1433 (*w)->set_zero_color (zero);
1500 ArdourCanvas::Line* canvas_item =
new ArdourCanvas::Line(
group);
1503 canvas_item->set (ArdourCanvas::Duple (-1.0, 2.0),
1506 canvas_item->raise_to_top ();
1507 canvas_item->show ();
1509 canvas_item->set_data (
"regionview",
this);
1521 AnalysisFeatureList::const_iterator i;
1522 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
1524 for (i = analysis_features.begin(), l =
feature_lines.begin(); i != analysis_features.end() && l !=
feature_lines.end(); ++i, ++l) {
1526 float *pos =
new float;
1530 ArdourCanvas::Duple (*pos, 2.0),
1534 (*l).second->set_data (
"position", pos);
1543 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
1549 float* pos = (
float*) (*l).second->get_data (
"position");
1551 if (rint(new_pos) == rint(*pos)) {
1567 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
1572 float *line_pos = (
float*) (*l).second->get_data (
"position");
1574 if (rint(pos) == rint(*line_pos)) {
1623 if (p ==
"show-waveforms") {
ArdourCanvas::Container & canvas_group() const
void set_duration(double units)
void envelope_active_changed()
ArdourCanvas::Color color(const std::string &, bool *failed=0) const
void reset_width_dependent_items(double pixel_width)
LIBARDOUR_API PBD::PropertyDescriptor< bool > fade_out_active
void peaks_ready_handler(uint32_t)
static PBD::Signal1< void, RegionView * > RegionViewGoingAway
boost::shared_ptr< AudioRegionGainLine > gain_line
void update_coverage_frames(LayerDisplay)
ArdourCanvas::Rectangle * fade_out_handle
fade out handle, or 0
virtual void region_resized(const PBD::PropertyChange &)
PublicEditor & editor() const
boost::shared_ptr< ARDOUR::Region > _region
static double NAME_HIGHLIGHT_THRESH
virtual Editing::MouseMode current_mouse_mode() const =0
void region_scale_amplitude_changed()
void set_envelope_active(bool yn)
ArdourCanvas::Rectangle * fade_out_trim_handle
fade out trim handle, or 0
void temporarily_hide_envelope()
Dangerous!
shared_ptr< T > dynamic_pointer_cast(shared_ptr< U > const &r)
void view_to_model_coord(double &x, double &y) const
void reset_fade_out_shape_width(boost::shared_ptr< ARDOUR::AudioRegion > ar, framecnt_t, bool drag_active=false)
boost::shared_ptr< AutomationList > fade_in()
void remove_gain_point_event(ArdourCanvas::Item *item, GdkEvent *event)
void add_command(Command *const cmd)
std::vector< ArdourCanvas::WaveView * > waves
boost::shared_ptr< AutomationList > fade_out()
ArdourCanvas::Rectangle * end_xfade_rect
virtual bool canvas_fade_in_handle_event(GdkEvent *event, ArdourCanvas::Item *, AudioRegionView *, bool)=0
virtual std::string get_item_name() const
virtual double sample_to_pixel(framepos_t frame) const =0
ArdourCanvas::Rectangle * fade_in_handle
fade in handle, or 0
ArdourCanvas::Text * name_text
std::string make_name() const
SessionConfiguration config
void init(bool wait_for_data)
void create_one_wave(uint32_t, bool)
boost::shared_ptr< ARDOUR::AudioRegion > audio_region() const
LIBARDOUR_API PBD::PropertyDescriptor< framepos_t > start
uint32_t current_height() const
virtual void drag_start()
framecnt_t frame_rate() const
#define ENSURE_GUI_THREAD(obj, method,...)
void remove_transient(float pos)
void set_fade_visibility(bool)
void update_envelope_visibility()
#define UINT_RGBA_CHANGE_A(x, a)
bool trim_fade_out_drag_active
virtual void update_coverage_frames(LayerDisplay)
void update_transient(float old_pos, float new_pos)
void region_changed(const PBD::PropertyChange &)
void setup_fade_handle_positions()
virtual bool canvas_end_xfade_event(GdkEvent *event, ArdourCanvas::Item *, AudioRegionView *)=0
void transients_changed()
AnalysisFeatureList transients()
void set_samples_per_pixel(double)
virtual bool canvas_fade_out_handle_event(GdkEvent *event, ArdourCanvas::Item *, AudioRegionView *, bool)=0
boost::shared_ptr< AutomationList > envelope()
Trimmable::CanTrim can_trim() const
void set_item_name(std::string, void *)
LIBARDOUR_API RCConfiguration * Config
framepos_t get_fade_out_shape_width()
boost::shared_ptr< ARDOUR::Region > region() const
std::list< framepos_t > AnalysisFeatureList
void redraw_start_xfade()
ArdourCanvas::XFadeCurve * start_xfade_curve
void add_gain_point_event(ArdourCanvas::Item *item, GdkEvent *event, bool with_guard_points)
virtual bool canvas_feature_line_event(GdkEvent *event, ArdourCanvas::Item *, RegionView *)=0
virtual void init(bool wait_for_data)
std::vector< ArdourCanvas::WaveView * > tmp_waves
see ::create_waves()
boost::shared_ptr< AudioSource > audio_source(uint32_t n=0) const
ARDOUR::Session * session() const
void set_some_waveform_colors(std::vector< ArdourCanvas::WaveView * > &waves_to_color)
boost::shared_ptr< ARDOUR::Track > track() const
virtual void begin_reversible_command(std::string cmd_name)=0
virtual void set_frame_color()
virtual void commit_reversible_command()=0
void reset_fade_in_shape()
LIBARDOUR_API PBD::PropertyDescriptor< boost::shared_ptr< AutomationList > > fade_out
LIBARDOUR_API PBD::PropertyDescriptor< boost::shared_ptr< AutomationList > > fade_in
std::vector< PBD::ScopedConnection * > _data_ready_connections
ArdourCanvas::XFadeCurve * end_xfade_curve
virtual void thaw_after_trim()
void show_region_editor()
void fade_out_active_changed()
ArdourCanvas::Rectangle * frame_handle_start
`frame' (fade) handle for the start of the item, or 0
void redraw_start_xfade_to(boost::shared_ptr< ARDOUR::AudioRegion >, framecnt_t, ArdourCanvas::Points &, double, double)
virtual void region_muted()
virtual void set_current_trimmable(boost::shared_ptr< ARDOUR::Trimmable >)=0
void set_amplitude_above_axis(gdouble spp)
EventList::size_type size() const
framepos_t get_fade_in_shape_width()
bool _start_xfade_visible
virtual void reset_width_dependent_items(double pixel_width)
PBD::Signal1< void, std::string > ParameterChanged
GhostRegion * add_ghost(TimeAxisView &)
void region_resized(const PBD::PropertyChange &)
LIBARDOUR_API RuntimeProfile * Profile
void set_name_text(const std::string &)
framepos_t position() const
void call_slot(EventLoop::InvalidationRecord *, const boost::function< void()> &)
std::list< std::pair< framepos_t, ArdourCanvas::Line * > > feature_lines
void reset_fade_out_shape()
static PublicEditor & instance()
virtual void remove_transient(framepos_t)
std::vector< ArdourCanvas::WaveView * > waves
uint32_t n_channels() const
boost::shared_ptr< AutomationList > inverse_fade_in()
ArdourCanvas::Rectangle * frame
virtual void set_height(double)
ArdourCanvas::Rectangle * fade_in_trim_handle
fade in trim handle, or 0
double _amplitude_above_axis
void reset_fade_in_shape_width(boost::shared_ptr< ARDOUR::AudioRegion > ar, framecnt_t, bool drag_active=false)
virtual bool canvas_start_xfade_event(GdkEvent *event, ArdourCanvas::Item *, AudioRegionView *)=0
static UIConfiguration * config()
std::vector< GhostRegion * > ghosts
void setup_waveform_visibility()
virtual void set_samples_per_pixel(double)
ARDOUR::AutomationList::iterator model() const
virtual void region_changed(const PBD::PropertyChange &)
ArdourCanvas::Rectangle * frame_handle_end
`frame' (fade) handle for the end of the item, or 0
virtual framepos_t pixel_to_sample(double pixel) const =0
EventList::const_iterator const_iterator
static double const handle_size
void unhide_envelope()
Dangerous!
void set_waveform_colors()
ArdourCanvas::Rectangle * start_xfade_rect
ArdourCanvas::Container * group
bool contains(PropertyDescriptor< T > p) const
framecnt_t length() const
void set_line_color(uint32_t)
void region_sync_changed()
void fade_in_active_changed()
virtual int update_transient(framepos_t, framepos_t)
void redraw_end_xfade_to(boost::shared_ptr< ARDOUR::AudioRegion >, framecnt_t, ArdourCanvas::Points &, double, double, double)
boost::shared_ptr< AutomationList > inverse_fade_out()
LIBGTKMM2EXT_API int pixel_width(const std::string &str, Pango::FontDescription &font)
void parameter_changed(std::string const &)
virtual void add(double when, double value, bool with_guards=true, bool with_default=true)
AudioRegionView(ArdourCanvas::Container *, RouteTimeAxisView &, boost::shared_ptr< ARDOUR::AudioRegion >, double initial_samples_per_pixel, uint32_t base_color)
void remove_visibility(VisibleAspects)
virtual bool canvas_wave_view_event(GdkEvent *event, ArdourCanvas::Item *, RegionView *)=0
LIBARDOUR_API PBD::PropertyDescriptor< float > scale_amplitude
LIBARDOUR_API PBD::PropertyDescriptor< bool > valid_transients
LIBARDOUR_API PBD::PropertyDescriptor< bool > envelope_active
virtual void set_current_movable(boost::shared_ptr< ARDOUR::Movable >)=0
virtual void set_colors()
LIBARDOUR_API PBD::PropertyDescriptor< bool > fade_in_active
LIBARDOUR_API PBD::PropertyChange bounds_change
std::string string_compose(const std::string &fmt, const T1 &o1)
LIBARDOUR_API PBD::PropertyDescriptor< boost::shared_ptr< AutomationList > > envelope
static double NAME_HIGHLIGHT_SIZE
void set_visibility(VisibleAspects)
ArdourCanvas::Container * group
LIBARDOUR_API PBD::PropertyDescriptor< framecnt_t > length
bool trim_fade_in_drag_active
LIBARDOUR_API PBD::PropertyDescriptor< bool > color