2 Copyright (C) 2001-2006 Paul Davis
4 This program is free software; you can r>edistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <boost/scoped_ptr.hpp>
27 #include <gtkmm2ext/gtk_ui.h>
29 #include "ardour/playlist.h"
30 #include "ardour/audioregion.h"
31 #include "ardour/audiosource.h"
32 #include "ardour/profile.h"
33 #include "ardour/session.h"
35 #include "pbd/memento_command.h"
36 #include "pbd/stacktrace.h"
38 #include "evoral/Curve.hpp"
40 #include "streamview.h"
41 #include "audio_region_view.h"
42 #include "audio_time_axis.h"
43 #include "simplerect.h"
44 #include "simpleline.h"
46 #include "public_editor.h"
47 #include "audio_region_editor.h"
48 #include "audio_streamview.h"
49 #include "region_gain_line.h"
50 #include "control_point.h"
51 #include "ghostregion.h"
52 #include "audio_time_axis.h"
54 #include "rgb_macros.h"
55 #include "gui_thread.h"
56 #include "ardour_ui.h"
60 #define MUTED_ALPHA 10
63 using namespace ARDOUR;
65 using namespace Editing;
66 using namespace ArdourCanvas;
68 static const int32_t sync_mark_width = 9;
69 static double const handle_size = 6; /* height of fade handles */
71 AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, boost::shared_ptr<AudioRegion> r, double spu,
72 Gdk::Color const & basic_color)
73 : RegionView (parent, tv, r, spu, basic_color)
79 , fade_position_line(0)
82 , start_xfade_rect (0)
83 , _start_xfade_visible (false)
87 , _end_xfade_visible (false)
88 , _amplitude_above_axis(1.0)
91 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&AudioRegionView::parameter_changed, this, _1), gui_context());
94 AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, boost::shared_ptr<AudioRegion> r, double spu,
95 Gdk::Color const & basic_color, bool recording, TimeAxisViewItem::Visibility visibility)
96 : RegionView (parent, tv, r, spu, basic_color, recording, visibility)
102 , fade_position_line(0)
104 , start_xfade_out (0)
105 , start_xfade_rect (0)
106 , _start_xfade_visible (false)
110 , _end_xfade_visible (false)
111 , _amplitude_above_axis(1.0)
114 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&AudioRegionView::parameter_changed, this, _1), gui_context());
117 AudioRegionView::AudioRegionView (const AudioRegionView& other, boost::shared_ptr<AudioRegion> other_region)
118 : RegionView (other, boost::shared_ptr<Region> (other_region))
123 , fade_position_line(0)
125 , start_xfade_out (0)
126 , start_xfade_rect (0)
127 , _start_xfade_visible (false)
131 , _end_xfade_visible (false)
132 , _amplitude_above_axis (other._amplitude_above_axis)
138 UINT_TO_RGBA (other.fill_color, &r, &g, &b, &a);
139 c.set_rgb_p (r/255.0, g/255.0, b/255.0);
143 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&AudioRegionView::parameter_changed, this, _1), gui_context());
147 AudioRegionView::init (Gdk::Color const & basic_color, bool wfd)
149 // FIXME: Some redundancy here with RegionView::init. Need to figure out
150 // where order is important and where it isn't...
152 RegionView::init (basic_color, wfd);
154 _amplitude_above_axis = 1.0;
156 compute_colors (basic_color);
160 fade_in_shape = new ArdourCanvas::Polygon (*group);
161 fade_in_shape->property_fill_color_rgba() = fade_color;
162 fade_in_shape->set_data ("regionview", this);
164 fade_out_shape = new ArdourCanvas::Polygon (*group);
165 fade_out_shape->property_fill_color_rgba() = fade_color;
166 fade_out_shape->set_data ("regionview", this);
169 fade_in_handle = new ArdourCanvas::SimpleRect (*group);
170 fade_in_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fill_color, 0);
171 fade_in_handle->property_outline_color_rgba() = RGBA_TO_UINT (0, 0, 0, 0);
173 fade_in_handle->set_data ("regionview", this);
175 fade_out_handle = new ArdourCanvas::SimpleRect (*group);
176 fade_out_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fill_color, 0);
177 fade_out_handle->property_outline_color_rgba() = RGBA_TO_UINT (0, 0, 0, 0);
179 fade_out_handle->set_data ("regionview", this);
181 fade_position_line = new ArdourCanvas::SimpleLine (*group);
182 fade_position_line->property_color_rgba() = 0xBBBBBBAA;
183 fade_position_line->property_y1() = 7;
184 fade_position_line->property_y2() = _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1;
186 fade_position_line->hide();
189 setup_fade_handle_positions ();
191 if (!trackview.session()->config.get_show_region_fades()) {
192 set_fade_visibility (false);
195 const string line_name = _region->name() + ":gain";
197 if (!Profile->get_sae()) {
198 gain_line.reset (new AudioRegionGainLine (line_name, *this, *group, audio_region()->envelope()));
201 update_envelope_visibility ();
204 set_height (trackview.current_height());
207 region_sync_changed ();
209 region_resized (ARDOUR::bounds_change);
210 set_waveview_data_src();
212 envelope_active_changed ();
213 fade_in_active_changed ();
214 fade_out_active_changed ();
216 reset_width_dependent_items (_pixel_width);
218 fade_in_shape->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_event), fade_in_shape, this));
219 if (fade_in_handle) {
220 fade_in_handle->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_handle_event), fade_in_handle, this));
223 fade_out_shape->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_event), fade_out_shape, this));
225 if (fade_out_handle) {
226 fade_out_handle->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_handle_event), fade_out_handle, this));
231 setup_waveform_visibility ();
232 setup_waveform_shape ();
233 setup_waveform_scale ();
235 /* XXX sync mark drag? */
238 AudioRegionView::~AudioRegionView ()
240 in_destructor = true;
242 RegionViewGoingAway (this); /* EMIT_SIGNAL */
244 for (vector<GnomeCanvasWaveViewCache *>::iterator cache = wave_caches.begin(); cache != wave_caches.end() ; ++cache) {
245 gnome_canvas_waveview_cache_destroy (*cache);
248 for (vector<ScopedConnection*>::iterator i = _data_ready_connections.begin(); i != _data_ready_connections.end(); ++i) {
252 for (list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator i = feature_lines.begin(); i != feature_lines.end(); ++i) {
253 delete ((*i).second);
256 /* all waveviews etc will be destroyed when the group is destroyed */
259 boost::shared_ptr<ARDOUR::AudioRegion>
260 AudioRegionView::audio_region() const
262 // "Guaranteed" to succeed...
263 return boost::dynamic_pointer_cast<AudioRegion>(_region);
267 AudioRegionView::region_changed (const PropertyChange& what_changed)
269 ENSURE_GUI_THREAD (*this, &AudioRegionView::region_changed, what_changed);
270 cerr << "AudioRegionView::region_changed() called" << endl;
272 RegionView::region_changed (what_changed);
274 if (what_changed.contains (ARDOUR::Properties::scale_amplitude)) {
275 region_scale_amplitude_changed ();
277 if (what_changed.contains (ARDOUR::Properties::fade_in)) {
278 cerr << region()->name() << " in changed\n";
279 stacktrace (cerr, 40);
282 if (what_changed.contains (ARDOUR::Properties::fade_out)) {
283 cerr << region()->name() << " out changed\n";
286 if (what_changed.contains (ARDOUR::Properties::fade_in_active)) {
287 cerr << region()->name() << " in active changed\n";
288 fade_in_active_changed ();
290 if (what_changed.contains (ARDOUR::Properties::fade_out_active)) {
291 cerr << region()->name() << " out active changed\n";
292 fade_out_active_changed ();
294 if (what_changed.contains (ARDOUR::Properties::fade_in_is_xfade)) {
295 cerr << region()->name() << " in is xfade changed\n";
298 if (what_changed.contains (ARDOUR::Properties::fade_out_is_xfade)) {
299 cerr << region()->name() << " out is xfade changed\n";
302 if (what_changed.contains (ARDOUR::Properties::envelope_active)) {
303 envelope_active_changed ();
305 if (what_changed.contains (ARDOUR::Properties::valid_transients)) {
306 transients_changed ();
311 AudioRegionView::fade_in_changed ()
313 reset_fade_in_shape ();
317 AudioRegionView::fade_out_changed ()
319 reset_fade_out_shape ();
323 AudioRegionView::fade_in_active_changed ()
325 if (audio_region()->fade_in_active()) {
326 fade_in_shape->property_fill_color_rgba() = RGBA_TO_UINT(45,45,45,90); // FIXME make a themeable colour
327 fade_in_shape->property_width_pixels() = 1;
329 fade_in_shape->property_fill_color_rgba() = RGBA_TO_UINT(45,45,45,20); // FIXME make a themeable colour
330 fade_in_shape->property_width_pixels() = 1;
335 AudioRegionView::fade_out_active_changed ()
337 if (audio_region()->fade_out_active()) {
338 fade_out_shape->property_fill_color_rgba() = RGBA_TO_UINT(45,45,45,90); // FIXME make a themeable colour
339 fade_out_shape->property_width_pixels() = 1;
341 fade_out_shape->property_fill_color_rgba() = RGBA_TO_UINT(45,45,45,20); // FIXME make a themeable colour
342 fade_out_shape->property_width_pixels() = 1;
348 AudioRegionView::region_scale_amplitude_changed ()
350 ENSURE_GUI_THREAD (*this, &AudioRegionView::region_scale_amplitude_changed)
352 for (uint32_t n = 0; n < waves.size(); ++n) {
353 // force a reload of the cache
354 waves[n]->property_data_src() = _region.get();
359 AudioRegionView::region_renamed ()
361 std::string str = RegionView::make_name ();
363 if (audio_region()->speed_mismatch (trackview.session()->frame_rate())) {
364 str = string ("*") + str;
367 if (_region->muted()) {
368 str = string ("!") + str;
371 set_item_name (str, this);
376 AudioRegionView::region_resized (const PropertyChange& what_changed)
378 AudioGhostRegion* agr;
380 RegionView::region_resized(what_changed);
381 PropertyChange interesting_stuff;
383 interesting_stuff.add (ARDOUR::Properties::start);
384 interesting_stuff.add (ARDOUR::Properties::length);
386 if (what_changed.contains (interesting_stuff)) {
388 for (uint32_t n = 0; n < waves.size(); ++n) {
389 waves[n]->property_region_start() = _region->start();
392 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
393 if ((agr = dynamic_cast<AudioGhostRegion*>(*i)) != 0) {
395 for (vector<WaveView*>::iterator w = agr->waves.begin(); w != agr->waves.end(); ++w) {
396 (*w)->property_region_start() = _region->start();
401 /* hide transient lines that extend beyond the region end */
403 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
405 for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
406 if (l->first > _region->length() - 1) {
416 AudioRegionView::reset_width_dependent_items (double pixel_width)
418 RegionView::reset_width_dependent_items(pixel_width);
419 assert(_pixel_width == pixel_width);
421 if (fade_in_handle) {
422 if (pixel_width <= 6.0 || _height < 5.0 || !trackview.session()->config.get_show_region_fades()) {
423 fade_in_handle->hide();
424 fade_out_handle->hide();
427 fade_in_handle->show();
428 fade_out_handle->show();
432 AnalysisFeatureList analysis_features = _region->transients();
433 AnalysisFeatureList::const_iterator i;
435 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
437 for (i = analysis_features.begin(), l = feature_lines.begin(); i != analysis_features.end() && l != feature_lines.end(); ++i, ++l) {
439 float x_pos = trackview.editor().frame_to_pixel (*i);
441 ArdourCanvas::Points points;
442 points.push_back(Gnome::Art::Point(x_pos, 2.0)); // first x-coord needs to be a non-normal value
443 points.push_back(Gnome::Art::Point(x_pos, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1));
446 (*l).second->property_points() = points;
449 reset_fade_shapes ();
453 AudioRegionView::region_muted ()
455 RegionView::region_muted();
457 for (uint32_t n=0; n < waves.size(); ++n) {
458 if (_region->muted()) {
459 waves[n]->property_wave_color() = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_WaveForm.get(), MUTED_ALPHA);
461 waves[n]->property_wave_color() = ARDOUR_UI::config()->canvasvar_WaveForm.get();
467 AudioRegionView::setup_fade_handle_positions()
469 /* position of fade handle offset from the top of the region view */
470 double const handle_pos = 2;
472 if (fade_in_handle) {
473 fade_in_handle->property_y1() = handle_pos;
474 fade_in_handle->property_y2() = handle_pos + handle_size;
477 if (fade_out_handle) {
478 fade_out_handle->property_y1() = handle_pos;
479 fade_out_handle->property_y2() = handle_pos + handle_size;
484 AudioRegionView::set_height (gdouble height)
486 RegionView::set_height (height);
488 uint32_t wcnt = waves.size();
490 for (uint32_t n = 0; n < wcnt; ++n) {
493 if (height < NAME_HIGHLIGHT_THRESH) {
494 ht = ((height - 2 * wcnt) / (double) wcnt);
496 ht = (((height - 2 * wcnt) - NAME_HIGHLIGHT_SIZE) / (double) wcnt);
499 gdouble yoff = n * (ht + 1);
501 waves[n]->property_height() = ht;
502 waves[n]->property_y() = yoff + 2;
507 if ((height/wcnt) < NAME_HIGHLIGHT_THRESH) {
510 update_envelope_visibility ();
513 gain_line->set_height ((uint32_t) rint (height - NAME_HIGHLIGHT_SIZE) - 2);
516 reset_fade_shapes ();
518 /* Update hights for any active feature lines */
519 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
521 for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
523 float pos_x = trackview.editor().frame_to_pixel((*l).first);
525 ArdourCanvas::Points points;
527 points.push_back(Gnome::Art::Point(pos_x, 2.0)); // first x-coord needs to be a non-normal value
528 points.push_back(Gnome::Art::Point(pos_x, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1));
530 (*l).second->property_points() = points;
533 if (fade_position_line) {
535 if (height < NAME_HIGHLIGHT_THRESH) {
536 fade_position_line->property_y2() = _height - 1;
539 fade_position_line->property_y2() = _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1;
544 name_pixbuf->raise_to_top();
549 AudioRegionView::reset_fade_shapes ()
551 reset_fade_in_shape ();
552 reset_fade_out_shape ();
556 AudioRegionView::reset_fade_in_shape ()
558 reset_fade_in_shape_width ((framecnt_t) audio_region()->fade_in()->back()->when);
562 AudioRegionView::reset_fade_in_shape_width (framecnt_t width)
568 if (audio_region()->fade_in_is_xfade()) {
569 if (fade_in_handle) {
570 fade_in_handle->hide ();
571 fade_in_shape->hide ();
573 redraw_start_xfade ();
576 if (start_xfade_in) {
577 start_xfade_in->hide ();
578 start_xfade_out->hide ();
579 start_xfade_rect->hide ();
580 _start_xfade_visible = false;
584 if (fade_in_handle == 0) {
588 fade_in_handle->show ();
590 /* smallest size for a fade is 64 frames */
592 width = std::max ((framecnt_t) 64, width);
596 /* round here to prevent little visual glitches with sub-pixel placement */
597 double const pwidth = rint (width / samples_per_unit);
598 uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth);
602 fade_in_shape->hide();
603 fade_in_handle->hide();
607 double const handle_center = pwidth;
609 /* Put the fade in handle so that its left side is at the end-of-fade line */
610 fade_in_handle->property_x1() = handle_center;
611 fade_in_handle->property_x2() = handle_center + handle_size;
614 fade_in_shape->hide();
618 if (trackview.session()->config.get_show_region_fades()) {
619 fade_in_shape->show();
622 float curve[npoints];
623 audio_region()->fade_in()->curve().get_vector (0, audio_region()->fade_in()->back()->when, curve, npoints);
625 points = get_canvas_points ("fade in shape", npoints + 3);
627 if (_height >= NAME_HIGHLIGHT_THRESH) {
628 h = _height - NAME_HIGHLIGHT_SIZE - 2;
633 /* points *MUST* be in anti-clockwise order */
636 double xdelta = pwidth/npoints;
638 for (pi = 0, pc = 0; pc < npoints; ++pc) {
639 (*points)[pi].set_x(1 + (pc * xdelta));
640 (*points)[pi++].set_y(2 + (h - (curve[pc] * h)));
645 (*points)[pi].set_x(pwidth);
646 (*points)[pi++].set_y(2);
648 (*points)[pi].set_x(1);
649 (*points)[pi++].set_y(2);
651 /* connect the dots ... */
653 (*points)[pi] = (*points)[0];
655 fade_in_shape->property_points() = *points;
658 /* ensure trim handle stays on top */
659 if (frame_handle_start) {
660 frame_handle_start->raise_to_top();
665 AudioRegionView::reset_fade_out_shape ()
667 reset_fade_out_shape_width ((framecnt_t) audio_region()->fade_out()->back()->when);
671 AudioRegionView::reset_fade_out_shape_width (framecnt_t width)
673 if (dragging() && audio_region()->fade_out_is_xfade()) {
674 /* we hide xfades while dragging regions */
678 if (audio_region()->fade_out_is_xfade()) {
679 if (fade_out_handle) {
680 fade_out_handle->hide ();
681 fade_out_shape->hide ();
687 end_xfade_in->hide ();
688 end_xfade_out->hide ();
689 end_xfade_rect->hide ();
690 _end_xfade_visible = false;
694 if (fade_out_handle == 0) {
698 fade_out_handle->show ();
700 /* smallest size for a fade is 64 frames */
702 width = std::max ((framecnt_t) 64, width);
706 /* round here to prevent little visual glitches with sub-pixel placement */
707 double const pwidth = rint (width / samples_per_unit);
708 uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth);
712 fade_out_shape->hide();
713 fade_out_handle->hide();
717 double const handle_center = (_region->length() - width) / samples_per_unit;
719 /* Put the fade out handle so that its right side is at the end-of-fade line;
720 * it's `one out' for precise pixel accuracy.
722 fade_out_handle->property_x1() = handle_center - 5;
723 fade_out_handle->property_x2() = handle_center + 1;
725 /* don't show shape if its too small */
728 fade_out_shape->hide();
732 if (trackview.session()->config.get_show_region_fades()) {
733 fade_out_shape->show();
736 float curve[npoints];
737 audio_region()->fade_out()->curve().get_vector (0, audio_region()->fade_out()->back()->when, curve, npoints);
739 if (_height >= NAME_HIGHLIGHT_THRESH) {
740 h = _height - NAME_HIGHLIGHT_SIZE - 2;
745 /* points *MUST* be in anti-clockwise order */
747 points = get_canvas_points ("fade out shape", npoints + 3);
750 double xdelta = pwidth/npoints;
752 for (pi = 0, pc = 0; pc < npoints; ++pc) {
753 (*points)[pi].set_x(_pixel_width - pwidth + (pc * xdelta));
754 (*points)[pi++].set_y(2 + (h - (curve[pc] * h)));
759 (*points)[pi].set_x(_pixel_width);
760 (*points)[pi++].set_y(h);
762 (*points)[pi].set_x(_pixel_width);
763 (*points)[pi++].set_y(2);
765 /* connect the dots ... */
767 (*points)[pi] = (*points)[0];
769 fade_out_shape->property_points() = *points;
772 /* ensure trim handle stays on top */
773 if (frame_handle_end) {
774 frame_handle_end->raise_to_top();
779 AudioRegionView::set_samples_per_unit (gdouble spu)
781 RegionView::set_samples_per_unit (spu);
783 if (Config->get_show_waveforms ()) {
784 for (uint32_t n = 0; n < waves.size(); ++n) {
785 waves[n]->property_samples_per_unit() = spu;
793 reset_fade_shapes ();
797 AudioRegionView::set_amplitude_above_axis (gdouble spp)
799 for (uint32_t n=0; n < waves.size(); ++n) {
800 waves[n]->property_amplitude_above_axis() = spp;
805 AudioRegionView::compute_colors (Gdk::Color const & basic_color)
807 RegionView::compute_colors (basic_color);
809 /* gain color computed in envelope_active_changed() */
811 fade_color = UINT_RGBA_CHANGE_A (fill_color, 120);
815 AudioRegionView::set_colors ()
817 RegionView::set_colors();
820 gain_line->set_line_color (audio_region()->envelope_active() ? ARDOUR_UI::config()->canvasvar_GainLine.get() : ARDOUR_UI::config()->canvasvar_GainLineInactive.get());
823 for (uint32_t n=0; n < waves.size(); ++n) {
824 if (_region->muted()) {
825 waves[n]->property_wave_color() = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_WaveForm.get(), MUTED_ALPHA);
827 waves[n]->property_wave_color() = ARDOUR_UI::config()->canvasvar_WaveForm.get();
830 waves[n]->property_clip_color() = ARDOUR_UI::config()->canvasvar_WaveFormClip.get();
831 waves[n]->property_zero_color() = ARDOUR_UI::config()->canvasvar_ZeroLine.get();
836 AudioRegionView::setup_waveform_visibility ()
838 if (Config->get_show_waveforms ()) {
839 for (uint32_t n = 0; n < waves.size(); ++n) {
840 /* make sure the zoom level is correct, since we don't update
841 this when waveforms are hidden.
843 waves[n]->property_samples_per_unit() = samples_per_unit;
847 for (uint32_t n = 0; n < waves.size(); ++n) {
854 AudioRegionView::temporarily_hide_envelope ()
862 AudioRegionView::unhide_envelope ()
864 update_envelope_visibility ();
868 AudioRegionView::update_envelope_visibility ()
874 if (Config->get_show_region_gain() || trackview.editor().current_mouse_mode() == Editing::MouseGain) {
875 gain_line->add_visibility (AutomationLine::Line);
882 AudioRegionView::create_waves ()
884 // cerr << "AudioRegionView::create_waves() called on " << this << endl;//DEBUG
885 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
891 ChanCount nchans = atv.track()->n_channels();
893 // cerr << "creating waves for " << _region->name() << " with wfd = " << wait_for_data
894 // << " and channels = " << nchans.n_audio() << endl;
896 /* in tmp_waves, set up null pointers for each channel so the vector is allocated */
897 for (uint32_t n = 0; n < nchans.n_audio(); ++n) {
898 tmp_waves.push_back (0);
901 for (vector<ScopedConnection*>::iterator i = _data_ready_connections.begin(); i != _data_ready_connections.end(); ++i) {
905 _data_ready_connections.clear ();
907 for (uint32_t i = 0; i < nchans.n_audio(); ++i) {
908 _data_ready_connections.push_back (0);
911 for (uint32_t n = 0; n < nchans.n_audio(); ++n) {
913 if (n >= audio_region()->n_channels()) {
917 wave_caches.push_back (WaveView::create_cache ());
919 // cerr << "\tchannel " << n << endl;
922 if (audio_region()->audio_source(n)->peaks_ready (boost::bind (&AudioRegionView::peaks_ready_handler, this, n), &_data_ready_connections[n], gui_context())) {
923 // cerr << "\tData is ready\n";
924 create_one_wave (n, true);
926 // cerr << "\tdata is not ready\n";
927 // we'll get a PeaksReady signal from the source in the future
928 // and will call create_one_wave(n) then.
932 // cerr << "\tdon't delay, display today!\n";
933 create_one_wave (n, true);
940 AudioRegionView::create_one_wave (uint32_t which, bool /*direct*/)
942 //cerr << "AudioRegionView::create_one_wave() called which: " << which << " this: " << this << endl;//DEBUG
943 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
944 uint32_t nchans = atv.track()->n_channels().n_audio();
946 uint32_t nwaves = std::min (nchans, audio_region()->n_channels());
949 if (trackview.current_height() < NAME_HIGHLIGHT_THRESH) {
950 ht = ((trackview.current_height()) / (double) nchans);
952 ht = ((trackview.current_height() - NAME_HIGHLIGHT_SIZE) / (double) nchans);
955 gdouble yoff = which * ht;
957 WaveView *wave = new WaveView(*group);
959 wave->property_data_src() = (gpointer) _region.get();
960 wave->property_cache() = wave_caches[which];
961 wave->property_cache_updater() = true;
962 wave->property_channel() = which;
963 wave->property_length_function() = (gpointer) region_length_from_c;
964 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
965 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
966 wave->property_x() = 0.0;
967 wave->property_y() = yoff;
968 wave->property_height() = (double) ht;
969 wave->property_samples_per_unit() = samples_per_unit;
970 wave->property_amplitude_above_axis() = _amplitude_above_axis;
973 wave->property_wave_color() = _region->muted() ? UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_RecWaveForm.get(), MUTED_ALPHA) : ARDOUR_UI::config()->canvasvar_RecWaveForm.get();
974 wave->property_fill_color() = ARDOUR_UI::config()->canvasvar_RecWaveFormFill.get();
976 wave->property_wave_color() = _region->muted() ? UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_WaveForm.get(), MUTED_ALPHA) : ARDOUR_UI::config()->canvasvar_WaveForm.get();
977 wave->property_fill_color() = ARDOUR_UI::config()->canvasvar_WaveFormFill.get();
980 wave->property_clip_color() = ARDOUR_UI::config()->canvasvar_WaveFormClip.get();
981 wave->property_zero_color() = ARDOUR_UI::config()->canvasvar_ZeroLine.get();
982 wave->property_zero_line() = true;
983 wave->property_region_start() = _region->start();
984 wave->property_rectified() = Config->get_waveform_shape() == Rectified;
985 wave->property_logscaled() = Config->get_waveform_scale() == Logarithmic;
987 if (!Config->get_show_waveforms ()) {
991 /* note: calling this function is serialized by the lock
992 held in the peak building thread that signals that
993 peaks are ready for use *or* by the fact that it is
994 called one by one from the GUI thread.
997 if (which < nchans) {
998 tmp_waves[which] = wave;
1000 /* n-channel track, >n-channel source */
1003 /* see if we're all ready */
1005 for (n = 0; n < nchans; ++n) {
1006 if (tmp_waves[n] == 0) {
1011 if (n == nwaves && waves.empty()) {
1012 /* all waves are ready */
1013 tmp_waves.resize(nwaves);
1018 /* all waves created, don't hook into peaks ready anymore */
1019 delete _data_ready_connections[which];
1020 _data_ready_connections[which] = 0;
1025 AudioRegionView::peaks_ready_handler (uint32_t which)
1027 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&AudioRegionView::create_one_wave, this, which, false));
1028 // cerr << "AudioRegionView::peaks_ready_handler() called on " << which << " this: " << this << endl;
1032 AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
1040 /* don't create points that can't be seen */
1042 update_envelope_visibility ();
1049 framepos_t fx = trackview.editor().pixel_to_frame (x);
1051 if (fx > _region->length()) {
1055 /* compute vertical fractional position */
1057 y = 1.0 - (y / (_height - NAME_HIGHLIGHT_SIZE));
1059 /* map using gain line */
1061 gain_line->view_to_model_coord (x, y);
1063 /* XXX STATEFUL: can't convert to stateful diff until we
1064 can represent automation data with it.
1067 trackview.session()->begin_reversible_command (_("add gain control point"));
1068 XMLNode &before = audio_region()->envelope()->get_state();
1070 if (!audio_region()->envelope_active()) {
1071 XMLNode ®ion_before = audio_region()->get_state();
1072 audio_region()->set_envelope_active(true);
1073 XMLNode ®ion_after = audio_region()->get_state();
1074 trackview.session()->add_command (new MementoCommand<AudioRegion>(*(audio_region().get()), ®ion_before, ®ion_after));
1077 audio_region()->envelope()->add (fx, y);
1079 XMLNode &after = audio_region()->envelope()->get_state();
1080 trackview.session()->add_command (new MementoCommand<AutomationList>(*audio_region()->envelope().get(), &before, &after));
1081 trackview.session()->commit_reversible_command ();
1085 AudioRegionView::remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent */*ev*/)
1087 ControlPoint *cp = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"));
1088 audio_region()->envelope()->erase (cp->model());
1092 AudioRegionView::setup_waveform_shape ()
1094 for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
1095 (*wave)->property_rectified() = Config->get_waveform_shape() == Rectified;
1100 AudioRegionView::setup_waveform_scale ()
1102 for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
1103 (*wave)->property_logscaled() = Config->get_waveform_scale() == Logarithmic;
1109 AudioRegionView::add_ghost (TimeAxisView& tv)
1111 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&trackview);
1114 double unit_position = _region->position () / samples_per_unit;
1115 AudioGhostRegion* ghost = new AudioGhostRegion (tv, trackview, unit_position);
1118 nchans = rtv->track()->n_channels().n_audio();
1120 for (uint32_t n = 0; n < nchans; ++n) {
1122 if (n >= audio_region()->n_channels()) {
1126 WaveView *wave = new WaveView(*ghost->group);
1128 wave->property_data_src() = _region.get();
1129 wave->property_cache() = wave_caches[n];
1130 wave->property_cache_updater() = false;
1131 wave->property_channel() = n;
1132 wave->property_length_function() = (gpointer)region_length_from_c;
1133 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
1134 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
1135 wave->property_x() = 0.0;
1136 wave->property_samples_per_unit() = samples_per_unit;
1137 wave->property_amplitude_above_axis() = _amplitude_above_axis;
1139 wave->property_region_start() = _region->start();
1141 ghost->waves.push_back(wave);
1144 ghost->set_height ();
1145 ghost->set_duration (_region->length() / samples_per_unit);
1146 ghost->set_colors();
1147 ghosts.push_back (ghost);
1153 AudioRegionView::entered (bool internal_editing)
1155 trackview.editor().set_current_trimmable (_region);
1156 trackview.editor().set_current_movable (_region);
1158 if (gain_line && trackview.editor().current_mouse_mode() == Editing::MouseGain) {
1159 gain_line->add_visibility (AutomationLine::ControlPoints);
1162 if (fade_in_handle && !internal_editing) {
1163 fade_in_handle->property_outline_color_rgba() = RGBA_TO_UINT (0, 0, 0, 255);
1164 fade_in_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 255);
1165 fade_out_handle->property_outline_color_rgba() = RGBA_TO_UINT (0, 0, 0, 255);
1166 fade_out_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 255);
1171 AudioRegionView::exited ()
1173 trackview.editor().set_current_trimmable (boost::shared_ptr<Trimmable>());
1174 trackview.editor().set_current_movable (boost::shared_ptr<Movable>());
1176 if (gain_line && trackview.editor().current_mouse_mode() == Editing::MouseGain) {
1177 gain_line->remove_visibility (AutomationLine::ControlPoints);
1180 if (fade_in_handle) {
1181 fade_in_handle->property_outline_color_rgba() = RGBA_TO_UINT (0, 0, 0, 0);
1182 fade_in_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 0);
1183 fade_out_handle->property_outline_color_rgba() = RGBA_TO_UINT (0, 0, 0, 0);
1184 fade_out_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 0);
1189 AudioRegionView::envelope_active_changed ()
1192 gain_line->set_line_color (audio_region()->envelope_active() ? ARDOUR_UI::config()->canvasvar_GainLine.get() : ARDOUR_UI::config()->canvasvar_GainLineInactive.get());
1197 AudioRegionView::set_waveview_data_src()
1199 AudioGhostRegion* agr;
1200 double unit_length= _region->length() / samples_per_unit;
1202 for (uint32_t n = 0; n < waves.size(); ++n) {
1203 // TODO: something else to let it know the channel
1204 waves[n]->property_data_src() = _region.get();
1207 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
1209 (*i)->set_duration (unit_length);
1211 if((agr = dynamic_cast<AudioGhostRegion*>(*i)) != 0) {
1212 for (vector<WaveView*>::iterator w = agr->waves.begin(); w != agr->waves.end(); ++w) {
1213 (*w)->property_data_src() = _region.get();
1221 AudioRegionView::color_handler ()
1223 //case cMutedWaveForm:
1225 //case cWaveFormClip:
1229 //case cGainLineInactive:
1231 envelope_active_changed();
1236 AudioRegionView::set_frame_color ()
1242 if (_region->opaque()) {
1248 TimeAxisViewItem::set_frame_color ();
1254 if (_region->muted()) {
1255 wc = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_SelectedWaveForm.get(), MUTED_ALPHA);
1257 wc = ARDOUR_UI::config()->canvasvar_SelectedWaveForm.get();
1259 fc = ARDOUR_UI::config()->canvasvar_SelectedWaveFormFill.get();
1262 if (_region->muted()) {
1263 wc = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_RecWaveForm.get(), MUTED_ALPHA);
1265 wc = ARDOUR_UI::config()->canvasvar_RecWaveForm.get();
1267 fc = ARDOUR_UI::config()->canvasvar_RecWaveFormFill.get();
1269 if (_region->muted()) {
1270 wc = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_WaveForm.get(), MUTED_ALPHA);
1272 wc = ARDOUR_UI::config()->canvasvar_WaveForm.get();
1274 fc = ARDOUR_UI::config()->canvasvar_WaveFormFill.get();
1278 for (vector<ArdourCanvas::WaveView*>::iterator w = waves.begin(); w != waves.end(); ++w) {
1279 if (_region->muted()) {
1280 (*w)->property_wave_color() = wc;
1282 (*w)->property_wave_color() = wc;
1283 (*w)->property_fill_color() = fc;
1289 AudioRegionView::set_fade_visibility (bool yn)
1292 if (fade_in_shape) {
1293 fade_in_shape->show();
1295 if (fade_out_shape) {
1296 fade_out_shape->show ();
1298 if (fade_in_handle) {
1299 fade_in_handle->show ();
1301 if (fade_out_handle) {
1302 fade_out_handle->show ();
1305 if (fade_in_shape) {
1306 fade_in_shape->hide();
1308 if (fade_out_shape) {
1309 fade_out_shape->hide ();
1311 if (fade_in_handle) {
1312 fade_in_handle->hide ();
1314 if (fade_out_handle) {
1315 fade_out_handle->hide ();
1321 AudioRegionView::update_coverage_frames (LayerDisplay d)
1323 RegionView::update_coverage_frames (d);
1325 if (fade_in_handle) {
1326 fade_in_handle->raise_to_top ();
1327 fade_out_handle->raise_to_top ();
1332 AudioRegionView::show_region_editor ()
1335 editor = new AudioRegionEditor (trackview.session(), audio_region());
1339 editor->set_position (Gtk::WIN_POS_MOUSE);
1345 AudioRegionView::show_fade_line (framepos_t pos)
1347 fade_position_line->property_x1() = trackview.editor().frame_to_pixel (pos);
1348 fade_position_line->property_x2() = trackview.editor().frame_to_pixel (pos);
1349 fade_position_line->show ();
1350 fade_position_line->raise_to_top ();
1354 AudioRegionView::hide_fade_line ()
1356 fade_position_line->hide ();
1361 AudioRegionView::transients_changed ()
1363 AnalysisFeatureList analysis_features = _region->transients();
1365 while (feature_lines.size() < analysis_features.size()) {
1367 ArdourCanvas::Line* canvas_item = new ArdourCanvas::Line(*group);
1369 ArdourCanvas::Points points;
1371 points.push_back(Gnome::Art::Point(-1.0, 2.0)); // first x-coord needs to be a non-normal value
1372 points.push_back(Gnome::Art::Point(1.0, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1));
1374 canvas_item->property_points() = points;
1375 canvas_item->property_width_pixels() = 1;
1376 canvas_item->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ZeroLine.get();
1377 canvas_item->property_first_arrowhead() = TRUE;
1378 canvas_item->property_last_arrowhead() = TRUE;
1379 canvas_item->property_arrow_shape_a() = 11.0;
1380 canvas_item->property_arrow_shape_b() = 0.0;
1381 canvas_item->property_arrow_shape_c() = 4.0;
1383 canvas_item->raise_to_top ();
1384 canvas_item->show ();
1386 canvas_item->set_data ("regionview", this);
1387 canvas_item->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_feature_line_event), canvas_item, this));
1389 feature_lines.push_back (make_pair(0, canvas_item));
1392 while (feature_lines.size() > analysis_features.size()) {
1393 ArdourCanvas::Line* line = feature_lines.back().second;
1394 feature_lines.pop_back ();
1398 AnalysisFeatureList::const_iterator i;
1399 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
1401 for (i = analysis_features.begin(), l = feature_lines.begin(); i != analysis_features.end() && l != feature_lines.end(); ++i, ++l) {
1403 ArdourCanvas::Points points;
1405 float *pos = new float;
1406 *pos = trackview.editor().frame_to_pixel (*i);
1408 points.push_back(Gnome::Art::Point(*pos, 2.0)); // first x-coord needs to be a non-normal value
1409 points.push_back(Gnome::Art::Point(*pos, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1));
1411 (*l).second->property_points() = points;
1412 (*l).second->set_data ("position", pos);
1419 AudioRegionView::update_transient(float /*old_pos*/, float new_pos)
1421 /* Find frame at old pos, calulate new frame then update region transients*/
1422 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
1424 for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
1426 /* Line has been updated in drag so we compare to new_pos */
1428 float* pos = (float*) (*l).second->get_data ("position");
1430 if (rint(new_pos) == rint(*pos)) {
1432 framepos_t old_frame = (*l).first;
1433 framepos_t new_frame = trackview.editor().pixel_to_frame (new_pos);
1435 _region->update_transient (old_frame, new_frame);
1443 AudioRegionView::remove_transient(float pos)
1445 /* Find frame at old pos, calulate new frame then update region transients*/
1446 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
1448 for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
1450 /* Line has been updated in drag so we compare to new_pos */
1451 float *line_pos = (float*) (*l).second->get_data ("position");
1453 if (rint(pos) == rint(*line_pos)) {
1454 _region->remove_transient ((*l).first);
1461 AudioRegionView::thaw_after_trim ()
1463 RegionView::thaw_after_trim ();
1469 AudioRegionView::redraw_start_xfade ()
1471 boost::shared_ptr<AudioRegion> ar (audio_region());
1473 if (!ar->fade_in() || ar->fade_in()->empty()) {
1477 if (!ar->fade_in_is_xfade()) {
1478 if (start_xfade_in) {
1479 start_xfade_in->hide ();
1480 start_xfade_out->hide ();
1481 start_xfade_rect->hide ();
1482 _start_xfade_visible = false;
1487 redraw_start_xfade_to (ar, ar->fade_in()->back()->when);
1491 AudioRegionView::redraw_start_xfade_to (boost::shared_ptr<AudioRegion> ar, framecnt_t len)
1493 int32_t const npoints = trackview.editor().frame_to_pixel (len);
1499 if (!start_xfade_in) {
1500 start_xfade_in = new ArdourCanvas::Line (*group);
1501 start_xfade_in->property_width_pixels() = 1;
1502 start_xfade_in->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GainLine.get();
1505 if (!start_xfade_out) {
1506 start_xfade_out = new ArdourCanvas::Line (*group);
1507 start_xfade_out->property_width_pixels() = 1;
1508 uint32_t col = UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->canvasvar_GainLine.get(), 125);
1509 start_xfade_out->property_fill_color_rgba() = col;
1512 if (!start_xfade_rect) {
1513 start_xfade_rect = new ArdourCanvas::SimpleRect (*group);
1514 start_xfade_rect->property_draw() = true;
1515 start_xfade_rect->property_fill() = true;;
1516 start_xfade_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ActiveCrossfade.get();
1517 start_xfade_rect->property_outline_pixels() = 0;
1518 start_xfade_rect->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_start_xfade_event), start_xfade_rect, this));
1519 start_xfade_rect->set_data ("regionview", this);
1522 Points* points = get_canvas_points ("xfade edit redraw", npoints);
1523 boost::scoped_ptr<float> vec (new float[npoints]);
1524 double effective_height = _height - NAME_HIGHLIGHT_SIZE - 1.0;
1526 ar->fade_in()->curve().get_vector (0, ar->fade_in()->back()->when, vec.get(), npoints);
1528 for (int i = 0, pci = 0; i < npoints; ++i) {
1529 Gnome::Art::Point &p ((*points)[pci++]);
1531 p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
1534 start_xfade_rect->property_x1() = ((*points)[0]).get_x();
1535 start_xfade_rect->property_y1() = 1.0;
1536 start_xfade_rect->property_x2() = ((*points)[npoints-1]).get_x();
1537 start_xfade_rect->property_y2() = effective_height;
1538 start_xfade_rect->show ();
1539 start_xfade_rect->raise_to_top ();
1541 start_xfade_in->property_points() = *points;
1542 start_xfade_in->show ();
1543 start_xfade_in->raise_to_top ();
1547 boost::shared_ptr<AutomationList> inverse = ar->inverse_fade_in();
1551 for (int i = 0, pci = 0; i < npoints; ++i) {
1552 Gnome::Art::Point &p ((*points)[pci++]);
1554 p.set_y (1.0 + effective_height - (effective_height * (1.0 - vec.get()[i])));
1559 inverse->curve().get_vector (0, inverse->back()->when, vec.get(), npoints);
1561 for (int i = 0, pci = 0; i < npoints; ++i) {
1562 Gnome::Art::Point &p ((*points)[pci++]);
1564 p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
1568 start_xfade_out->property_points() = *points;
1569 start_xfade_out->show ();
1570 start_xfade_out->raise_to_top ();
1572 _start_xfade_visible = true;
1578 AudioRegionView::redraw_end_xfade ()
1580 boost::shared_ptr<AudioRegion> ar (audio_region());
1582 if (!ar->fade_out() || ar->fade_out()->empty()) {
1586 if (!ar->fade_out_is_xfade()) {
1588 end_xfade_in->hide ();
1589 end_xfade_out->hide ();
1590 end_xfade_rect->hide ();
1591 _end_xfade_visible = false;
1596 redraw_end_xfade_to (ar, ar->fade_out()->back()->when);
1600 AudioRegionView::redraw_end_xfade_to (boost::shared_ptr<AudioRegion> ar, framecnt_t len)
1602 int32_t const npoints = trackview.editor().frame_to_pixel (len);
1608 if (!end_xfade_in) {
1609 end_xfade_in = new ArdourCanvas::Line (*group);
1610 end_xfade_in->property_width_pixels() = 1;
1611 end_xfade_in->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GainLine.get();
1614 if (!end_xfade_out) {
1615 end_xfade_out = new ArdourCanvas::Line (*group);
1616 end_xfade_out->property_width_pixels() = 1;
1617 uint32_t col UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->canvasvar_GainLine.get(), 125);
1618 end_xfade_out->property_fill_color_rgba() = col;
1621 if (!end_xfade_rect) {
1622 end_xfade_rect = new ArdourCanvas::SimpleRect (*group);
1623 end_xfade_rect->property_draw() = true;
1624 end_xfade_rect->property_fill() = true;;
1625 end_xfade_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ActiveCrossfade.get();
1626 end_xfade_rect->property_outline_pixels() = 0;
1627 end_xfade_rect->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_end_xfade_event), end_xfade_rect, this));
1628 end_xfade_rect->set_data ("regionview", this);
1631 Points* points = get_canvas_points ("xfade edit redraw", npoints);
1632 boost::scoped_ptr<float> vec (new float[npoints]);
1634 ar->fade_out()->curve().get_vector (0, ar->fade_out()->back()->when, vec.get(), npoints);
1636 double rend = trackview.editor().frame_to_pixel (_region->length() - len);
1637 double effective_height = _height - NAME_HIGHLIGHT_SIZE - 1;
1639 for (int i = 0, pci = 0; i < npoints; ++i) {
1640 Gnome::Art::Point &p ((*points)[pci++]);
1642 p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
1645 end_xfade_rect->property_x1() = ((*points)[0]).get_x();
1646 end_xfade_rect->property_y1() = 1;
1647 end_xfade_rect->property_x2() = ((*points)[npoints-1]).get_x();
1648 end_xfade_rect->property_y2() = effective_height;
1649 end_xfade_rect->show ();
1650 end_xfade_rect->raise_to_top ();
1652 end_xfade_in->property_points() = *points;
1653 end_xfade_in->show ();
1654 end_xfade_in->raise_to_top ();
1658 boost::shared_ptr<AutomationList> inverse = ar->inverse_fade_out ();
1662 for (int i = 0, pci = 0; i < npoints; ++i) {
1663 Gnome::Art::Point &p ((*points)[pci++]);
1665 p.set_y (1.0 + effective_height - (effective_height * (1.0 - vec.get()[i])));
1670 inverse->curve().get_vector (inverse->front()->when, inverse->back()->when, vec.get(), npoints);
1672 for (int i = 0, pci = 0; i < npoints; ++i) {
1673 Gnome::Art::Point &p ((*points)[pci++]);
1675 p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
1679 end_xfade_out->property_points() = *points;
1680 end_xfade_out->show ();
1681 end_xfade_out->raise_to_top ();
1683 _end_xfade_visible = true;
1689 AudioRegionView::hide_xfades ()
1691 hide_start_xfade ();
1696 AudioRegionView::hide_start_xfade ()
1698 if (start_xfade_in) {
1699 start_xfade_in->hide();
1701 if (start_xfade_out) {
1702 start_xfade_out->hide();
1704 if (start_xfade_rect) {
1705 start_xfade_rect->hide ();
1708 _start_xfade_visible = false;
1712 AudioRegionView::hide_end_xfade ()
1715 end_xfade_in->hide();
1717 if (end_xfade_out) {
1718 end_xfade_out->hide();
1720 if (end_xfade_rect) {
1721 end_xfade_rect->hide ();
1724 _end_xfade_visible = false;
1728 AudioRegionView::show_start_xfade ()
1730 if (start_xfade_in) {
1731 start_xfade_in->show();
1733 if (start_xfade_out) {
1734 start_xfade_out->show();
1736 if (start_xfade_rect) {
1737 start_xfade_rect->show ();
1740 _start_xfade_visible = true;
1744 AudioRegionView::show_end_xfade ()
1747 end_xfade_in->show();
1749 if (end_xfade_out) {
1750 end_xfade_out->show();
1752 if (end_xfade_rect) {
1753 end_xfade_rect->show ();
1756 _end_xfade_visible = true;
1760 AudioRegionView::show_xfades ()
1762 show_start_xfade ();
1767 AudioRegionView::drag_start ()
1769 TimeAxisViewItem::drag_start ();
1770 AudioTimeAxisView* atav = dynamic_cast<AudioTimeAxisView*> (&trackview);
1773 AudioStreamView* av = atav->audio_view();
1775 /* this will hide our xfades too */
1776 _hidden_xfades = av->hide_xfades_with (audio_region());
1782 AudioRegionView::drag_end ()
1784 TimeAxisViewItem::drag_end ();
1786 for (list<AudioRegionView*>::iterator i = _hidden_xfades.first.begin(); i != _hidden_xfades.first.end(); ++i) {
1787 (*i)->show_start_xfade ();
1790 for (list<AudioRegionView*>::iterator i = _hidden_xfades.second.begin(); i != _hidden_xfades.second.end(); ++i) {
1791 (*i)->show_end_xfade ();
1794 _hidden_xfades.first.clear ();
1795 _hidden_xfades.second.clear ();
1799 AudioRegionView::parameter_changed (string const & p)
1801 if (p == "show-waveforms") {
1802 setup_waveform_visibility ();
1803 } else if (p == "waveform-scale") {
1804 setup_waveform_scale ();
1805 } else if (p == "waveform-shape") {
1806 setup_waveform_shape ();