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;
70 AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, boost::shared_ptr<AudioRegion> r, double spu,
71 Gdk::Color const & basic_color)
72 : RegionView (parent, tv, r, spu, basic_color)
78 , fade_position_line(0)
81 , start_xfade_rect (0)
85 , _amplitude_above_axis(1.0)
91 AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, boost::shared_ptr<AudioRegion> r, double spu,
92 Gdk::Color const & basic_color, bool recording, TimeAxisViewItem::Visibility visibility)
93 : RegionView (parent, tv, r, spu, basic_color, recording, visibility)
99 , fade_position_line(0)
101 , start_xfade_out (0)
102 , start_xfade_rect (0)
106 , _amplitude_above_axis(1.0)
112 AudioRegionView::AudioRegionView (const AudioRegionView& other, boost::shared_ptr<AudioRegion> other_region)
113 : RegionView (other, boost::shared_ptr<Region> (other_region))
118 , fade_position_line(0)
120 , start_xfade_out (0)
121 , start_xfade_rect (0)
125 , _amplitude_above_axis (other._amplitude_above_axis)
126 , _flags (other._flags)
132 UINT_TO_RGBA (other.fill_color, &r, &g, &b, &a);
133 c.set_rgb_p (r/255.0, g/255.0, b/255.0);
139 AudioRegionView::init (Gdk::Color const & basic_color, bool wfd)
141 // FIXME: Some redundancy here with RegionView::init. Need to figure out
142 // where order is important and where it isn't...
144 RegionView::init (basic_color, wfd);
148 _amplitude_above_axis = 1.0;
151 if ((node = _region->extra_xml ("GUI")) != 0) {
154 _flags = WaveformVisible;
158 compute_colors (basic_color);
162 fade_in_shape = new ArdourCanvas::Polygon (*group);
163 fade_in_shape->property_fill_color_rgba() = fade_color;
164 fade_in_shape->set_data ("regionview", this);
166 fade_out_shape = new ArdourCanvas::Polygon (*group);
167 fade_out_shape->property_fill_color_rgba() = fade_color;
168 fade_out_shape->set_data ("regionview", this);
171 fade_in_handle = new ArdourCanvas::SimpleRect (*group);
172 fade_in_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fill_color, 0);
173 fade_in_handle->property_outline_pixels() = 0;
175 fade_in_handle->set_data ("regionview", this);
177 fade_out_handle = new ArdourCanvas::SimpleRect (*group);
178 fade_out_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fill_color, 0);
179 fade_out_handle->property_outline_pixels() = 0;
181 fade_out_handle->set_data ("regionview", this);
183 fade_position_line = new ArdourCanvas::SimpleLine (*group);
184 fade_position_line->property_color_rgba() = 0xBBBBBBAA;
185 fade_position_line->property_y1() = 7;
186 fade_position_line->property_y2() = _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1;
188 fade_position_line->hide();
191 setup_fade_handle_positions ();
193 if (!trackview.session()->config.get_show_region_fades()) {
194 set_fade_visibility (false);
197 const string line_name = _region->name() + ":gain";
199 if (!Profile->get_sae()) {
200 gain_line.reset (new AudioRegionGainLine (line_name, *this, *group, audio_region()->envelope()));
203 update_envelope_visibility ();
206 set_height (trackview.current_height());
209 region_sync_changed ();
211 region_resized (ARDOUR::bounds_change);
212 set_waveview_data_src();
214 envelope_active_changed ();
215 fade_in_active_changed ();
216 fade_out_active_changed ();
218 reset_width_dependent_items (_pixel_width);
220 fade_in_shape->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_event), fade_in_shape, this));
221 if (fade_in_handle) {
222 fade_in_handle->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_handle_event), fade_in_handle, this));
225 fade_out_shape->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_event), fade_out_shape, this));
227 if (fade_out_handle) {
228 fade_out_handle->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_handle_event), fade_out_handle, this));
233 /* XXX sync mark drag? */
236 AudioRegionView::~AudioRegionView ()
238 in_destructor = true;
240 RegionViewGoingAway (this); /* EMIT_SIGNAL */
242 for (vector<GnomeCanvasWaveViewCache *>::iterator cache = wave_caches.begin(); cache != wave_caches.end() ; ++cache) {
243 gnome_canvas_waveview_cache_destroy (*cache);
246 for (vector<ScopedConnection*>::iterator i = _data_ready_connections.begin(); i != _data_ready_connections.end(); ++i) {
250 for (list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator i = feature_lines.begin(); i != feature_lines.end(); ++i) {
251 delete ((*i).second);
254 /* all waveviews etc will be destroyed when the group is destroyed */
257 boost::shared_ptr<ARDOUR::AudioRegion>
258 AudioRegionView::audio_region() const
260 // "Guaranteed" to succeed...
261 return boost::dynamic_pointer_cast<AudioRegion>(_region);
265 AudioRegionView::region_changed (const PropertyChange& what_changed)
267 ENSURE_GUI_THREAD (*this, &AudioRegionView::region_changed, what_changed);
268 // cerr << "AudioRegionView::region_changed() called" << endl;
270 RegionView::region_changed (what_changed);
272 if (what_changed.contains (ARDOUR::Properties::scale_amplitude)) {
273 region_scale_amplitude_changed ();
275 if (what_changed.contains (ARDOUR::Properties::fade_in)) {
278 if (what_changed.contains (ARDOUR::Properties::fade_out)) {
281 if (what_changed.contains (ARDOUR::Properties::fade_in_active)) {
282 fade_in_active_changed ();
284 if (what_changed.contains (ARDOUR::Properties::fade_out_active)) {
285 fade_out_active_changed ();
287 if (what_changed.contains (ARDOUR::Properties::envelope_active)) {
288 envelope_active_changed ();
290 if (what_changed.contains (ARDOUR::Properties::valid_transients)) {
291 transients_changed ();
296 AudioRegionView::fade_in_changed ()
298 reset_fade_in_shape ();
302 AudioRegionView::fade_out_changed ()
304 reset_fade_out_shape ();
308 AudioRegionView::fade_in_active_changed ()
310 if (audio_region()->fade_in_active()) {
311 fade_in_shape->property_fill_color_rgba() = RGBA_TO_UINT(45,45,45,90); // FIXME make a themeable colour
312 fade_in_shape->property_width_pixels() = 1;
314 fade_in_shape->property_fill_color_rgba() = RGBA_TO_UINT(45,45,45,20); // FIXME make a themeable colour
315 fade_in_shape->property_width_pixels() = 1;
320 AudioRegionView::fade_out_active_changed ()
322 if (audio_region()->fade_out_active()) {
323 fade_out_shape->property_fill_color_rgba() = RGBA_TO_UINT(45,45,45,90); // FIXME make a themeable colour
324 fade_out_shape->property_width_pixels() = 1;
326 fade_out_shape->property_fill_color_rgba() = RGBA_TO_UINT(45,45,45,20); // FIXME make a themeable colour
327 fade_out_shape->property_width_pixels() = 1;
333 AudioRegionView::region_scale_amplitude_changed ()
335 ENSURE_GUI_THREAD (*this, &AudioRegionView::region_scale_amplitude_changed)
337 for (uint32_t n = 0; n < waves.size(); ++n) {
338 // force a reload of the cache
339 waves[n]->property_data_src() = _region.get();
344 AudioRegionView::region_renamed ()
346 std::string str = RegionView::make_name ();
348 if (audio_region()->speed_mismatch (trackview.session()->frame_rate())) {
349 str = string ("*") + str;
352 if (_region->muted()) {
353 str = string ("!") + str;
356 set_item_name (str, this);
361 AudioRegionView::region_resized (const PropertyChange& what_changed)
363 AudioGhostRegion* agr;
365 RegionView::region_resized(what_changed);
366 PropertyChange interesting_stuff;
368 interesting_stuff.add (ARDOUR::Properties::start);
369 interesting_stuff.add (ARDOUR::Properties::length);
371 if (what_changed.contains (interesting_stuff)) {
373 for (uint32_t n = 0; n < waves.size(); ++n) {
374 waves[n]->property_region_start() = _region->start();
377 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
378 if ((agr = dynamic_cast<AudioGhostRegion*>(*i)) != 0) {
380 for (vector<WaveView*>::iterator w = agr->waves.begin(); w != agr->waves.end(); ++w) {
381 (*w)->property_region_start() = _region->start();
386 /* hide transient lines that extend beyond the region end */
388 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
390 for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
391 if (l->first > _region->length() - 1) {
401 AudioRegionView::reset_width_dependent_items (double pixel_width)
403 RegionView::reset_width_dependent_items(pixel_width);
404 assert(_pixel_width == pixel_width);
406 if (fade_in_handle) {
407 if (pixel_width <= 6.0 || _height < 5.0 || !trackview.session()->config.get_show_region_fades()) {
408 fade_in_handle->hide();
409 fade_out_handle->hide();
412 fade_in_handle->show();
413 fade_out_handle->show();
417 AnalysisFeatureList analysis_features = _region->transients();
418 AnalysisFeatureList::const_iterator i;
420 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
422 for (i = analysis_features.begin(), l = feature_lines.begin(); i != analysis_features.end() && l != feature_lines.end(); ++i, ++l) {
424 float x_pos = trackview.editor().frame_to_pixel (*i);
426 ArdourCanvas::Points points;
427 points.push_back(Gnome::Art::Point(x_pos, 2.0)); // first x-coord needs to be a non-normal value
428 points.push_back(Gnome::Art::Point(x_pos, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1));
431 (*l).second->property_points() = points;
434 reset_fade_shapes ();
438 AudioRegionView::region_muted ()
440 RegionView::region_muted();
442 for (uint32_t n=0; n < waves.size(); ++n) {
443 if (_region->muted()) {
444 waves[n]->property_wave_color() = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_WaveForm.get(), MUTED_ALPHA);
446 waves[n]->property_wave_color() = ARDOUR_UI::config()->canvasvar_WaveForm.get();
452 AudioRegionView::setup_fade_handle_positions()
454 /* position of fade handle offset from the top of the region view */
455 double const handle_pos = 2;
456 /* height of fade handles */
457 double const handle_height = 5;
459 if (fade_in_handle) {
460 fade_in_handle->property_y1() = handle_pos;
461 fade_in_handle->property_y2() = handle_pos + handle_height;
464 if (fade_out_handle) {
465 fade_out_handle->property_y1() = handle_pos;
466 fade_out_handle->property_y2() = handle_pos + handle_height;
471 AudioRegionView::set_height (gdouble height)
473 RegionView::set_height (height);
475 uint32_t wcnt = waves.size();
477 for (uint32_t n = 0; n < wcnt; ++n) {
480 if (height < NAME_HIGHLIGHT_THRESH) {
481 ht = ((height - 2 * wcnt) / (double) wcnt);
483 ht = (((height - 2 * wcnt) - NAME_HIGHLIGHT_SIZE) / (double) wcnt);
486 gdouble yoff = n * (ht + 1);
488 waves[n]->property_height() = ht;
489 waves[n]->property_y() = yoff + 2;
494 if ((height/wcnt) < NAME_HIGHLIGHT_THRESH) {
497 update_envelope_visibility ();
500 gain_line->set_height ((uint32_t) rint (height - NAME_HIGHLIGHT_SIZE) - 2);
503 reset_fade_shapes ();
505 /* Update hights for any active feature lines */
506 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
508 for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
510 float pos_x = trackview.editor().frame_to_pixel((*l).first);
512 ArdourCanvas::Points points;
514 points.push_back(Gnome::Art::Point(pos_x, 2.0)); // first x-coord needs to be a non-normal value
515 points.push_back(Gnome::Art::Point(pos_x, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1));
517 (*l).second->property_points() = points;
520 if (fade_position_line) {
522 if (height < NAME_HIGHLIGHT_THRESH) {
523 fade_position_line->property_y2() = _height - 1;
526 fade_position_line->property_y2() = _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1;
531 name_pixbuf->raise_to_top();
536 AudioRegionView::reset_fade_shapes ()
538 reset_fade_in_shape ();
539 reset_fade_out_shape ();
543 AudioRegionView::reset_fade_in_shape ()
545 reset_fade_in_shape_width ((framecnt_t) audio_region()->fade_in()->back()->when);
549 AudioRegionView::reset_fade_in_shape_width (framecnt_t width)
555 if (audio_region()->fade_in_is_xfade()) {
556 if (fade_in_handle) {
557 fade_in_handle->hide ();
558 fade_in_shape->hide ();
560 redraw_start_xfade ();
563 if (start_xfade_in) {
564 start_xfade_in->hide ();
565 start_xfade_out->hide ();
566 start_xfade_rect->hide ();
570 if (fade_in_handle == 0) {
574 fade_in_handle->show ();
576 /* smallest size for a fade is 64 frames */
578 width = std::max ((framecnt_t) 64, width);
582 /* round here to prevent little visual glitches with sub-pixel placement */
583 double const pwidth = rint (width / samples_per_unit);
584 uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth);
588 fade_in_shape->hide();
589 fade_in_handle->hide();
593 double const handle_center = pwidth;
595 /* Put the fade in handle so that its left side is at the end-of-fade line */
596 fade_in_handle->property_x1() = handle_center;
597 fade_in_handle->property_x2() = handle_center + 6;
600 fade_in_shape->hide();
604 if (trackview.session()->config.get_show_region_fades()) {
605 fade_in_shape->show();
608 float curve[npoints];
609 audio_region()->fade_in()->curve().get_vector (0, audio_region()->fade_in()->back()->when, curve, npoints);
611 points = get_canvas_points ("fade in shape", npoints + 3);
613 if (_height >= NAME_HIGHLIGHT_THRESH) {
614 h = _height - NAME_HIGHLIGHT_SIZE - 2;
619 /* points *MUST* be in anti-clockwise order */
622 double xdelta = pwidth/npoints;
624 for (pi = 0, pc = 0; pc < npoints; ++pc) {
625 (*points)[pi].set_x(1 + (pc * xdelta));
626 (*points)[pi++].set_y(2 + (h - (curve[pc] * h)));
631 (*points)[pi].set_x(pwidth);
632 (*points)[pi++].set_y(2);
634 (*points)[pi].set_x(1);
635 (*points)[pi++].set_y(2);
637 /* connect the dots ... */
639 (*points)[pi] = (*points)[0];
641 fade_in_shape->property_points() = *points;
644 /* ensure trim handle stays on top */
645 if (frame_handle_start) {
646 frame_handle_start->raise_to_top();
651 AudioRegionView::reset_fade_out_shape ()
653 reset_fade_out_shape_width ((framecnt_t) audio_region()->fade_out()->back()->when);
657 AudioRegionView::reset_fade_out_shape_width (framecnt_t width)
659 if (dragging() && audio_region()->fade_out_is_xfade()) {
660 /* we hide xfades while dragging regions */
664 if (audio_region()->fade_out_is_xfade()) {
665 if (fade_out_handle) {
666 fade_out_handle->hide ();
667 fade_out_shape->hide ();
673 end_xfade_in->hide ();
674 end_xfade_out->hide ();
675 end_xfade_rect->hide ();
679 if (fade_out_handle == 0) {
683 fade_out_handle->show ();
685 /* smallest size for a fade is 64 frames */
687 width = std::max ((framecnt_t) 64, width);
691 /* round here to prevent little visual glitches with sub-pixel placement */
692 double const pwidth = rint (width / samples_per_unit);
693 uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth);
697 fade_out_shape->hide();
698 fade_out_handle->hide();
702 double const handle_center = (_region->length() - width) / samples_per_unit;
704 /* Put the fade out handle so that its right side is at the end-of-fade line;
705 * it's `one out' for precise pixel accuracy.
707 fade_out_handle->property_x1() = handle_center - 5;
708 fade_out_handle->property_x2() = handle_center + 1;
710 /* don't show shape if its too small */
713 fade_out_shape->hide();
717 if (trackview.session()->config.get_show_region_fades()) {
718 fade_out_shape->show();
721 float curve[npoints];
722 audio_region()->fade_out()->curve().get_vector (0, audio_region()->fade_out()->back()->when, curve, npoints);
724 if (_height >= NAME_HIGHLIGHT_THRESH) {
725 h = _height - NAME_HIGHLIGHT_SIZE - 2;
730 /* points *MUST* be in anti-clockwise order */
732 points = get_canvas_points ("fade out shape", npoints + 3);
735 double xdelta = pwidth/npoints;
737 for (pi = 0, pc = 0; pc < npoints; ++pc) {
738 (*points)[pi].set_x(_pixel_width - pwidth + (pc * xdelta));
739 (*points)[pi++].set_y(2 + (h - (curve[pc] * h)));
744 (*points)[pi].set_x(_pixel_width);
745 (*points)[pi++].set_y(h);
747 (*points)[pi].set_x(_pixel_width);
748 (*points)[pi++].set_y(2);
750 /* connect the dots ... */
752 (*points)[pi] = (*points)[0];
754 fade_out_shape->property_points() = *points;
757 /* ensure trim handle stays on top */
758 if (frame_handle_end) {
759 frame_handle_end->raise_to_top();
764 AudioRegionView::set_samples_per_unit (gdouble spu)
766 RegionView::set_samples_per_unit (spu);
768 if (_flags & WaveformVisible) {
769 for (uint32_t n=0; n < waves.size(); ++n) {
770 waves[n]->property_samples_per_unit() = spu;
778 reset_fade_shapes ();
782 AudioRegionView::set_amplitude_above_axis (gdouble spp)
784 for (uint32_t n=0; n < waves.size(); ++n) {
785 waves[n]->property_amplitude_above_axis() = spp;
790 AudioRegionView::compute_colors (Gdk::Color const & basic_color)
792 RegionView::compute_colors (basic_color);
794 /* gain color computed in envelope_active_changed() */
796 fade_color = UINT_RGBA_CHANGE_A (fill_color, 120);
800 AudioRegionView::set_colors ()
802 RegionView::set_colors();
805 gain_line->set_line_color (audio_region()->envelope_active() ? ARDOUR_UI::config()->canvasvar_GainLine.get() : ARDOUR_UI::config()->canvasvar_GainLineInactive.get());
808 for (uint32_t n=0; n < waves.size(); ++n) {
809 if (_region->muted()) {
810 waves[n]->property_wave_color() = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_WaveForm.get(), MUTED_ALPHA);
812 waves[n]->property_wave_color() = ARDOUR_UI::config()->canvasvar_WaveForm.get();
815 waves[n]->property_clip_color() = ARDOUR_UI::config()->canvasvar_WaveFormClip.get();
816 waves[n]->property_zero_color() = ARDOUR_UI::config()->canvasvar_ZeroLine.get();
821 AudioRegionView::set_waveform_visible (bool yn)
823 if (((_flags & WaveformVisible) != yn)) {
825 for (uint32_t n=0; n < waves.size(); ++n) {
826 /* make sure the zoom level is correct, since we don't update
827 this when waveforms are hidden.
829 waves[n]->property_samples_per_unit() = samples_per_unit;
832 _flags |= WaveformVisible;
834 for (uint32_t n=0; n < waves.size(); ++n) {
837 _flags &= ~WaveformVisible;
844 AudioRegionView::temporarily_hide_envelope ()
852 AudioRegionView::unhide_envelope ()
854 update_envelope_visibility ();
858 AudioRegionView::update_envelope_visibility ()
864 if (Config->get_show_region_gain() || trackview.editor().current_mouse_mode() == Editing::MouseGain) {
865 gain_line->add_visibility (AutomationLine::Line);
872 AudioRegionView::create_waves ()
874 // cerr << "AudioRegionView::create_waves() called on " << this << endl;//DEBUG
875 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
881 ChanCount nchans = atv.track()->n_channels();
883 // cerr << "creating waves for " << _region->name() << " with wfd = " << wait_for_data
884 // << " and channels = " << nchans.n_audio() << endl;
886 /* in tmp_waves, set up null pointers for each channel so the vector is allocated */
887 for (uint32_t n = 0; n < nchans.n_audio(); ++n) {
888 tmp_waves.push_back (0);
891 for (vector<ScopedConnection*>::iterator i = _data_ready_connections.begin(); i != _data_ready_connections.end(); ++i) {
895 _data_ready_connections.clear ();
897 for (uint32_t i = 0; i < nchans.n_audio(); ++i) {
898 _data_ready_connections.push_back (0);
901 for (uint32_t n = 0; n < nchans.n_audio(); ++n) {
903 if (n >= audio_region()->n_channels()) {
907 wave_caches.push_back (WaveView::create_cache ());
909 // cerr << "\tchannel " << n << endl;
912 if (audio_region()->audio_source(n)->peaks_ready (boost::bind (&AudioRegionView::peaks_ready_handler, this, n), &_data_ready_connections[n], gui_context())) {
913 // cerr << "\tData is ready\n";
914 create_one_wave (n, true);
916 // cerr << "\tdata is not ready\n";
917 // we'll get a PeaksReady signal from the source in the future
918 // and will call create_one_wave(n) then.
922 // cerr << "\tdon't delay, display today!\n";
923 create_one_wave (n, true);
930 AudioRegionView::create_one_wave (uint32_t which, bool /*direct*/)
932 //cerr << "AudioRegionView::create_one_wave() called which: " << which << " this: " << this << endl;//DEBUG
933 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
934 uint32_t nchans = atv.track()->n_channels().n_audio();
936 uint32_t nwaves = std::min (nchans, audio_region()->n_channels());
939 if (trackview.current_height() < NAME_HIGHLIGHT_THRESH) {
940 ht = ((trackview.current_height()) / (double) nchans);
942 ht = ((trackview.current_height() - NAME_HIGHLIGHT_SIZE) / (double) nchans);
945 gdouble yoff = which * ht;
947 WaveView *wave = new WaveView(*group);
949 wave->property_data_src() = (gpointer) _region.get();
950 wave->property_cache() = wave_caches[which];
951 wave->property_cache_updater() = true;
952 wave->property_channel() = which;
953 wave->property_length_function() = (gpointer) region_length_from_c;
954 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
955 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
956 wave->property_x() = 0.0;
957 wave->property_y() = yoff;
958 wave->property_height() = (double) ht;
959 wave->property_samples_per_unit() = samples_per_unit;
960 wave->property_amplitude_above_axis() = _amplitude_above_axis;
963 wave->property_wave_color() = _region->muted() ? UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_RecWaveForm.get(), MUTED_ALPHA) : ARDOUR_UI::config()->canvasvar_RecWaveForm.get();
964 wave->property_fill_color() = ARDOUR_UI::config()->canvasvar_RecWaveFormFill.get();
966 wave->property_wave_color() = _region->muted() ? UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_WaveForm.get(), MUTED_ALPHA) : ARDOUR_UI::config()->canvasvar_WaveForm.get();
967 wave->property_fill_color() = ARDOUR_UI::config()->canvasvar_WaveFormFill.get();
970 wave->property_clip_color() = ARDOUR_UI::config()->canvasvar_WaveFormClip.get();
971 wave->property_zero_color() = ARDOUR_UI::config()->canvasvar_ZeroLine.get();
972 wave->property_zero_line() = true;
973 wave->property_region_start() = _region->start();
974 wave->property_rectified() = (bool) (_flags & WaveformRectified);
975 wave->property_logscaled() = (bool) (_flags & WaveformLogScaled);
977 if (!(_flags & WaveformVisible)) {
981 /* note: calling this function is serialized by the lock
982 held in the peak building thread that signals that
983 peaks are ready for use *or* by the fact that it is
984 called one by one from the GUI thread.
987 if (which < nchans) {
988 tmp_waves[which] = wave;
990 /* n-channel track, >n-channel source */
993 /* see if we're all ready */
995 for (n = 0; n < nchans; ++n) {
996 if (tmp_waves[n] == 0) {
1001 if (n == nwaves && waves.empty()) {
1002 /* all waves are ready */
1003 tmp_waves.resize(nwaves);
1008 /* all waves created, don't hook into peaks ready anymore */
1009 delete _data_ready_connections[which];
1010 _data_ready_connections[which] = 0;
1015 AudioRegionView::peaks_ready_handler (uint32_t which)
1017 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&AudioRegionView::create_one_wave, this, which, false));
1018 // cerr << "AudioRegionView::peaks_ready_handler() called on " << which << " this: " << this << endl;
1022 AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
1030 /* don't create points that can't be seen */
1032 update_envelope_visibility ();
1039 framepos_t fx = trackview.editor().pixel_to_frame (x);
1041 if (fx > _region->length()) {
1045 /* compute vertical fractional position */
1047 y = 1.0 - (y / (_height - NAME_HIGHLIGHT_SIZE));
1049 /* map using gain line */
1051 gain_line->view_to_model_coord (x, y);
1053 /* XXX STATEFUL: can't convert to stateful diff until we
1054 can represent automation data with it.
1057 trackview.session()->begin_reversible_command (_("add gain control point"));
1058 XMLNode &before = audio_region()->envelope()->get_state();
1060 if (!audio_region()->envelope_active()) {
1061 XMLNode ®ion_before = audio_region()->get_state();
1062 audio_region()->set_envelope_active(true);
1063 XMLNode ®ion_after = audio_region()->get_state();
1064 trackview.session()->add_command (new MementoCommand<AudioRegion>(*(audio_region().get()), ®ion_before, ®ion_after));
1067 audio_region()->envelope()->add (fx, y);
1069 XMLNode &after = audio_region()->envelope()->get_state();
1070 trackview.session()->add_command (new MementoCommand<AutomationList>(*audio_region()->envelope().get(), &before, &after));
1071 trackview.session()->commit_reversible_command ();
1075 AudioRegionView::remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent */*ev*/)
1077 ControlPoint *cp = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"));
1078 audio_region()->envelope()->erase (cp->model());
1082 AudioRegionView::store_flags()
1084 XMLNode *node = new XMLNode ("GUI");
1086 node->add_property ("waveform-visible", (_flags & WaveformVisible) ? "yes" : "no");
1087 node->add_property ("waveform-rectified", (_flags & WaveformRectified) ? "yes" : "no");
1088 node->add_property ("waveform-logscaled", (_flags & WaveformLogScaled) ? "yes" : "no");
1090 _region->add_extra_xml (*node);
1094 AudioRegionView::set_flags (XMLNode* node)
1098 if ((prop = node->property ("waveform-visible")) != 0) {
1099 if (string_is_affirmative (prop->value())) {
1100 _flags |= WaveformVisible;
1104 if ((prop = node->property ("waveform-rectified")) != 0) {
1105 if (string_is_affirmative (prop->value())) {
1106 _flags |= WaveformRectified;
1110 if ((prop = node->property ("waveform-logscaled")) != 0) {
1111 if (string_is_affirmative (prop->value())) {
1112 _flags |= WaveformLogScaled;
1118 AudioRegionView::set_waveform_shape (WaveformShape shape)
1122 /* this slightly odd approach is to leave the door open to
1123 other "shapes" such as spectral displays, etc.
1136 if (yn != (bool) (_flags & WaveformRectified)) {
1137 for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
1138 (*wave)->property_rectified() = yn;
1142 _flags |= WaveformRectified;
1144 _flags &= ~WaveformRectified;
1151 AudioRegionView::set_waveform_scale (WaveformScale scale)
1153 bool yn = (scale == Logarithmic);
1155 if (yn != (bool) (_flags & WaveformLogScaled)) {
1156 for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
1157 (*wave)->property_logscaled() = yn;
1161 _flags |= WaveformLogScaled;
1163 _flags &= ~WaveformLogScaled;
1171 AudioRegionView::add_ghost (TimeAxisView& tv)
1173 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&trackview);
1176 double unit_position = _region->position () / samples_per_unit;
1177 AudioGhostRegion* ghost = new AudioGhostRegion (tv, trackview, unit_position);
1180 nchans = rtv->track()->n_channels().n_audio();
1182 for (uint32_t n = 0; n < nchans; ++n) {
1184 if (n >= audio_region()->n_channels()) {
1188 WaveView *wave = new WaveView(*ghost->group);
1190 wave->property_data_src() = _region.get();
1191 wave->property_cache() = wave_caches[n];
1192 wave->property_cache_updater() = false;
1193 wave->property_channel() = n;
1194 wave->property_length_function() = (gpointer)region_length_from_c;
1195 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
1196 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
1197 wave->property_x() = 0.0;
1198 wave->property_samples_per_unit() = samples_per_unit;
1199 wave->property_amplitude_above_axis() = _amplitude_above_axis;
1201 wave->property_region_start() = _region->start();
1203 ghost->waves.push_back(wave);
1206 ghost->set_height ();
1207 ghost->set_duration (_region->length() / samples_per_unit);
1208 ghost->set_colors();
1209 ghosts.push_back (ghost);
1215 AudioRegionView::entered (bool internal_editing)
1217 trackview.editor().set_current_trimmable (_region);
1218 trackview.editor().set_current_movable (_region);
1220 if (gain_line && trackview.editor().current_mouse_mode() == Editing::MouseGain) {
1221 gain_line->add_visibility (AutomationLine::ControlPoints);
1224 if (fade_in_handle && !internal_editing) {
1225 fade_in_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 255);
1226 fade_out_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 255);
1231 AudioRegionView::exited ()
1233 trackview.editor().set_current_trimmable (boost::shared_ptr<Trimmable>());
1234 trackview.editor().set_current_movable (boost::shared_ptr<Movable>());
1236 if (gain_line && trackview.editor().current_mouse_mode() == Editing::MouseGain) {
1237 gain_line->remove_visibility (AutomationLine::ControlPoints);
1240 if (fade_in_handle) {
1241 fade_in_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 0);
1242 fade_out_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 0);
1247 AudioRegionView::envelope_active_changed ()
1250 gain_line->set_line_color (audio_region()->envelope_active() ? ARDOUR_UI::config()->canvasvar_GainLine.get() : ARDOUR_UI::config()->canvasvar_GainLineInactive.get());
1255 AudioRegionView::set_waveview_data_src()
1257 AudioGhostRegion* agr;
1258 double unit_length= _region->length() / samples_per_unit;
1260 for (uint32_t n = 0; n < waves.size(); ++n) {
1261 // TODO: something else to let it know the channel
1262 waves[n]->property_data_src() = _region.get();
1265 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
1267 (*i)->set_duration (unit_length);
1269 if((agr = dynamic_cast<AudioGhostRegion*>(*i)) != 0) {
1270 for (vector<WaveView*>::iterator w = agr->waves.begin(); w != agr->waves.end(); ++w) {
1271 (*w)->property_data_src() = _region.get();
1279 AudioRegionView::color_handler ()
1281 //case cMutedWaveForm:
1283 //case cWaveFormClip:
1287 //case cGainLineInactive:
1289 envelope_active_changed();
1294 AudioRegionView::set_frame_color ()
1300 if (_region->opaque()) {
1306 TimeAxisViewItem::set_frame_color ();
1312 if (_region->muted()) {
1313 wc = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_SelectedWaveForm.get(), MUTED_ALPHA);
1315 wc = ARDOUR_UI::config()->canvasvar_SelectedWaveForm.get();
1317 fc = ARDOUR_UI::config()->canvasvar_SelectedWaveFormFill.get();
1320 if (_region->muted()) {
1321 wc = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_RecWaveForm.get(), MUTED_ALPHA);
1323 wc = ARDOUR_UI::config()->canvasvar_RecWaveForm.get();
1325 fc = ARDOUR_UI::config()->canvasvar_RecWaveFormFill.get();
1327 if (_region->muted()) {
1328 wc = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_WaveForm.get(), MUTED_ALPHA);
1330 wc = ARDOUR_UI::config()->canvasvar_WaveForm.get();
1332 fc = ARDOUR_UI::config()->canvasvar_WaveFormFill.get();
1336 for (vector<ArdourCanvas::WaveView*>::iterator w = waves.begin(); w != waves.end(); ++w) {
1337 if (_region->muted()) {
1338 (*w)->property_wave_color() = wc;
1340 (*w)->property_wave_color() = wc;
1341 (*w)->property_fill_color() = fc;
1347 AudioRegionView::set_fade_visibility (bool yn)
1350 if (fade_in_shape) {
1351 fade_in_shape->show();
1353 if (fade_out_shape) {
1354 fade_out_shape->show ();
1356 if (fade_in_handle) {
1357 fade_in_handle->show ();
1359 if (fade_out_handle) {
1360 fade_out_handle->show ();
1363 if (fade_in_shape) {
1364 fade_in_shape->hide();
1366 if (fade_out_shape) {
1367 fade_out_shape->hide ();
1369 if (fade_in_handle) {
1370 fade_in_handle->hide ();
1372 if (fade_out_handle) {
1373 fade_out_handle->hide ();
1379 AudioRegionView::update_coverage_frames (LayerDisplay d)
1381 RegionView::update_coverage_frames (d);
1383 if (fade_in_handle) {
1384 fade_in_handle->raise_to_top ();
1385 fade_out_handle->raise_to_top ();
1390 AudioRegionView::show_region_editor ()
1393 editor = new AudioRegionEditor (trackview.session(), audio_region());
1397 editor->set_position (Gtk::WIN_POS_MOUSE);
1403 AudioRegionView::show_fade_line (framepos_t pos)
1405 fade_position_line->property_x1() = trackview.editor().frame_to_pixel (pos);
1406 fade_position_line->property_x2() = trackview.editor().frame_to_pixel (pos);
1407 fade_position_line->show ();
1408 fade_position_line->raise_to_top ();
1412 AudioRegionView::hide_fade_line ()
1414 fade_position_line->hide ();
1419 AudioRegionView::transients_changed ()
1421 AnalysisFeatureList analysis_features = _region->transients();
1423 while (feature_lines.size() < analysis_features.size()) {
1425 ArdourCanvas::Line* canvas_item = new ArdourCanvas::Line(*group);
1427 ArdourCanvas::Points points;
1429 points.push_back(Gnome::Art::Point(-1.0, 2.0)); // first x-coord needs to be a non-normal value
1430 points.push_back(Gnome::Art::Point(1.0, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1));
1432 canvas_item->property_points() = points;
1433 canvas_item->property_width_pixels() = 1;
1434 canvas_item->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ZeroLine.get();
1435 canvas_item->property_first_arrowhead() = TRUE;
1436 canvas_item->property_last_arrowhead() = TRUE;
1437 canvas_item->property_arrow_shape_a() = 11.0;
1438 canvas_item->property_arrow_shape_b() = 0.0;
1439 canvas_item->property_arrow_shape_c() = 4.0;
1441 canvas_item->raise_to_top ();
1442 canvas_item->show ();
1444 canvas_item->set_data ("regionview", this);
1445 canvas_item->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_feature_line_event), canvas_item, this));
1447 feature_lines.push_back (make_pair(0, canvas_item));
1450 while (feature_lines.size() > analysis_features.size()) {
1451 ArdourCanvas::Line* line = feature_lines.back().second;
1452 feature_lines.pop_back ();
1456 AnalysisFeatureList::const_iterator i;
1457 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
1459 for (i = analysis_features.begin(), l = feature_lines.begin(); i != analysis_features.end() && l != feature_lines.end(); ++i, ++l) {
1461 ArdourCanvas::Points points;
1463 float *pos = new float;
1464 *pos = trackview.editor().frame_to_pixel (*i);
1466 points.push_back(Gnome::Art::Point(*pos, 2.0)); // first x-coord needs to be a non-normal value
1467 points.push_back(Gnome::Art::Point(*pos, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1));
1469 (*l).second->property_points() = points;
1470 (*l).second->set_data ("position", pos);
1477 AudioRegionView::update_transient(float /*old_pos*/, float new_pos)
1479 /* Find frame at old pos, calulate new frame then update region transients*/
1480 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
1482 for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
1484 /* Line has been updated in drag so we compare to new_pos */
1486 float* pos = (float*) (*l).second->get_data ("position");
1488 if (rint(new_pos) == rint(*pos)) {
1490 framepos_t old_frame = (*l).first;
1491 framepos_t new_frame = trackview.editor().pixel_to_frame (new_pos);
1493 _region->update_transient (old_frame, new_frame);
1501 AudioRegionView::remove_transient(float pos)
1503 /* Find frame at old pos, calulate new frame then update region transients*/
1504 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
1506 for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
1508 /* Line has been updated in drag so we compare to new_pos */
1509 float *line_pos = (float*) (*l).second->get_data ("position");
1511 if (rint(pos) == rint(*line_pos)) {
1512 _region->remove_transient ((*l).first);
1519 AudioRegionView::thaw_after_trim ()
1521 RegionView::thaw_after_trim ();
1527 AudioRegionView::redraw_start_xfade ()
1529 boost::shared_ptr<AudioRegion> ar (audio_region());
1531 if (!ar->fade_in() || ar->fade_in()->empty()) {
1535 if (!ar->fade_in_is_xfade()) {
1536 if (start_xfade_in) {
1537 start_xfade_in->hide ();
1538 start_xfade_out->hide ();
1539 start_xfade_rect->hide ();
1544 redraw_start_xfade_to (ar, ar->fade_in()->back()->when);
1548 AudioRegionView::redraw_start_xfade_to (boost::shared_ptr<AudioRegion> ar, framecnt_t len)
1550 int32_t const npoints = trackview.editor().frame_to_pixel (len);
1556 if (!start_xfade_in) {
1557 start_xfade_in = new ArdourCanvas::Line (*group);
1558 start_xfade_in->property_width_pixels() = 1;
1559 start_xfade_in->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GainLine.get();
1562 if (!start_xfade_out) {
1563 start_xfade_out = new ArdourCanvas::Line (*group);
1564 start_xfade_out->property_width_pixels() = 1;
1565 uint32_t col = UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->canvasvar_GainLine.get(), 125);
1566 start_xfade_out->property_fill_color_rgba() = col;
1569 if (!start_xfade_rect) {
1570 start_xfade_rect = new ArdourCanvas::SimpleRect (*group);
1571 start_xfade_rect->property_draw() = true;
1572 start_xfade_rect->property_fill() = true;;
1573 start_xfade_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ActiveCrossfade.get();
1574 start_xfade_rect->property_outline_pixels() = 0;
1575 start_xfade_rect->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_start_xfade_event), start_xfade_rect, this));
1576 start_xfade_rect->set_data ("regionview", this);
1579 Points* points = get_canvas_points ("xfade edit redraw", npoints);
1580 boost::scoped_ptr<float> vec (new float[npoints]);
1581 double effective_height = _height - NAME_HIGHLIGHT_SIZE - 1.0;
1583 ar->fade_in()->curve().get_vector (0, ar->fade_in()->back()->when, vec.get(), npoints);
1585 for (int i = 0, pci = 0; i < npoints; ++i) {
1586 Gnome::Art::Point &p ((*points)[pci++]);
1588 p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
1591 start_xfade_rect->property_x1() = ((*points)[0]).get_x();
1592 start_xfade_rect->property_y1() = 1.0;
1593 start_xfade_rect->property_x2() = ((*points)[npoints-1]).get_x();
1594 start_xfade_rect->property_y2() = effective_height;
1595 start_xfade_rect->show ();
1596 start_xfade_rect->raise_to_top ();
1598 start_xfade_in->property_points() = *points;
1599 start_xfade_in->show ();
1600 start_xfade_in->raise_to_top ();
1604 boost::shared_ptr<AutomationList> inverse = ar->inverse_fade_in();
1608 for (int i = 0, pci = 0; i < npoints; ++i) {
1609 Gnome::Art::Point &p ((*points)[pci++]);
1611 p.set_y (1.0 + effective_height - (effective_height * (1.0 - vec.get()[i])));
1616 inverse->curve().get_vector (0, inverse->back()->when, vec.get(), npoints);
1618 for (int i = 0, pci = 0; i < npoints; ++i) {
1619 Gnome::Art::Point &p ((*points)[pci++]);
1621 p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
1625 start_xfade_out->property_points() = *points;
1626 start_xfade_out->show ();
1627 start_xfade_out->raise_to_top ();
1633 AudioRegionView::redraw_end_xfade ()
1635 boost::shared_ptr<AudioRegion> ar (audio_region());
1637 if (!ar->fade_out() || ar->fade_out()->empty()) {
1641 if (!ar->fade_out_is_xfade()) {
1643 end_xfade_in->hide ();
1644 end_xfade_out->hide ();
1645 end_xfade_rect->hide ();
1650 redraw_end_xfade_to (ar, ar->fade_out()->back()->when);
1654 AudioRegionView::redraw_end_xfade_to (boost::shared_ptr<AudioRegion> ar, framecnt_t len)
1656 int32_t const npoints = trackview.editor().frame_to_pixel (len);
1662 if (!end_xfade_in) {
1663 end_xfade_in = new ArdourCanvas::Line (*group);
1664 end_xfade_in->property_width_pixels() = 1;
1665 end_xfade_in->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GainLine.get();
1668 if (!end_xfade_out) {
1669 end_xfade_out = new ArdourCanvas::Line (*group);
1670 end_xfade_out->property_width_pixels() = 1;
1671 uint32_t col UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->canvasvar_GainLine.get(), 125);
1672 end_xfade_out->property_fill_color_rgba() = col;
1675 if (!end_xfade_rect) {
1676 end_xfade_rect = new ArdourCanvas::SimpleRect (*group);
1677 end_xfade_rect->property_draw() = true;
1678 end_xfade_rect->property_fill() = true;;
1679 end_xfade_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ActiveCrossfade.get();
1680 end_xfade_rect->property_outline_pixels() = 0;
1681 end_xfade_rect->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_end_xfade_event), end_xfade_rect, this));
1682 end_xfade_rect->set_data ("regionview", this);
1685 Points* points = get_canvas_points ("xfade edit redraw", npoints);
1686 boost::scoped_ptr<float> vec (new float[npoints]);
1688 ar->fade_out()->curve().get_vector (0, ar->fade_out()->back()->when, vec.get(), npoints);
1690 double rend = trackview.editor().frame_to_pixel (_region->length() - len);
1691 double effective_height = _height - NAME_HIGHLIGHT_SIZE - 1;
1693 for (int i = 0, pci = 0; i < npoints; ++i) {
1694 Gnome::Art::Point &p ((*points)[pci++]);
1696 p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
1699 end_xfade_rect->property_x1() = ((*points)[0]).get_x();
1700 end_xfade_rect->property_y1() = 1;
1701 end_xfade_rect->property_x2() = ((*points)[npoints-1]).get_x();
1702 end_xfade_rect->property_y2() = effective_height;
1703 end_xfade_rect->show ();
1704 end_xfade_rect->raise_to_top ();
1706 end_xfade_in->property_points() = *points;
1707 end_xfade_in->show ();
1708 end_xfade_in->raise_to_top ();
1712 boost::shared_ptr<AutomationList> inverse = ar->inverse_fade_out ();
1716 for (int i = 0, pci = 0; i < npoints; ++i) {
1717 Gnome::Art::Point &p ((*points)[pci++]);
1719 p.set_y (1.0 + effective_height - (effective_height * (1.0 - vec.get()[i])));
1724 inverse->curve().get_vector (inverse->front()->when, inverse->back()->when, vec.get(), npoints);
1726 for (int i = 0, pci = 0; i < npoints; ++i) {
1727 Gnome::Art::Point &p ((*points)[pci++]);
1729 p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
1733 end_xfade_out->property_points() = *points;
1734 end_xfade_out->show ();
1735 end_xfade_out->raise_to_top ();
1742 AudioRegionView::hide_xfades ()
1744 if (start_xfade_in) {
1745 start_xfade_in->hide();
1747 if (start_xfade_out) {
1748 start_xfade_out->hide();
1750 if (start_xfade_rect) {
1751 start_xfade_rect->hide ();
1754 end_xfade_in->hide();
1756 if (end_xfade_out) {
1757 end_xfade_out->hide();
1759 if (end_xfade_rect) {
1760 end_xfade_rect->hide ();
1765 AudioRegionView::show_xfades ()
1767 if (start_xfade_in) {
1768 start_xfade_in->show();
1770 if (start_xfade_out) {
1771 start_xfade_out->show();
1773 if (start_xfade_rect) {
1774 start_xfade_rect->show ();
1777 end_xfade_in->show();
1779 if (end_xfade_out) {
1780 end_xfade_out->show();
1782 if (end_xfade_rect) {
1783 end_xfade_rect->show ();
1788 AudioRegionView::drag_start ()
1790 TimeAxisViewItem::drag_start ();
1791 AudioTimeAxisView* atav = dynamic_cast<AudioTimeAxisView*> (&trackview);
1794 AudioStreamView* av = atav->audio_view();
1796 /* this will hide our xfades too */
1797 av->hide_xfades_with (audio_region());
1803 AudioRegionView::drag_end ()
1805 TimeAxisViewItem::drag_end ();
1806 /* fades will be redrawn if they changed */