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)
663 if (audio_region()->fade_out_is_xfade()) {
664 if (fade_out_handle) {
665 fade_out_handle->hide ();
666 fade_out_shape->hide ();
672 end_xfade_in->hide ();
673 end_xfade_out->hide ();
674 end_xfade_rect->hide ();
678 if (fade_out_handle == 0) {
682 fade_out_handle->show ();
684 /* smallest size for a fade is 64 frames */
686 width = std::max ((framecnt_t) 64, width);
690 /* round here to prevent little visual glitches with sub-pixel placement */
691 double const pwidth = rint (width / samples_per_unit);
692 uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth);
696 fade_out_shape->hide();
697 fade_out_handle->hide();
701 double const handle_center = (_region->length() - width) / samples_per_unit;
703 /* Put the fade out handle so that its right side is at the end-of-fade line;
704 * it's `one out' for precise pixel accuracy.
706 fade_out_handle->property_x1() = handle_center - 5;
707 fade_out_handle->property_x2() = handle_center + 1;
709 /* don't show shape if its too small */
712 fade_out_shape->hide();
716 if (trackview.session()->config.get_show_region_fades()) {
717 fade_out_shape->show();
720 float curve[npoints];
721 audio_region()->fade_out()->curve().get_vector (0, audio_region()->fade_out()->back()->when, curve, npoints);
723 if (_height >= NAME_HIGHLIGHT_THRESH) {
724 h = _height - NAME_HIGHLIGHT_SIZE - 2;
729 /* points *MUST* be in anti-clockwise order */
731 points = get_canvas_points ("fade out shape", npoints + 3);
734 double xdelta = pwidth/npoints;
736 for (pi = 0, pc = 0; pc < npoints; ++pc) {
737 (*points)[pi].set_x(_pixel_width - pwidth + (pc * xdelta));
738 (*points)[pi++].set_y(2 + (h - (curve[pc] * h)));
743 (*points)[pi].set_x(_pixel_width);
744 (*points)[pi++].set_y(h);
746 (*points)[pi].set_x(_pixel_width);
747 (*points)[pi++].set_y(2);
749 /* connect the dots ... */
751 (*points)[pi] = (*points)[0];
753 fade_out_shape->property_points() = *points;
756 /* ensure trim handle stays on top */
757 if (frame_handle_end) {
758 frame_handle_end->raise_to_top();
763 AudioRegionView::set_samples_per_unit (gdouble spu)
765 RegionView::set_samples_per_unit (spu);
767 if (_flags & WaveformVisible) {
768 for (uint32_t n=0; n < waves.size(); ++n) {
769 waves[n]->property_samples_per_unit() = spu;
777 reset_fade_shapes ();
781 AudioRegionView::set_amplitude_above_axis (gdouble spp)
783 for (uint32_t n=0; n < waves.size(); ++n) {
784 waves[n]->property_amplitude_above_axis() = spp;
789 AudioRegionView::compute_colors (Gdk::Color const & basic_color)
791 RegionView::compute_colors (basic_color);
793 /* gain color computed in envelope_active_changed() */
795 fade_color = UINT_RGBA_CHANGE_A (fill_color, 120);
799 AudioRegionView::set_colors ()
801 RegionView::set_colors();
804 gain_line->set_line_color (audio_region()->envelope_active() ? ARDOUR_UI::config()->canvasvar_GainLine.get() : ARDOUR_UI::config()->canvasvar_GainLineInactive.get());
807 for (uint32_t n=0; n < waves.size(); ++n) {
808 if (_region->muted()) {
809 waves[n]->property_wave_color() = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_WaveForm.get(), MUTED_ALPHA);
811 waves[n]->property_wave_color() = ARDOUR_UI::config()->canvasvar_WaveForm.get();
814 waves[n]->property_clip_color() = ARDOUR_UI::config()->canvasvar_WaveFormClip.get();
815 waves[n]->property_zero_color() = ARDOUR_UI::config()->canvasvar_ZeroLine.get();
820 AudioRegionView::set_waveform_visible (bool yn)
822 if (((_flags & WaveformVisible) != yn)) {
824 for (uint32_t n=0; n < waves.size(); ++n) {
825 /* make sure the zoom level is correct, since we don't update
826 this when waveforms are hidden.
828 waves[n]->property_samples_per_unit() = samples_per_unit;
831 _flags |= WaveformVisible;
833 for (uint32_t n=0; n < waves.size(); ++n) {
836 _flags &= ~WaveformVisible;
843 AudioRegionView::temporarily_hide_envelope ()
851 AudioRegionView::unhide_envelope ()
853 update_envelope_visibility ();
857 AudioRegionView::update_envelope_visibility ()
863 if (Config->get_show_region_gain() || trackview.editor().current_mouse_mode() == Editing::MouseGain) {
864 gain_line->add_visibility (AutomationLine::Line);
871 AudioRegionView::create_waves ()
873 // cerr << "AudioRegionView::create_waves() called on " << this << endl;//DEBUG
874 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
880 ChanCount nchans = atv.track()->n_channels();
882 // cerr << "creating waves for " << _region->name() << " with wfd = " << wait_for_data
883 // << " and channels = " << nchans.n_audio() << endl;
885 /* in tmp_waves, set up null pointers for each channel so the vector is allocated */
886 for (uint32_t n = 0; n < nchans.n_audio(); ++n) {
887 tmp_waves.push_back (0);
890 for (vector<ScopedConnection*>::iterator i = _data_ready_connections.begin(); i != _data_ready_connections.end(); ++i) {
894 _data_ready_connections.clear ();
896 for (uint32_t i = 0; i < nchans.n_audio(); ++i) {
897 _data_ready_connections.push_back (0);
900 for (uint32_t n = 0; n < nchans.n_audio(); ++n) {
902 if (n >= audio_region()->n_channels()) {
906 wave_caches.push_back (WaveView::create_cache ());
908 // cerr << "\tchannel " << n << endl;
911 if (audio_region()->audio_source(n)->peaks_ready (boost::bind (&AudioRegionView::peaks_ready_handler, this, n), &_data_ready_connections[n], gui_context())) {
912 // cerr << "\tData is ready\n";
913 create_one_wave (n, true);
915 // cerr << "\tdata is not ready\n";
916 // we'll get a PeaksReady signal from the source in the future
917 // and will call create_one_wave(n) then.
921 // cerr << "\tdon't delay, display today!\n";
922 create_one_wave (n, true);
929 AudioRegionView::create_one_wave (uint32_t which, bool /*direct*/)
931 //cerr << "AudioRegionView::create_one_wave() called which: " << which << " this: " << this << endl;//DEBUG
932 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
933 uint32_t nchans = atv.track()->n_channels().n_audio();
935 uint32_t nwaves = std::min (nchans, audio_region()->n_channels());
938 if (trackview.current_height() < NAME_HIGHLIGHT_THRESH) {
939 ht = ((trackview.current_height()) / (double) nchans);
941 ht = ((trackview.current_height() - NAME_HIGHLIGHT_SIZE) / (double) nchans);
944 gdouble yoff = which * ht;
946 WaveView *wave = new WaveView(*group);
948 wave->property_data_src() = (gpointer) _region.get();
949 wave->property_cache() = wave_caches[which];
950 wave->property_cache_updater() = true;
951 wave->property_channel() = which;
952 wave->property_length_function() = (gpointer) region_length_from_c;
953 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
954 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
955 wave->property_x() = 0.0;
956 wave->property_y() = yoff;
957 wave->property_height() = (double) ht;
958 wave->property_samples_per_unit() = samples_per_unit;
959 wave->property_amplitude_above_axis() = _amplitude_above_axis;
962 wave->property_wave_color() = _region->muted() ? UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_RecWaveForm.get(), MUTED_ALPHA) : ARDOUR_UI::config()->canvasvar_RecWaveForm.get();
963 wave->property_fill_color() = ARDOUR_UI::config()->canvasvar_RecWaveFormFill.get();
965 wave->property_wave_color() = _region->muted() ? UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_WaveForm.get(), MUTED_ALPHA) : ARDOUR_UI::config()->canvasvar_WaveForm.get();
966 wave->property_fill_color() = ARDOUR_UI::config()->canvasvar_WaveFormFill.get();
969 wave->property_clip_color() = ARDOUR_UI::config()->canvasvar_WaveFormClip.get();
970 wave->property_zero_color() = ARDOUR_UI::config()->canvasvar_ZeroLine.get();
971 wave->property_zero_line() = true;
972 wave->property_region_start() = _region->start();
973 wave->property_rectified() = (bool) (_flags & WaveformRectified);
974 wave->property_logscaled() = (bool) (_flags & WaveformLogScaled);
976 if (!(_flags & WaveformVisible)) {
980 /* note: calling this function is serialized by the lock
981 held in the peak building thread that signals that
982 peaks are ready for use *or* by the fact that it is
983 called one by one from the GUI thread.
986 if (which < nchans) {
987 tmp_waves[which] = wave;
989 /* n-channel track, >n-channel source */
992 /* see if we're all ready */
994 for (n = 0; n < nchans; ++n) {
995 if (tmp_waves[n] == 0) {
1000 if (n == nwaves && waves.empty()) {
1001 /* all waves are ready */
1002 tmp_waves.resize(nwaves);
1007 /* all waves created, don't hook into peaks ready anymore */
1008 delete _data_ready_connections[which];
1009 _data_ready_connections[which] = 0;
1014 AudioRegionView::peaks_ready_handler (uint32_t which)
1016 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&AudioRegionView::create_one_wave, this, which, false));
1017 // cerr << "AudioRegionView::peaks_ready_handler() called on " << which << " this: " << this << endl;
1021 AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
1029 /* don't create points that can't be seen */
1031 update_envelope_visibility ();
1038 framepos_t fx = trackview.editor().pixel_to_frame (x);
1040 if (fx > _region->length()) {
1044 /* compute vertical fractional position */
1046 y = 1.0 - (y / (_height - NAME_HIGHLIGHT_SIZE));
1048 /* map using gain line */
1050 gain_line->view_to_model_coord (x, y);
1052 /* XXX STATEFUL: can't convert to stateful diff until we
1053 can represent automation data with it.
1056 trackview.session()->begin_reversible_command (_("add gain control point"));
1057 XMLNode &before = audio_region()->envelope()->get_state();
1059 if (!audio_region()->envelope_active()) {
1060 XMLNode ®ion_before = audio_region()->get_state();
1061 audio_region()->set_envelope_active(true);
1062 XMLNode ®ion_after = audio_region()->get_state();
1063 trackview.session()->add_command (new MementoCommand<AudioRegion>(*(audio_region().get()), ®ion_before, ®ion_after));
1066 audio_region()->envelope()->add (fx, y);
1068 XMLNode &after = audio_region()->envelope()->get_state();
1069 trackview.session()->add_command (new MementoCommand<AutomationList>(*audio_region()->envelope().get(), &before, &after));
1070 trackview.session()->commit_reversible_command ();
1074 AudioRegionView::remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent */*ev*/)
1076 ControlPoint *cp = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"));
1077 audio_region()->envelope()->erase (cp->model());
1081 AudioRegionView::store_flags()
1083 XMLNode *node = new XMLNode ("GUI");
1085 node->add_property ("waveform-visible", (_flags & WaveformVisible) ? "yes" : "no");
1086 node->add_property ("waveform-rectified", (_flags & WaveformRectified) ? "yes" : "no");
1087 node->add_property ("waveform-logscaled", (_flags & WaveformLogScaled) ? "yes" : "no");
1089 _region->add_extra_xml (*node);
1093 AudioRegionView::set_flags (XMLNode* node)
1097 if ((prop = node->property ("waveform-visible")) != 0) {
1098 if (string_is_affirmative (prop->value())) {
1099 _flags |= WaveformVisible;
1103 if ((prop = node->property ("waveform-rectified")) != 0) {
1104 if (string_is_affirmative (prop->value())) {
1105 _flags |= WaveformRectified;
1109 if ((prop = node->property ("waveform-logscaled")) != 0) {
1110 if (string_is_affirmative (prop->value())) {
1111 _flags |= WaveformLogScaled;
1117 AudioRegionView::set_waveform_shape (WaveformShape shape)
1121 /* this slightly odd approach is to leave the door open to
1122 other "shapes" such as spectral displays, etc.
1135 if (yn != (bool) (_flags & WaveformRectified)) {
1136 for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
1137 (*wave)->property_rectified() = yn;
1141 _flags |= WaveformRectified;
1143 _flags &= ~WaveformRectified;
1150 AudioRegionView::set_waveform_scale (WaveformScale scale)
1152 bool yn = (scale == Logarithmic);
1154 if (yn != (bool) (_flags & WaveformLogScaled)) {
1155 for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
1156 (*wave)->property_logscaled() = yn;
1160 _flags |= WaveformLogScaled;
1162 _flags &= ~WaveformLogScaled;
1170 AudioRegionView::add_ghost (TimeAxisView& tv)
1172 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&trackview);
1175 double unit_position = _region->position () / samples_per_unit;
1176 AudioGhostRegion* ghost = new AudioGhostRegion (tv, trackview, unit_position);
1179 nchans = rtv->track()->n_channels().n_audio();
1181 for (uint32_t n = 0; n < nchans; ++n) {
1183 if (n >= audio_region()->n_channels()) {
1187 WaveView *wave = new WaveView(*ghost->group);
1189 wave->property_data_src() = _region.get();
1190 wave->property_cache() = wave_caches[n];
1191 wave->property_cache_updater() = false;
1192 wave->property_channel() = n;
1193 wave->property_length_function() = (gpointer)region_length_from_c;
1194 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
1195 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
1196 wave->property_x() = 0.0;
1197 wave->property_samples_per_unit() = samples_per_unit;
1198 wave->property_amplitude_above_axis() = _amplitude_above_axis;
1200 wave->property_region_start() = _region->start();
1202 ghost->waves.push_back(wave);
1205 ghost->set_height ();
1206 ghost->set_duration (_region->length() / samples_per_unit);
1207 ghost->set_colors();
1208 ghosts.push_back (ghost);
1214 AudioRegionView::entered (bool internal_editing)
1216 trackview.editor().set_current_trimmable (_region);
1217 trackview.editor().set_current_movable (_region);
1219 if (gain_line && trackview.editor().current_mouse_mode() == Editing::MouseGain) {
1220 gain_line->add_visibility (AutomationLine::ControlPoints);
1223 if (fade_in_handle && !internal_editing) {
1224 fade_in_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 255);
1225 fade_out_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 255);
1230 AudioRegionView::exited ()
1232 trackview.editor().set_current_trimmable (boost::shared_ptr<Trimmable>());
1233 trackview.editor().set_current_movable (boost::shared_ptr<Movable>());
1235 if (gain_line && trackview.editor().current_mouse_mode() == Editing::MouseGain) {
1236 gain_line->remove_visibility (AutomationLine::ControlPoints);
1239 if (fade_in_handle) {
1240 fade_in_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 0);
1241 fade_out_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 0);
1246 AudioRegionView::envelope_active_changed ()
1249 gain_line->set_line_color (audio_region()->envelope_active() ? ARDOUR_UI::config()->canvasvar_GainLine.get() : ARDOUR_UI::config()->canvasvar_GainLineInactive.get());
1254 AudioRegionView::set_waveview_data_src()
1256 AudioGhostRegion* agr;
1257 double unit_length= _region->length() / samples_per_unit;
1259 for (uint32_t n = 0; n < waves.size(); ++n) {
1260 // TODO: something else to let it know the channel
1261 waves[n]->property_data_src() = _region.get();
1264 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
1266 (*i)->set_duration (unit_length);
1268 if((agr = dynamic_cast<AudioGhostRegion*>(*i)) != 0) {
1269 for (vector<WaveView*>::iterator w = agr->waves.begin(); w != agr->waves.end(); ++w) {
1270 (*w)->property_data_src() = _region.get();
1278 AudioRegionView::color_handler ()
1280 //case cMutedWaveForm:
1282 //case cWaveFormClip:
1286 //case cGainLineInactive:
1288 envelope_active_changed();
1293 AudioRegionView::set_frame_color ()
1299 if (_region->opaque()) {
1305 TimeAxisViewItem::set_frame_color ();
1311 if (_region->muted()) {
1312 wc = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_SelectedWaveForm.get(), MUTED_ALPHA);
1314 wc = ARDOUR_UI::config()->canvasvar_SelectedWaveForm.get();
1316 fc = ARDOUR_UI::config()->canvasvar_SelectedWaveFormFill.get();
1319 if (_region->muted()) {
1320 wc = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_RecWaveForm.get(), MUTED_ALPHA);
1322 wc = ARDOUR_UI::config()->canvasvar_RecWaveForm.get();
1324 fc = ARDOUR_UI::config()->canvasvar_RecWaveFormFill.get();
1326 if (_region->muted()) {
1327 wc = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_WaveForm.get(), MUTED_ALPHA);
1329 wc = ARDOUR_UI::config()->canvasvar_WaveForm.get();
1331 fc = ARDOUR_UI::config()->canvasvar_WaveFormFill.get();
1335 for (vector<ArdourCanvas::WaveView*>::iterator w = waves.begin(); w != waves.end(); ++w) {
1336 if (_region->muted()) {
1337 (*w)->property_wave_color() = wc;
1339 (*w)->property_wave_color() = wc;
1340 (*w)->property_fill_color() = fc;
1346 AudioRegionView::set_fade_visibility (bool yn)
1349 if (fade_in_shape) {
1350 fade_in_shape->show();
1352 if (fade_out_shape) {
1353 fade_out_shape->show ();
1355 if (fade_in_handle) {
1356 fade_in_handle->show ();
1358 if (fade_out_handle) {
1359 fade_out_handle->show ();
1362 if (fade_in_shape) {
1363 fade_in_shape->hide();
1365 if (fade_out_shape) {
1366 fade_out_shape->hide ();
1368 if (fade_in_handle) {
1369 fade_in_handle->hide ();
1371 if (fade_out_handle) {
1372 fade_out_handle->hide ();
1378 AudioRegionView::update_coverage_frames (LayerDisplay d)
1380 RegionView::update_coverage_frames (d);
1382 if (fade_in_handle) {
1383 fade_in_handle->raise_to_top ();
1384 fade_out_handle->raise_to_top ();
1389 AudioRegionView::show_region_editor ()
1392 editor = new AudioRegionEditor (trackview.session(), audio_region());
1396 editor->set_position (Gtk::WIN_POS_MOUSE);
1402 AudioRegionView::show_fade_line (framepos_t pos)
1404 fade_position_line->property_x1() = trackview.editor().frame_to_pixel (pos);
1405 fade_position_line->property_x2() = trackview.editor().frame_to_pixel (pos);
1406 fade_position_line->show ();
1407 fade_position_line->raise_to_top ();
1411 AudioRegionView::hide_fade_line ()
1413 fade_position_line->hide ();
1418 AudioRegionView::transients_changed ()
1420 AnalysisFeatureList analysis_features = _region->transients();
1422 while (feature_lines.size() < analysis_features.size()) {
1424 ArdourCanvas::Line* canvas_item = new ArdourCanvas::Line(*group);
1426 ArdourCanvas::Points points;
1428 points.push_back(Gnome::Art::Point(-1.0, 2.0)); // first x-coord needs to be a non-normal value
1429 points.push_back(Gnome::Art::Point(1.0, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1));
1431 canvas_item->property_points() = points;
1432 canvas_item->property_width_pixels() = 1;
1433 canvas_item->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ZeroLine.get();
1434 canvas_item->property_first_arrowhead() = TRUE;
1435 canvas_item->property_last_arrowhead() = TRUE;
1436 canvas_item->property_arrow_shape_a() = 11.0;
1437 canvas_item->property_arrow_shape_b() = 0.0;
1438 canvas_item->property_arrow_shape_c() = 4.0;
1440 canvas_item->raise_to_top ();
1441 canvas_item->show ();
1443 canvas_item->set_data ("regionview", this);
1444 canvas_item->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_feature_line_event), canvas_item, this));
1446 feature_lines.push_back (make_pair(0, canvas_item));
1449 while (feature_lines.size() > analysis_features.size()) {
1450 ArdourCanvas::Line* line = feature_lines.back().second;
1451 feature_lines.pop_back ();
1455 AnalysisFeatureList::const_iterator i;
1456 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
1458 for (i = analysis_features.begin(), l = feature_lines.begin(); i != analysis_features.end() && l != feature_lines.end(); ++i, ++l) {
1460 ArdourCanvas::Points points;
1462 float *pos = new float;
1463 *pos = trackview.editor().frame_to_pixel (*i);
1465 points.push_back(Gnome::Art::Point(*pos, 2.0)); // first x-coord needs to be a non-normal value
1466 points.push_back(Gnome::Art::Point(*pos, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1));
1468 (*l).second->property_points() = points;
1469 (*l).second->set_data ("position", pos);
1476 AudioRegionView::update_transient(float /*old_pos*/, float new_pos)
1478 /* Find frame at old pos, calulate new frame then update region transients*/
1479 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
1481 for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
1483 /* Line has been updated in drag so we compare to new_pos */
1485 float* pos = (float*) (*l).second->get_data ("position");
1487 if (rint(new_pos) == rint(*pos)) {
1489 framepos_t old_frame = (*l).first;
1490 framepos_t new_frame = trackview.editor().pixel_to_frame (new_pos);
1492 _region->update_transient (old_frame, new_frame);
1500 AudioRegionView::remove_transient(float pos)
1502 /* Find frame at old pos, calulate new frame then update region transients*/
1503 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
1505 for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
1507 /* Line has been updated in drag so we compare to new_pos */
1508 float *line_pos = (float*) (*l).second->get_data ("position");
1510 if (rint(pos) == rint(*line_pos)) {
1511 _region->remove_transient ((*l).first);
1518 AudioRegionView::thaw_after_trim ()
1520 RegionView::thaw_after_trim ();
1526 AudioRegionView::redraw_start_xfade ()
1528 boost::shared_ptr<AudioRegion> ar (audio_region());
1530 if (!ar->fade_in() || ar->fade_in()->empty()) {
1534 if (!ar->fade_in_is_xfade()) {
1535 if (start_xfade_in) {
1536 start_xfade_in->hide ();
1537 start_xfade_out->hide ();
1538 start_xfade_rect->hide ();
1543 redraw_start_xfade_to (ar, ar->fade_in()->back()->when);
1547 AudioRegionView::redraw_start_xfade_to (boost::shared_ptr<AudioRegion> ar, framecnt_t len)
1549 int32_t const npoints = trackview.editor().frame_to_pixel (len);
1555 if (!start_xfade_in) {
1556 start_xfade_in = new ArdourCanvas::Line (*group);
1557 start_xfade_in->property_width_pixels() = 1;
1558 start_xfade_in->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GainLine.get();
1561 if (!start_xfade_out) {
1562 start_xfade_out = new ArdourCanvas::Line (*group);
1563 start_xfade_out->property_width_pixels() = 1;
1564 uint32_t col = UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->canvasvar_GainLine.get(), 125);
1565 start_xfade_out->property_fill_color_rgba() = col;
1568 if (!start_xfade_rect) {
1569 start_xfade_rect = new ArdourCanvas::SimpleRect (*group);
1570 start_xfade_rect->property_draw() = true;
1571 start_xfade_rect->property_fill() = true;;
1572 start_xfade_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ActiveCrossfade.get();
1573 start_xfade_rect->property_outline_pixels() = 0;
1574 start_xfade_rect->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_start_xfade_event), start_xfade_rect, this));
1575 start_xfade_rect->set_data ("regionview", this);
1578 Points* points = get_canvas_points ("xfade edit redraw", npoints);
1579 boost::scoped_ptr<float> vec (new float[npoints]);
1580 double effective_height = _height - NAME_HIGHLIGHT_SIZE - 1.0;
1582 ar->fade_in()->curve().get_vector (0, ar->fade_in()->back()->when, vec.get(), npoints);
1584 for (int i = 0, pci = 0; i < npoints; ++i) {
1585 Gnome::Art::Point &p ((*points)[pci++]);
1587 p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
1590 start_xfade_rect->property_x1() = ((*points)[0]).get_x();
1591 start_xfade_rect->property_y1() = 1.0;
1592 start_xfade_rect->property_x2() = ((*points)[npoints-1]).get_x();
1593 start_xfade_rect->property_y2() = effective_height;
1594 start_xfade_rect->show ();
1595 start_xfade_rect->raise_to_top ();
1597 start_xfade_in->property_points() = *points;
1598 start_xfade_in->show ();
1599 start_xfade_in->raise_to_top ();
1603 boost::shared_ptr<AutomationList> inverse = ar->inverse_fade_in();
1607 for (int i = 0, pci = 0; i < npoints; ++i) {
1608 Gnome::Art::Point &p ((*points)[pci++]);
1610 p.set_y (1.0 + effective_height - (effective_height * (1.0 - vec.get()[i])));
1615 inverse->curve().get_vector (0, inverse->back()->when, vec.get(), npoints);
1617 for (int i = 0, pci = 0; i < npoints; ++i) {
1618 Gnome::Art::Point &p ((*points)[pci++]);
1620 p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
1624 start_xfade_out->property_points() = *points;
1625 start_xfade_out->show ();
1626 start_xfade_out->raise_to_top ();
1632 AudioRegionView::redraw_end_xfade ()
1634 boost::shared_ptr<AudioRegion> ar (audio_region());
1636 if (!ar->fade_out() || ar->fade_out()->empty()) {
1640 if (!ar->fade_out_is_xfade()) {
1642 end_xfade_in->hide ();
1643 end_xfade_out->hide ();
1644 end_xfade_rect->hide ();
1649 redraw_end_xfade_to (ar, ar->fade_out()->back()->when);
1653 AudioRegionView::redraw_end_xfade_to (boost::shared_ptr<AudioRegion> ar, framecnt_t len)
1655 int32_t const npoints = trackview.editor().frame_to_pixel (len);
1661 if (!end_xfade_in) {
1662 end_xfade_in = new ArdourCanvas::Line (*group);
1663 end_xfade_in->property_width_pixels() = 1;
1664 end_xfade_in->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GainLine.get();
1667 if (!end_xfade_out) {
1668 end_xfade_out = new ArdourCanvas::Line (*group);
1669 end_xfade_out->property_width_pixels() = 1;
1670 uint32_t col UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->canvasvar_GainLine.get(), 125);
1671 end_xfade_out->property_fill_color_rgba() = col;
1674 if (!end_xfade_rect) {
1675 end_xfade_rect = new ArdourCanvas::SimpleRect (*group);
1676 end_xfade_rect->property_draw() = true;
1677 end_xfade_rect->property_fill() = true;;
1678 end_xfade_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ActiveCrossfade.get();
1679 end_xfade_rect->property_outline_pixels() = 0;
1680 end_xfade_rect->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_end_xfade_event), end_xfade_rect, this));
1681 end_xfade_rect->set_data ("regionview", this);
1684 Points* points = get_canvas_points ("xfade edit redraw", npoints);
1685 boost::scoped_ptr<float> vec (new float[npoints]);
1687 ar->fade_out()->curve().get_vector (0, ar->fade_out()->back()->when, vec.get(), npoints);
1689 double rend = trackview.editor().frame_to_pixel (_region->length() - len);
1690 double effective_height = _height - NAME_HIGHLIGHT_SIZE - 1;
1692 for (int i = 0, pci = 0; i < npoints; ++i) {
1693 Gnome::Art::Point &p ((*points)[pci++]);
1695 p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
1698 end_xfade_rect->property_x1() = ((*points)[0]).get_x();
1699 end_xfade_rect->property_y1() = 1;
1700 end_xfade_rect->property_x2() = ((*points)[npoints-1]).get_x();
1701 end_xfade_rect->property_y2() = effective_height;
1702 end_xfade_rect->show ();
1703 end_xfade_rect->raise_to_top ();
1705 end_xfade_in->property_points() = *points;
1706 end_xfade_in->show ();
1707 end_xfade_in->raise_to_top ();
1711 boost::shared_ptr<AutomationList> inverse = ar->inverse_fade_out ();
1715 for (int i = 0, pci = 0; i < npoints; ++i) {
1716 Gnome::Art::Point &p ((*points)[pci++]);
1718 p.set_y (1.0 + effective_height - (effective_height * (1.0 - vec.get()[i])));
1723 inverse->curve().get_vector (inverse->front()->when, inverse->back()->when, vec.get(), npoints);
1725 for (int i = 0, pci = 0; i < npoints; ++i) {
1726 Gnome::Art::Point &p ((*points)[pci++]);
1728 p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
1732 end_xfade_out->property_points() = *points;
1733 end_xfade_out->show ();
1734 end_xfade_out->raise_to_top ();
1741 AudioRegionView::hide_xfades ()
1743 if (start_xfade_in) {
1744 start_xfade_in->hide();
1746 if (start_xfade_out) {
1747 start_xfade_out->hide();
1749 if (start_xfade_rect) {
1750 start_xfade_rect->hide ();
1753 end_xfade_in->hide();
1755 if (end_xfade_out) {
1756 end_xfade_out->hide();
1758 if (end_xfade_rect) {
1759 end_xfade_rect->hide ();
1764 AudioRegionView::show_xfades ()
1766 if (start_xfade_in) {
1767 start_xfade_in->show();
1769 if (start_xfade_out) {
1770 start_xfade_out->show();
1772 if (start_xfade_rect) {
1773 start_xfade_rect->show ();
1776 end_xfade_in->show();
1778 if (end_xfade_out) {
1779 end_xfade_out->show();
1781 if (end_xfade_rect) {
1782 end_xfade_rect->show ();
1787 AudioRegionView::drag_start ()
1789 TimeAxisViewItem::drag_start ();
1790 AudioTimeAxisView* atav = dynamic_cast<AudioTimeAxisView*> (&trackview);
1793 AudioStreamView* av = atav->audio_view();
1795 /* this will hide our xfades too */
1796 av->hide_xfades_with (audio_region());
1802 AudioRegionView::drag_end ()
1804 TimeAxisViewItem::drag_end ();
1805 /* fades will be redrawn if they changed */