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_array.hpp>
24 #include <boost/scoped_ptr.hpp>
28 #include <gtkmm2ext/gtk_ui.h>
30 #include "ardour/playlist.h"
31 #include "ardour/audioregion.h"
32 #include "ardour/audiosource.h"
33 #include "ardour/profile.h"
34 #include "ardour/session.h"
36 #include "pbd/memento_command.h"
37 #include "pbd/stacktrace.h"
39 #include "evoral/Curve.hpp"
41 #include "streamview.h"
42 #include "audio_region_view.h"
43 #include "audio_time_axis.h"
44 #include "simplerect.h"
45 #include "simpleline.h"
47 #include "public_editor.h"
48 #include "audio_region_editor.h"
49 #include "audio_streamview.h"
50 #include "region_gain_line.h"
51 #include "control_point.h"
52 #include "ghostregion.h"
53 #include "audio_time_axis.h"
55 #include "rgb_macros.h"
56 #include "gui_thread.h"
57 #include "ardour_ui.h"
61 #define MUTED_ALPHA 10
64 using namespace ARDOUR;
66 using namespace Editing;
67 using namespace ArdourCanvas;
69 static const int32_t sync_mark_width = 9;
70 static double const handle_size = 6; /* height of fade handles */
72 AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, boost::shared_ptr<AudioRegion> r, double spu,
73 Gdk::Color const & basic_color)
74 : RegionView (parent, tv, r, spu, basic_color)
80 , fade_position_line(0)
83 , start_xfade_rect (0)
84 , _start_xfade_visible (false)
88 , _end_xfade_visible (false)
89 , _amplitude_above_axis(1.0)
92 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&AudioRegionView::parameter_changed, this, _1), gui_context());
95 AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, boost::shared_ptr<AudioRegion> r, double spu,
96 Gdk::Color const & basic_color, bool recording, TimeAxisViewItem::Visibility visibility)
97 : RegionView (parent, tv, r, spu, basic_color, recording, visibility)
103 , fade_position_line(0)
105 , start_xfade_out (0)
106 , start_xfade_rect (0)
107 , _start_xfade_visible (false)
111 , _end_xfade_visible (false)
112 , _amplitude_above_axis(1.0)
115 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&AudioRegionView::parameter_changed, this, _1), gui_context());
118 AudioRegionView::AudioRegionView (const AudioRegionView& other, boost::shared_ptr<AudioRegion> other_region)
119 : RegionView (other, boost::shared_ptr<Region> (other_region))
124 , fade_position_line(0)
126 , start_xfade_out (0)
127 , start_xfade_rect (0)
128 , _start_xfade_visible (false)
132 , _end_xfade_visible (false)
133 , _amplitude_above_axis (other._amplitude_above_axis)
139 UINT_TO_RGBA (other.fill_color, &r, &g, &b, &a);
140 c.set_rgb_p (r/255.0, g/255.0, b/255.0);
144 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&AudioRegionView::parameter_changed, this, _1), gui_context());
148 AudioRegionView::init (Gdk::Color const & basic_color, bool wfd)
150 // FIXME: Some redundancy here with RegionView::init. Need to figure out
151 // where order is important and where it isn't...
153 RegionView::init (basic_color, wfd);
155 _amplitude_above_axis = 1.0;
157 compute_colors (basic_color);
161 fade_in_shape = new ArdourCanvas::Polygon (*group);
162 fade_in_shape->property_fill_color_rgba() = fade_color;
163 fade_in_shape->set_data ("regionview", this);
165 fade_out_shape = new ArdourCanvas::Polygon (*group);
166 fade_out_shape->property_fill_color_rgba() = fade_color;
167 fade_out_shape->set_data ("regionview", this);
170 fade_in_handle = new ArdourCanvas::SimpleRect (*group);
171 fade_in_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fill_color, 0);
172 fade_in_handle->property_outline_color_rgba() = RGBA_TO_UINT (0, 0, 0, 0);
174 fade_in_handle->set_data ("regionview", this);
176 fade_out_handle = new ArdourCanvas::SimpleRect (*group);
177 fade_out_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fill_color, 0);
178 fade_out_handle->property_outline_color_rgba() = RGBA_TO_UINT (0, 0, 0, 0);
180 fade_out_handle->set_data ("regionview", this);
182 fade_position_line = new ArdourCanvas::SimpleLine (*group);
183 fade_position_line->property_color_rgba() = 0xBBBBBBAA;
184 fade_position_line->property_y1() = 7;
185 fade_position_line->property_y2() = _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1;
187 fade_position_line->hide();
190 setup_fade_handle_positions ();
192 if (!trackview.session()->config.get_show_region_fades()) {
193 set_fade_visibility (false);
196 const string line_name = _region->name() + ":gain";
198 if (!Profile->get_sae()) {
199 gain_line.reset (new AudioRegionGainLine (line_name, *this, *group, audio_region()->envelope()));
202 update_envelope_visibility ();
205 set_height (trackview.current_height());
208 region_sync_changed ();
210 region_resized (ARDOUR::bounds_change);
211 set_waveview_data_src();
213 envelope_active_changed ();
214 fade_in_active_changed ();
215 fade_out_active_changed ();
217 reset_width_dependent_items (_pixel_width);
219 fade_in_shape->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_event), fade_in_shape, this));
220 if (fade_in_handle) {
221 fade_in_handle->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_handle_event), fade_in_handle, this));
224 fade_out_shape->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_event), fade_out_shape, this));
226 if (fade_out_handle) {
227 fade_out_handle->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_handle_event), fade_out_handle, this));
232 setup_waveform_visibility ();
233 setup_waveform_shape ();
234 setup_waveform_scale ();
236 /* XXX sync mark drag? */
239 AudioRegionView::~AudioRegionView ()
241 in_destructor = true;
243 RegionViewGoingAway (this); /* EMIT_SIGNAL */
245 for (vector<GnomeCanvasWaveViewCache *>::iterator cache = wave_caches.begin(); cache != wave_caches.end() ; ++cache) {
246 gnome_canvas_waveview_cache_destroy (*cache);
249 for (vector<ScopedConnection*>::iterator i = _data_ready_connections.begin(); i != _data_ready_connections.end(); ++i) {
253 for (list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator i = feature_lines.begin(); i != feature_lines.end(); ++i) {
254 delete ((*i).second);
257 /* all waveviews etc will be destroyed when the group is destroyed */
260 boost::shared_ptr<ARDOUR::AudioRegion>
261 AudioRegionView::audio_region() const
263 // "Guaranteed" to succeed...
264 return boost::dynamic_pointer_cast<AudioRegion>(_region);
268 AudioRegionView::region_changed (const PropertyChange& what_changed)
270 ENSURE_GUI_THREAD (*this, &AudioRegionView::region_changed, what_changed);
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)) {
280 if (what_changed.contains (ARDOUR::Properties::fade_out)) {
283 if (what_changed.contains (ARDOUR::Properties::fade_in_active)) {
284 fade_in_active_changed ();
286 if (what_changed.contains (ARDOUR::Properties::fade_out_active)) {
287 fade_out_active_changed ();
289 if (what_changed.contains (ARDOUR::Properties::fade_in_is_xfade)) {
292 if (what_changed.contains (ARDOUR::Properties::fade_out_is_xfade)) {
295 if (what_changed.contains (ARDOUR::Properties::envelope_active)) {
296 envelope_active_changed ();
298 if (what_changed.contains (ARDOUR::Properties::valid_transients)) {
299 transients_changed ();
304 AudioRegionView::fade_in_changed ()
306 reset_fade_in_shape ();
310 AudioRegionView::fade_out_changed ()
312 reset_fade_out_shape ();
316 AudioRegionView::fade_in_active_changed ()
318 if (audio_region()->fade_in_active()) {
319 fade_in_shape->property_fill_color_rgba() = RGBA_TO_UINT(45,45,45,90); // FIXME make a themeable colour
320 fade_in_shape->property_width_pixels() = 1;
322 fade_in_shape->property_fill_color_rgba() = RGBA_TO_UINT(45,45,45,20); // FIXME make a themeable colour
323 fade_in_shape->property_width_pixels() = 1;
328 AudioRegionView::fade_out_active_changed ()
330 if (audio_region()->fade_out_active()) {
331 fade_out_shape->property_fill_color_rgba() = RGBA_TO_UINT(45,45,45,90); // FIXME make a themeable colour
332 fade_out_shape->property_width_pixels() = 1;
334 fade_out_shape->property_fill_color_rgba() = RGBA_TO_UINT(45,45,45,20); // FIXME make a themeable colour
335 fade_out_shape->property_width_pixels() = 1;
341 AudioRegionView::region_scale_amplitude_changed ()
343 ENSURE_GUI_THREAD (*this, &AudioRegionView::region_scale_amplitude_changed)
345 for (uint32_t n = 0; n < waves.size(); ++n) {
346 // force a reload of the cache
347 waves[n]->property_data_src() = _region.get();
352 AudioRegionView::region_renamed ()
354 std::string str = RegionView::make_name ();
356 if (audio_region()->speed_mismatch (trackview.session()->frame_rate())) {
357 str = string ("*") + str;
360 if (_region->muted()) {
361 str = string ("!") + str;
364 set_item_name (str, this);
369 AudioRegionView::region_resized (const PropertyChange& what_changed)
371 AudioGhostRegion* agr;
373 RegionView::region_resized(what_changed);
374 PropertyChange interesting_stuff;
376 interesting_stuff.add (ARDOUR::Properties::start);
377 interesting_stuff.add (ARDOUR::Properties::length);
379 if (what_changed.contains (interesting_stuff)) {
381 for (uint32_t n = 0; n < waves.size(); ++n) {
382 waves[n]->property_region_start() = _region->start();
385 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
386 if ((agr = dynamic_cast<AudioGhostRegion*>(*i)) != 0) {
388 for (vector<WaveView*>::iterator w = agr->waves.begin(); w != agr->waves.end(); ++w) {
389 (*w)->property_region_start() = _region->start();
394 /* hide transient lines that extend beyond the region end */
396 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
398 for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
399 if (l->first > _region->length() - 1) {
409 AudioRegionView::reset_width_dependent_items (double pixel_width)
411 RegionView::reset_width_dependent_items(pixel_width);
412 assert(_pixel_width == pixel_width);
414 if (fade_in_handle) {
415 if (pixel_width <= 6.0 || _height < 5.0 || !trackview.session()->config.get_show_region_fades()) {
416 fade_in_handle->hide();
417 fade_out_handle->hide();
420 fade_in_handle->show();
421 fade_out_handle->show();
425 AnalysisFeatureList analysis_features = _region->transients();
426 AnalysisFeatureList::const_iterator i;
428 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
430 for (i = analysis_features.begin(), l = feature_lines.begin(); i != analysis_features.end() && l != feature_lines.end(); ++i, ++l) {
432 float x_pos = trackview.editor().frame_to_pixel (*i);
434 ArdourCanvas::Points points;
435 points.push_back(Gnome::Art::Point(x_pos, 2.0)); // first x-coord needs to be a non-normal value
436 points.push_back(Gnome::Art::Point(x_pos, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1));
439 (*l).second->property_points() = points;
442 reset_fade_shapes ();
446 AudioRegionView::region_muted ()
448 RegionView::region_muted();
450 for (uint32_t n=0; n < waves.size(); ++n) {
451 if (_region->muted()) {
452 waves[n]->property_wave_color() = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_WaveForm.get(), MUTED_ALPHA);
454 waves[n]->property_wave_color() = ARDOUR_UI::config()->canvasvar_WaveForm.get();
460 AudioRegionView::setup_fade_handle_positions()
462 /* position of fade handle offset from the top of the region view */
463 double const handle_pos = 2;
465 if (fade_in_handle) {
466 fade_in_handle->property_y1() = handle_pos;
467 fade_in_handle->property_y2() = handle_pos + handle_size;
470 if (fade_out_handle) {
471 fade_out_handle->property_y1() = handle_pos;
472 fade_out_handle->property_y2() = handle_pos + handle_size;
477 AudioRegionView::set_height (gdouble height)
479 RegionView::set_height (height);
481 uint32_t wcnt = waves.size();
483 for (uint32_t n = 0; n < wcnt; ++n) {
486 if (height < NAME_HIGHLIGHT_THRESH) {
487 ht = ((height - 2 * wcnt) / (double) wcnt);
489 ht = (((height - 2 * wcnt) - NAME_HIGHLIGHT_SIZE) / (double) wcnt);
492 gdouble yoff = n * (ht + 1);
494 waves[n]->property_height() = ht;
495 waves[n]->property_y() = yoff + 2;
500 if ((height/wcnt) < NAME_HIGHLIGHT_THRESH) {
503 update_envelope_visibility ();
506 gain_line->set_height ((uint32_t) rint (height - NAME_HIGHLIGHT_SIZE) - 2);
509 reset_fade_shapes ();
511 /* Update hights for any active feature lines */
512 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
514 for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
516 float pos_x = trackview.editor().frame_to_pixel((*l).first);
518 ArdourCanvas::Points points;
520 points.push_back(Gnome::Art::Point(pos_x, 2.0)); // first x-coord needs to be a non-normal value
521 points.push_back(Gnome::Art::Point(pos_x, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1));
523 (*l).second->property_points() = points;
526 if (fade_position_line) {
528 if (height < NAME_HIGHLIGHT_THRESH) {
529 fade_position_line->property_y2() = _height - 1;
532 fade_position_line->property_y2() = _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1;
537 name_pixbuf->raise_to_top();
542 AudioRegionView::reset_fade_shapes ()
544 reset_fade_in_shape ();
545 reset_fade_out_shape ();
549 AudioRegionView::reset_fade_in_shape ()
551 reset_fade_in_shape_width ((framecnt_t) audio_region()->fade_in()->back()->when);
555 AudioRegionView::reset_fade_in_shape_width (framecnt_t width)
561 if (audio_region()->fade_in_is_xfade()) {
562 if (fade_in_handle) {
563 fade_in_handle->hide ();
564 fade_in_shape->hide ();
566 redraw_start_xfade ();
569 if (start_xfade_in) {
570 start_xfade_in->hide ();
571 start_xfade_out->hide ();
572 start_xfade_rect->hide ();
573 _start_xfade_visible = false;
577 if (fade_in_handle == 0) {
581 fade_in_handle->show ();
583 /* smallest size for a fade is 64 frames */
585 width = std::max ((framecnt_t) 64, width);
589 /* round here to prevent little visual glitches with sub-pixel placement */
590 double const pwidth = rint (width / samples_per_unit);
591 uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth);
595 fade_in_shape->hide();
596 fade_in_handle->hide();
600 double const handle_center = pwidth;
602 /* Put the fade in handle so that its left side is at the end-of-fade line */
603 fade_in_handle->property_x1() = handle_center;
604 fade_in_handle->property_x2() = handle_center + handle_size;
607 fade_in_shape->hide();
611 if (trackview.session()->config.get_show_region_fades()) {
612 fade_in_shape->show();
615 float curve[npoints];
616 audio_region()->fade_in()->curve().get_vector (0, audio_region()->fade_in()->back()->when, curve, npoints);
618 points = get_canvas_points ("fade in shape", npoints + 3);
620 if (_height >= NAME_HIGHLIGHT_THRESH) {
621 h = _height - NAME_HIGHLIGHT_SIZE - 2;
626 /* points *MUST* be in anti-clockwise order */
629 double xdelta = pwidth/npoints;
631 for (pi = 0, pc = 0; pc < npoints; ++pc) {
632 (*points)[pi].set_x(1 + (pc * xdelta));
633 (*points)[pi++].set_y(2 + (h - (curve[pc] * h)));
638 (*points)[pi].set_x(pwidth);
639 (*points)[pi++].set_y(2);
641 (*points)[pi].set_x(1);
642 (*points)[pi++].set_y(2);
644 /* connect the dots ... */
646 (*points)[pi] = (*points)[0];
648 fade_in_shape->property_points() = *points;
651 /* ensure trim handle stays on top */
652 if (frame_handle_start) {
653 frame_handle_start->raise_to_top();
658 AudioRegionView::reset_fade_out_shape ()
660 reset_fade_out_shape_width ((framecnt_t) audio_region()->fade_out()->back()->when);
664 AudioRegionView::reset_fade_out_shape_width (framecnt_t width)
666 if (dragging() && audio_region()->fade_out_is_xfade()) {
667 /* we hide xfades while dragging regions */
671 if (audio_region()->fade_out_is_xfade()) {
672 if (fade_out_handle) {
673 fade_out_handle->hide ();
674 fade_out_shape->hide ();
680 end_xfade_in->hide ();
681 end_xfade_out->hide ();
682 end_xfade_rect->hide ();
683 _end_xfade_visible = false;
687 if (fade_out_handle == 0) {
691 fade_out_handle->show ();
693 /* smallest size for a fade is 64 frames */
695 width = std::max ((framecnt_t) 64, width);
699 /* round here to prevent little visual glitches with sub-pixel placement */
700 double const pwidth = rint (width / samples_per_unit);
701 uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth);
705 fade_out_shape->hide();
706 fade_out_handle->hide();
710 double const handle_center = (_region->length() - width) / samples_per_unit;
712 /* Put the fade out handle so that its right side is at the end-of-fade line;
713 * it's `one out' for precise pixel accuracy.
715 fade_out_handle->property_x1() = handle_center - 5;
716 fade_out_handle->property_x2() = handle_center + 1;
718 /* don't show shape if its too small */
721 fade_out_shape->hide();
725 if (trackview.session()->config.get_show_region_fades()) {
726 fade_out_shape->show();
729 float curve[npoints];
730 audio_region()->fade_out()->curve().get_vector (0, audio_region()->fade_out()->back()->when, curve, npoints);
732 if (_height >= NAME_HIGHLIGHT_THRESH) {
733 h = _height - NAME_HIGHLIGHT_SIZE - 2;
738 /* points *MUST* be in anti-clockwise order */
740 points = get_canvas_points ("fade out shape", npoints + 3);
743 double xdelta = pwidth/npoints;
745 for (pi = 0, pc = 0; pc < npoints; ++pc) {
746 (*points)[pi].set_x(_pixel_width - pwidth + (pc * xdelta));
747 (*points)[pi++].set_y(2 + (h - (curve[pc] * h)));
752 (*points)[pi].set_x(_pixel_width);
753 (*points)[pi++].set_y(h);
755 (*points)[pi].set_x(_pixel_width);
756 (*points)[pi++].set_y(2);
758 /* connect the dots ... */
760 (*points)[pi] = (*points)[0];
762 fade_out_shape->property_points() = *points;
765 /* ensure trim handle stays on top */
766 if (frame_handle_end) {
767 frame_handle_end->raise_to_top();
772 AudioRegionView::set_samples_per_unit (gdouble spu)
774 RegionView::set_samples_per_unit (spu);
776 if (Config->get_show_waveforms ()) {
777 for (uint32_t n = 0; n < waves.size(); ++n) {
778 waves[n]->property_samples_per_unit() = spu;
786 reset_fade_shapes ();
790 AudioRegionView::set_amplitude_above_axis (gdouble spp)
792 for (uint32_t n=0; n < waves.size(); ++n) {
793 waves[n]->property_amplitude_above_axis() = spp;
798 AudioRegionView::compute_colors (Gdk::Color const & basic_color)
800 RegionView::compute_colors (basic_color);
802 /* gain color computed in envelope_active_changed() */
804 fade_color = UINT_RGBA_CHANGE_A (fill_color, 120);
808 AudioRegionView::set_colors ()
810 RegionView::set_colors();
813 gain_line->set_line_color (audio_region()->envelope_active() ? ARDOUR_UI::config()->canvasvar_GainLine.get() : ARDOUR_UI::config()->canvasvar_GainLineInactive.get());
816 for (uint32_t n=0; n < waves.size(); ++n) {
817 if (_region->muted()) {
818 waves[n]->property_wave_color() = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_WaveForm.get(), MUTED_ALPHA);
820 waves[n]->property_wave_color() = ARDOUR_UI::config()->canvasvar_WaveForm.get();
823 waves[n]->property_clip_color() = ARDOUR_UI::config()->canvasvar_WaveFormClip.get();
824 waves[n]->property_zero_color() = ARDOUR_UI::config()->canvasvar_ZeroLine.get();
829 AudioRegionView::setup_waveform_visibility ()
831 if (Config->get_show_waveforms ()) {
832 for (uint32_t n = 0; n < waves.size(); ++n) {
833 /* make sure the zoom level is correct, since we don't update
834 this when waveforms are hidden.
836 waves[n]->property_samples_per_unit() = samples_per_unit;
840 for (uint32_t n = 0; n < waves.size(); ++n) {
847 AudioRegionView::temporarily_hide_envelope ()
855 AudioRegionView::unhide_envelope ()
857 update_envelope_visibility ();
861 AudioRegionView::update_envelope_visibility ()
867 if (Config->get_show_region_gain() || trackview.editor().current_mouse_mode() == Editing::MouseGain) {
868 gain_line->add_visibility (AutomationLine::Line);
875 AudioRegionView::create_waves ()
877 // cerr << "AudioRegionView::create_waves() called on " << this << endl;//DEBUG
878 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
884 ChanCount nchans = atv.track()->n_channels();
886 // cerr << "creating waves for " << _region->name() << " with wfd = " << wait_for_data
887 // << " and channels = " << nchans.n_audio() << endl;
889 /* in tmp_waves, set up null pointers for each channel so the vector is allocated */
890 for (uint32_t n = 0; n < nchans.n_audio(); ++n) {
891 tmp_waves.push_back (0);
894 for (vector<ScopedConnection*>::iterator i = _data_ready_connections.begin(); i != _data_ready_connections.end(); ++i) {
898 _data_ready_connections.clear ();
900 for (uint32_t i = 0; i < nchans.n_audio(); ++i) {
901 _data_ready_connections.push_back (0);
904 for (uint32_t n = 0; n < nchans.n_audio(); ++n) {
906 if (n >= audio_region()->n_channels()) {
910 wave_caches.push_back (WaveView::create_cache ());
912 // cerr << "\tchannel " << n << endl;
915 if (audio_region()->audio_source(n)->peaks_ready (boost::bind (&AudioRegionView::peaks_ready_handler, this, n), &_data_ready_connections[n], gui_context())) {
916 // cerr << "\tData is ready\n";
917 create_one_wave (n, true);
919 // cerr << "\tdata is not ready\n";
920 // we'll get a PeaksReady signal from the source in the future
921 // and will call create_one_wave(n) then.
925 // cerr << "\tdon't delay, display today!\n";
926 create_one_wave (n, true);
933 AudioRegionView::create_one_wave (uint32_t which, bool /*direct*/)
935 //cerr << "AudioRegionView::create_one_wave() called which: " << which << " this: " << this << endl;//DEBUG
936 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
937 uint32_t nchans = atv.track()->n_channels().n_audio();
939 uint32_t nwaves = std::min (nchans, audio_region()->n_channels());
942 if (trackview.current_height() < NAME_HIGHLIGHT_THRESH) {
943 ht = ((trackview.current_height()) / (double) nchans);
945 ht = ((trackview.current_height() - NAME_HIGHLIGHT_SIZE) / (double) nchans);
948 gdouble yoff = which * ht;
950 WaveView *wave = new WaveView(*group);
952 wave->property_data_src() = (gpointer) _region.get();
953 wave->property_cache() = wave_caches[which];
954 wave->property_cache_updater() = true;
955 wave->property_channel() = which;
956 wave->property_length_function() = (gpointer) region_length_from_c;
957 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
958 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
959 wave->property_x() = 0.0;
960 wave->property_y() = yoff;
961 wave->property_height() = (double) ht;
962 wave->property_samples_per_unit() = samples_per_unit;
963 wave->property_amplitude_above_axis() = _amplitude_above_axis;
966 wave->property_wave_color() = _region->muted() ? UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_RecWaveForm.get(), MUTED_ALPHA) : ARDOUR_UI::config()->canvasvar_RecWaveForm.get();
967 wave->property_fill_color() = ARDOUR_UI::config()->canvasvar_RecWaveFormFill.get();
969 wave->property_wave_color() = _region->muted() ? UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_WaveForm.get(), MUTED_ALPHA) : ARDOUR_UI::config()->canvasvar_WaveForm.get();
970 wave->property_fill_color() = ARDOUR_UI::config()->canvasvar_WaveFormFill.get();
973 wave->property_clip_color() = ARDOUR_UI::config()->canvasvar_WaveFormClip.get();
974 wave->property_zero_color() = ARDOUR_UI::config()->canvasvar_ZeroLine.get();
975 wave->property_zero_line() = true;
976 wave->property_region_start() = _region->start();
977 wave->property_rectified() = Config->get_waveform_shape() == Rectified;
978 wave->property_logscaled() = Config->get_waveform_scale() == Logarithmic;
980 if (!Config->get_show_waveforms ()) {
984 /* note: calling this function is serialized by the lock
985 held in the peak building thread that signals that
986 peaks are ready for use *or* by the fact that it is
987 called one by one from the GUI thread.
990 if (which < nchans) {
991 tmp_waves[which] = wave;
993 /* n-channel track, >n-channel source */
996 /* see if we're all ready */
998 for (n = 0; n < nchans; ++n) {
999 if (tmp_waves[n] == 0) {
1004 if (n == nwaves && waves.empty()) {
1005 /* all waves are ready */
1006 tmp_waves.resize(nwaves);
1011 /* all waves created, don't hook into peaks ready anymore */
1012 delete _data_ready_connections[which];
1013 _data_ready_connections[which] = 0;
1018 AudioRegionView::peaks_ready_handler (uint32_t which)
1020 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&AudioRegionView::create_one_wave, this, which, false));
1021 // cerr << "AudioRegionView::peaks_ready_handler() called on " << which << " this: " << this << endl;
1025 AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
1033 /* don't create points that can't be seen */
1035 update_envelope_visibility ();
1042 framepos_t fx = trackview.editor().pixel_to_frame (x);
1044 if (fx > _region->length()) {
1048 /* compute vertical fractional position */
1050 y = 1.0 - (y / (_height - NAME_HIGHLIGHT_SIZE));
1052 /* map using gain line */
1054 gain_line->view_to_model_coord (x, y);
1056 /* XXX STATEFUL: can't convert to stateful diff until we
1057 can represent automation data with it.
1060 trackview.session()->begin_reversible_command (_("add gain control point"));
1061 XMLNode &before = audio_region()->envelope()->get_state();
1063 if (!audio_region()->envelope_active()) {
1064 XMLNode ®ion_before = audio_region()->get_state();
1065 audio_region()->set_envelope_active(true);
1066 XMLNode ®ion_after = audio_region()->get_state();
1067 trackview.session()->add_command (new MementoCommand<AudioRegion>(*(audio_region().get()), ®ion_before, ®ion_after));
1070 audio_region()->envelope()->add (fx, y);
1072 XMLNode &after = audio_region()->envelope()->get_state();
1073 trackview.session()->add_command (new MementoCommand<AutomationList>(*audio_region()->envelope().get(), &before, &after));
1074 trackview.session()->commit_reversible_command ();
1078 AudioRegionView::remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent */*ev*/)
1080 ControlPoint *cp = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"));
1081 audio_region()->envelope()->erase (cp->model());
1085 AudioRegionView::setup_waveform_shape ()
1087 for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
1088 (*wave)->property_rectified() = Config->get_waveform_shape() == Rectified;
1093 AudioRegionView::setup_waveform_scale ()
1095 for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
1096 (*wave)->property_logscaled() = Config->get_waveform_scale() == Logarithmic;
1102 AudioRegionView::add_ghost (TimeAxisView& tv)
1104 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&trackview);
1107 double unit_position = _region->position () / samples_per_unit;
1108 AudioGhostRegion* ghost = new AudioGhostRegion (tv, trackview, unit_position);
1111 nchans = rtv->track()->n_channels().n_audio();
1113 for (uint32_t n = 0; n < nchans; ++n) {
1115 if (n >= audio_region()->n_channels()) {
1119 WaveView *wave = new WaveView(*ghost->group);
1121 wave->property_data_src() = _region.get();
1122 wave->property_cache() = wave_caches[n];
1123 wave->property_cache_updater() = false;
1124 wave->property_channel() = n;
1125 wave->property_length_function() = (gpointer)region_length_from_c;
1126 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
1127 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
1128 wave->property_x() = 0.0;
1129 wave->property_samples_per_unit() = samples_per_unit;
1130 wave->property_amplitude_above_axis() = _amplitude_above_axis;
1132 wave->property_region_start() = _region->start();
1134 ghost->waves.push_back(wave);
1137 ghost->set_height ();
1138 ghost->set_duration (_region->length() / samples_per_unit);
1139 ghost->set_colors();
1140 ghosts.push_back (ghost);
1146 AudioRegionView::entered (bool internal_editing)
1148 trackview.editor().set_current_trimmable (_region);
1149 trackview.editor().set_current_movable (_region);
1151 if (gain_line && trackview.editor().current_mouse_mode() == Editing::MouseGain) {
1152 gain_line->add_visibility (AutomationLine::ControlPoints);
1155 if (fade_in_handle && !internal_editing) {
1156 fade_in_handle->property_outline_color_rgba() = RGBA_TO_UINT (0, 0, 0, 255);
1157 fade_in_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 255);
1158 fade_out_handle->property_outline_color_rgba() = RGBA_TO_UINT (0, 0, 0, 255);
1159 fade_out_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 255);
1164 AudioRegionView::exited ()
1166 trackview.editor().set_current_trimmable (boost::shared_ptr<Trimmable>());
1167 trackview.editor().set_current_movable (boost::shared_ptr<Movable>());
1169 if (gain_line && trackview.editor().current_mouse_mode() == Editing::MouseGain) {
1170 gain_line->remove_visibility (AutomationLine::ControlPoints);
1173 if (fade_in_handle) {
1174 fade_in_handle->property_outline_color_rgba() = RGBA_TO_UINT (0, 0, 0, 0);
1175 fade_in_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 0);
1176 fade_out_handle->property_outline_color_rgba() = RGBA_TO_UINT (0, 0, 0, 0);
1177 fade_out_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 0);
1182 AudioRegionView::envelope_active_changed ()
1185 gain_line->set_line_color (audio_region()->envelope_active() ? ARDOUR_UI::config()->canvasvar_GainLine.get() : ARDOUR_UI::config()->canvasvar_GainLineInactive.get());
1190 AudioRegionView::set_waveview_data_src()
1192 AudioGhostRegion* agr;
1193 double unit_length= _region->length() / samples_per_unit;
1195 for (uint32_t n = 0; n < waves.size(); ++n) {
1196 // TODO: something else to let it know the channel
1197 waves[n]->property_data_src() = _region.get();
1200 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
1202 (*i)->set_duration (unit_length);
1204 if((agr = dynamic_cast<AudioGhostRegion*>(*i)) != 0) {
1205 for (vector<WaveView*>::iterator w = agr->waves.begin(); w != agr->waves.end(); ++w) {
1206 (*w)->property_data_src() = _region.get();
1214 AudioRegionView::color_handler ()
1216 //case cMutedWaveForm:
1218 //case cWaveFormClip:
1222 //case cGainLineInactive:
1224 envelope_active_changed();
1229 AudioRegionView::set_frame_color ()
1235 if (_region->opaque()) {
1241 TimeAxisViewItem::set_frame_color ();
1247 if (_region->muted()) {
1248 wc = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_SelectedWaveForm.get(), MUTED_ALPHA);
1250 wc = ARDOUR_UI::config()->canvasvar_SelectedWaveForm.get();
1252 fc = ARDOUR_UI::config()->canvasvar_SelectedWaveFormFill.get();
1255 if (_region->muted()) {
1256 wc = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_RecWaveForm.get(), MUTED_ALPHA);
1258 wc = ARDOUR_UI::config()->canvasvar_RecWaveForm.get();
1260 fc = ARDOUR_UI::config()->canvasvar_RecWaveFormFill.get();
1262 if (_region->muted()) {
1263 wc = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_WaveForm.get(), MUTED_ALPHA);
1265 wc = ARDOUR_UI::config()->canvasvar_WaveForm.get();
1267 fc = ARDOUR_UI::config()->canvasvar_WaveFormFill.get();
1271 for (vector<ArdourCanvas::WaveView*>::iterator w = waves.begin(); w != waves.end(); ++w) {
1272 if (_region->muted()) {
1273 (*w)->property_wave_color() = wc;
1275 (*w)->property_wave_color() = wc;
1276 (*w)->property_fill_color() = fc;
1282 AudioRegionView::set_fade_visibility (bool yn)
1285 if (fade_in_shape) {
1286 fade_in_shape->show();
1288 if (fade_out_shape) {
1289 fade_out_shape->show ();
1291 if (fade_in_handle) {
1292 fade_in_handle->show ();
1294 if (fade_out_handle) {
1295 fade_out_handle->show ();
1298 if (fade_in_shape) {
1299 fade_in_shape->hide();
1301 if (fade_out_shape) {
1302 fade_out_shape->hide ();
1304 if (fade_in_handle) {
1305 fade_in_handle->hide ();
1307 if (fade_out_handle) {
1308 fade_out_handle->hide ();
1314 AudioRegionView::update_coverage_frames (LayerDisplay d)
1316 RegionView::update_coverage_frames (d);
1318 if (fade_in_handle) {
1319 fade_in_handle->raise_to_top ();
1320 fade_out_handle->raise_to_top ();
1325 AudioRegionView::show_region_editor ()
1328 editor = new AudioRegionEditor (trackview.session(), audio_region());
1332 editor->set_position (Gtk::WIN_POS_MOUSE);
1338 AudioRegionView::show_fade_line (framepos_t pos)
1340 fade_position_line->property_x1() = trackview.editor().frame_to_pixel (pos);
1341 fade_position_line->property_x2() = trackview.editor().frame_to_pixel (pos);
1342 fade_position_line->show ();
1343 fade_position_line->raise_to_top ();
1347 AudioRegionView::hide_fade_line ()
1349 fade_position_line->hide ();
1354 AudioRegionView::transients_changed ()
1356 AnalysisFeatureList analysis_features = _region->transients();
1358 while (feature_lines.size() < analysis_features.size()) {
1360 ArdourCanvas::Line* canvas_item = new ArdourCanvas::Line(*group);
1362 ArdourCanvas::Points points;
1364 points.push_back(Gnome::Art::Point(-1.0, 2.0)); // first x-coord needs to be a non-normal value
1365 points.push_back(Gnome::Art::Point(1.0, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1));
1367 canvas_item->property_points() = points;
1368 canvas_item->property_width_pixels() = 1;
1369 canvas_item->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ZeroLine.get();
1370 canvas_item->property_first_arrowhead() = TRUE;
1371 canvas_item->property_last_arrowhead() = TRUE;
1372 canvas_item->property_arrow_shape_a() = 11.0;
1373 canvas_item->property_arrow_shape_b() = 0.0;
1374 canvas_item->property_arrow_shape_c() = 4.0;
1376 canvas_item->raise_to_top ();
1377 canvas_item->show ();
1379 canvas_item->set_data ("regionview", this);
1380 canvas_item->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_feature_line_event), canvas_item, this));
1382 feature_lines.push_back (make_pair(0, canvas_item));
1385 while (feature_lines.size() > analysis_features.size()) {
1386 ArdourCanvas::Line* line = feature_lines.back().second;
1387 feature_lines.pop_back ();
1391 AnalysisFeatureList::const_iterator i;
1392 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
1394 for (i = analysis_features.begin(), l = feature_lines.begin(); i != analysis_features.end() && l != feature_lines.end(); ++i, ++l) {
1396 ArdourCanvas::Points points;
1398 float *pos = new float;
1399 *pos = trackview.editor().frame_to_pixel (*i);
1401 points.push_back(Gnome::Art::Point(*pos, 2.0)); // first x-coord needs to be a non-normal value
1402 points.push_back(Gnome::Art::Point(*pos, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1));
1404 (*l).second->property_points() = points;
1405 (*l).second->set_data ("position", pos);
1412 AudioRegionView::update_transient(float /*old_pos*/, float new_pos)
1414 /* Find frame at old pos, calulate new frame then update region transients*/
1415 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
1417 for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
1419 /* Line has been updated in drag so we compare to new_pos */
1421 float* pos = (float*) (*l).second->get_data ("position");
1423 if (rint(new_pos) == rint(*pos)) {
1425 framepos_t old_frame = (*l).first;
1426 framepos_t new_frame = trackview.editor().pixel_to_frame (new_pos);
1428 _region->update_transient (old_frame, new_frame);
1436 AudioRegionView::remove_transient(float pos)
1438 /* Find frame at old pos, calulate new frame then update region transients*/
1439 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
1441 for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
1443 /* Line has been updated in drag so we compare to new_pos */
1444 float *line_pos = (float*) (*l).second->get_data ("position");
1446 if (rint(pos) == rint(*line_pos)) {
1447 _region->remove_transient ((*l).first);
1454 AudioRegionView::thaw_after_trim ()
1456 RegionView::thaw_after_trim ();
1462 AudioRegionView::redraw_start_xfade ()
1464 boost::shared_ptr<AudioRegion> ar (audio_region());
1466 if (!ar->fade_in() || ar->fade_in()->empty()) {
1470 if (!ar->fade_in_is_xfade()) {
1471 if (start_xfade_in) {
1472 start_xfade_in->hide ();
1473 start_xfade_out->hide ();
1474 start_xfade_rect->hide ();
1475 _start_xfade_visible = false;
1480 redraw_start_xfade_to (ar, ar->fade_in()->back()->when);
1484 AudioRegionView::redraw_start_xfade_to (boost::shared_ptr<AudioRegion> ar, framecnt_t len)
1486 int32_t const npoints = trackview.editor().frame_to_pixel (len);
1492 if (!start_xfade_in) {
1493 start_xfade_in = new ArdourCanvas::Line (*group);
1494 start_xfade_in->property_width_pixels() = 1;
1495 start_xfade_in->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GainLine.get();
1498 if (!start_xfade_out) {
1499 start_xfade_out = new ArdourCanvas::Line (*group);
1500 start_xfade_out->property_width_pixels() = 1;
1501 uint32_t col = UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->canvasvar_GainLine.get(), 125);
1502 start_xfade_out->property_fill_color_rgba() = col;
1505 if (!start_xfade_rect) {
1506 start_xfade_rect = new ArdourCanvas::SimpleRect (*group);
1507 start_xfade_rect->property_draw() = true;
1508 start_xfade_rect->property_fill() = true;;
1509 start_xfade_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ActiveCrossfade.get();
1510 start_xfade_rect->property_outline_pixels() = 0;
1511 start_xfade_rect->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_start_xfade_event), start_xfade_rect, this));
1512 start_xfade_rect->set_data ("regionview", this);
1515 Points* points = get_canvas_points ("xfade edit redraw", npoints);
1516 boost::scoped_array<float> vec (new float[npoints]);
1517 double effective_height = _height - NAME_HIGHLIGHT_SIZE - 1.0;
1519 ar->fade_in()->curve().get_vector (0, ar->fade_in()->back()->when, vec.get(), npoints);
1521 for (int i = 0, pci = 0; i < npoints; ++i) {
1522 Gnome::Art::Point &p ((*points)[pci++]);
1524 p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
1527 start_xfade_rect->property_x1() = ((*points)[0]).get_x();
1528 start_xfade_rect->property_y1() = 1.0;
1529 start_xfade_rect->property_x2() = ((*points)[npoints-1]).get_x();
1530 start_xfade_rect->property_y2() = effective_height;
1531 start_xfade_rect->show ();
1532 start_xfade_rect->raise_to_top ();
1534 start_xfade_in->property_points() = *points;
1535 start_xfade_in->show ();
1536 start_xfade_in->raise_to_top ();
1540 boost::shared_ptr<AutomationList> inverse = ar->inverse_fade_in();
1544 for (int i = 0, pci = 0; i < npoints; ++i) {
1545 Gnome::Art::Point &p ((*points)[pci++]);
1547 p.set_y (1.0 + effective_height - (effective_height * (1.0 - vec.get()[i])));
1552 inverse->curve().get_vector (0, inverse->back()->when, vec.get(), npoints);
1554 for (int i = 0, pci = 0; i < npoints; ++i) {
1555 Gnome::Art::Point &p ((*points)[pci++]);
1557 p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
1561 start_xfade_out->property_points() = *points;
1562 start_xfade_out->show ();
1563 start_xfade_out->raise_to_top ();
1565 _start_xfade_visible = true;
1571 AudioRegionView::redraw_end_xfade ()
1573 boost::shared_ptr<AudioRegion> ar (audio_region());
1575 if (!ar->fade_out() || ar->fade_out()->empty()) {
1579 if (!ar->fade_out_is_xfade()) {
1581 end_xfade_in->hide ();
1582 end_xfade_out->hide ();
1583 end_xfade_rect->hide ();
1584 _end_xfade_visible = false;
1589 redraw_end_xfade_to (ar, ar->fade_out()->back()->when);
1593 AudioRegionView::redraw_end_xfade_to (boost::shared_ptr<AudioRegion> ar, framecnt_t len)
1595 int32_t const npoints = trackview.editor().frame_to_pixel (len);
1601 if (!end_xfade_in) {
1602 end_xfade_in = new ArdourCanvas::Line (*group);
1603 end_xfade_in->property_width_pixels() = 1;
1604 end_xfade_in->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GainLine.get();
1607 if (!end_xfade_out) {
1608 end_xfade_out = new ArdourCanvas::Line (*group);
1609 end_xfade_out->property_width_pixels() = 1;
1610 uint32_t col UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->canvasvar_GainLine.get(), 125);
1611 end_xfade_out->property_fill_color_rgba() = col;
1614 if (!end_xfade_rect) {
1615 end_xfade_rect = new ArdourCanvas::SimpleRect (*group);
1616 end_xfade_rect->property_draw() = true;
1617 end_xfade_rect->property_fill() = true;;
1618 end_xfade_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ActiveCrossfade.get();
1619 end_xfade_rect->property_outline_pixels() = 0;
1620 end_xfade_rect->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_end_xfade_event), end_xfade_rect, this));
1621 end_xfade_rect->set_data ("regionview", this);
1624 Points* points = get_canvas_points ("xfade edit redraw", npoints);
1625 boost::scoped_ptr<float> vec (new float[npoints]);
1627 ar->fade_out()->curve().get_vector (0, ar->fade_out()->back()->when, vec.get(), npoints);
1629 double rend = trackview.editor().frame_to_pixel (_region->length() - len);
1630 double effective_height = _height - NAME_HIGHLIGHT_SIZE - 1;
1632 for (int i = 0, pci = 0; i < npoints; ++i) {
1633 Gnome::Art::Point &p ((*points)[pci++]);
1635 p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
1638 end_xfade_rect->property_x1() = ((*points)[0]).get_x();
1639 end_xfade_rect->property_y1() = 1;
1640 end_xfade_rect->property_x2() = ((*points)[npoints-1]).get_x();
1641 end_xfade_rect->property_y2() = effective_height;
1642 end_xfade_rect->show ();
1643 end_xfade_rect->raise_to_top ();
1645 end_xfade_in->property_points() = *points;
1646 end_xfade_in->show ();
1647 end_xfade_in->raise_to_top ();
1651 boost::shared_ptr<AutomationList> inverse = ar->inverse_fade_out ();
1655 for (int i = 0, pci = 0; i < npoints; ++i) {
1656 Gnome::Art::Point &p ((*points)[pci++]);
1658 p.set_y (1.0 + effective_height - (effective_height * (1.0 - vec.get()[i])));
1663 inverse->curve().get_vector (inverse->front()->when, inverse->back()->when, vec.get(), npoints);
1665 for (int i = 0, pci = 0; i < npoints; ++i) {
1666 Gnome::Art::Point &p ((*points)[pci++]);
1668 p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
1672 end_xfade_out->property_points() = *points;
1673 end_xfade_out->show ();
1674 end_xfade_out->raise_to_top ();
1676 _end_xfade_visible = true;
1682 AudioRegionView::hide_xfades ()
1684 hide_start_xfade ();
1689 AudioRegionView::hide_start_xfade ()
1691 if (start_xfade_in) {
1692 start_xfade_in->hide();
1694 if (start_xfade_out) {
1695 start_xfade_out->hide();
1697 if (start_xfade_rect) {
1698 start_xfade_rect->hide ();
1701 _start_xfade_visible = false;
1705 AudioRegionView::hide_end_xfade ()
1708 end_xfade_in->hide();
1710 if (end_xfade_out) {
1711 end_xfade_out->hide();
1713 if (end_xfade_rect) {
1714 end_xfade_rect->hide ();
1717 _end_xfade_visible = false;
1721 AudioRegionView::show_start_xfade ()
1723 if (start_xfade_in) {
1724 start_xfade_in->show();
1726 if (start_xfade_out) {
1727 start_xfade_out->show();
1729 if (start_xfade_rect) {
1730 start_xfade_rect->show ();
1733 _start_xfade_visible = true;
1737 AudioRegionView::show_end_xfade ()
1740 end_xfade_in->show();
1742 if (end_xfade_out) {
1743 end_xfade_out->show();
1745 if (end_xfade_rect) {
1746 end_xfade_rect->show ();
1749 _end_xfade_visible = true;
1753 AudioRegionView::show_xfades ()
1755 show_start_xfade ();
1760 AudioRegionView::drag_start ()
1762 TimeAxisViewItem::drag_start ();
1763 AudioTimeAxisView* atav = dynamic_cast<AudioTimeAxisView*> (&trackview);
1766 AudioStreamView* av = atav->audio_view();
1768 /* this will hide our xfades too */
1769 _hidden_xfades = av->hide_xfades_with (audio_region());
1775 AudioRegionView::drag_end ()
1777 TimeAxisViewItem::drag_end ();
1779 for (list<AudioRegionView*>::iterator i = _hidden_xfades.first.begin(); i != _hidden_xfades.first.end(); ++i) {
1780 (*i)->show_start_xfade ();
1783 for (list<AudioRegionView*>::iterator i = _hidden_xfades.second.begin(); i != _hidden_xfades.second.end(); ++i) {
1784 (*i)->show_end_xfade ();
1787 _hidden_xfades.first.clear ();
1788 _hidden_xfades.second.clear ();
1792 AudioRegionView::parameter_changed (string const & p)
1794 if (p == "show-waveforms") {
1795 setup_waveform_visibility ();
1796 } else if (p == "waveform-scale") {
1797 setup_waveform_scale ();
1798 } else if (p == "waveform-shape") {
1799 setup_waveform_shape ();