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 gain_line->set_visibility (automation_line_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 gain_line->set_visibility (automation_line_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 ()
854 gain_line->set_visibility (automation_line_visibility());
859 AudioRegionView::update_envelope_visible ()
862 gain_line->set_visibility (automation_line_visibility());
867 AudioRegionView::create_waves ()
869 // cerr << "AudioRegionView::create_waves() called on " << this << endl;//DEBUG
870 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
876 ChanCount nchans = atv.track()->n_channels();
878 // cerr << "creating waves for " << _region->name() << " with wfd = " << wait_for_data
879 // << " and channels = " << nchans.n_audio() << endl;
881 /* in tmp_waves, set up null pointers for each channel so the vector is allocated */
882 for (uint32_t n = 0; n < nchans.n_audio(); ++n) {
883 tmp_waves.push_back (0);
886 for (vector<ScopedConnection*>::iterator i = _data_ready_connections.begin(); i != _data_ready_connections.end(); ++i) {
890 _data_ready_connections.clear ();
892 for (uint32_t i = 0; i < nchans.n_audio(); ++i) {
893 _data_ready_connections.push_back (0);
896 for (uint32_t n = 0; n < nchans.n_audio(); ++n) {
898 if (n >= audio_region()->n_channels()) {
902 wave_caches.push_back (WaveView::create_cache ());
904 // cerr << "\tchannel " << n << endl;
907 if (audio_region()->audio_source(n)->peaks_ready (boost::bind (&AudioRegionView::peaks_ready_handler, this, n), &_data_ready_connections[n], gui_context())) {
908 // cerr << "\tData is ready\n";
909 create_one_wave (n, true);
911 // cerr << "\tdata is not ready\n";
912 // we'll get a PeaksReady signal from the source in the future
913 // and will call create_one_wave(n) then.
917 // cerr << "\tdon't delay, display today!\n";
918 create_one_wave (n, true);
925 AudioRegionView::create_one_wave (uint32_t which, bool /*direct*/)
927 //cerr << "AudioRegionView::create_one_wave() called which: " << which << " this: " << this << endl;//DEBUG
928 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
929 uint32_t nchans = atv.track()->n_channels().n_audio();
931 uint32_t nwaves = std::min (nchans, audio_region()->n_channels());
934 if (trackview.current_height() < NAME_HIGHLIGHT_THRESH) {
935 ht = ((trackview.current_height()) / (double) nchans);
937 ht = ((trackview.current_height() - NAME_HIGHLIGHT_SIZE) / (double) nchans);
940 gdouble yoff = which * ht;
942 WaveView *wave = new WaveView(*group);
944 wave->property_data_src() = (gpointer) _region.get();
945 wave->property_cache() = wave_caches[which];
946 wave->property_cache_updater() = true;
947 wave->property_channel() = which;
948 wave->property_length_function() = (gpointer) region_length_from_c;
949 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
950 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
951 wave->property_x() = 0.0;
952 wave->property_y() = yoff;
953 wave->property_height() = (double) ht;
954 wave->property_samples_per_unit() = samples_per_unit;
955 wave->property_amplitude_above_axis() = _amplitude_above_axis;
958 wave->property_wave_color() = _region->muted() ? UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_RecWaveForm.get(), MUTED_ALPHA) : ARDOUR_UI::config()->canvasvar_RecWaveForm.get();
959 wave->property_fill_color() = ARDOUR_UI::config()->canvasvar_RecWaveFormFill.get();
961 wave->property_wave_color() = _region->muted() ? UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_WaveForm.get(), MUTED_ALPHA) : ARDOUR_UI::config()->canvasvar_WaveForm.get();
962 wave->property_fill_color() = ARDOUR_UI::config()->canvasvar_WaveFormFill.get();
965 wave->property_clip_color() = ARDOUR_UI::config()->canvasvar_WaveFormClip.get();
966 wave->property_zero_color() = ARDOUR_UI::config()->canvasvar_ZeroLine.get();
967 wave->property_zero_line() = true;
968 wave->property_region_start() = _region->start();
969 wave->property_rectified() = (bool) (_flags & WaveformRectified);
970 wave->property_logscaled() = (bool) (_flags & WaveformLogScaled);
972 if (!(_flags & WaveformVisible)) {
976 /* note: calling this function is serialized by the lock
977 held in the peak building thread that signals that
978 peaks are ready for use *or* by the fact that it is
979 called one by one from the GUI thread.
982 if (which < nchans) {
983 tmp_waves[which] = wave;
985 /* n-channel track, >n-channel source */
988 /* see if we're all ready */
990 for (n = 0; n < nchans; ++n) {
991 if (tmp_waves[n] == 0) {
996 if (n == nwaves && waves.empty()) {
997 /* all waves are ready */
998 tmp_waves.resize(nwaves);
1003 /* all waves created, don't hook into peaks ready anymore */
1004 delete _data_ready_connections[which];
1005 _data_ready_connections[which] = 0;
1010 AudioRegionView::peaks_ready_handler (uint32_t which)
1012 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&AudioRegionView::create_one_wave, this, which, false));
1013 // cerr << "AudioRegionView::peaks_ready_handler() called on " << which << " this: " << this << endl;
1017 AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
1025 /* don't create points that can't be seen */
1027 gain_line->set_visibility (automation_line_visibility());
1034 framepos_t fx = trackview.editor().pixel_to_frame (x);
1036 if (fx > _region->length()) {
1040 /* compute vertical fractional position */
1042 y = 1.0 - (y / (_height - NAME_HIGHLIGHT_SIZE));
1044 /* map using gain line */
1046 gain_line->view_to_model_coord (x, y);
1048 /* XXX STATEFUL: can't convert to stateful diff until we
1049 can represent automation data with it.
1052 trackview.session()->begin_reversible_command (_("add gain control point"));
1053 XMLNode &before = audio_region()->envelope()->get_state();
1055 if (!audio_region()->envelope_active()) {
1056 XMLNode ®ion_before = audio_region()->get_state();
1057 audio_region()->set_envelope_active(true);
1058 XMLNode ®ion_after = audio_region()->get_state();
1059 trackview.session()->add_command (new MementoCommand<AudioRegion>(*(audio_region().get()), ®ion_before, ®ion_after));
1062 audio_region()->envelope()->add (fx, y);
1064 XMLNode &after = audio_region()->envelope()->get_state();
1065 trackview.session()->add_command (new MementoCommand<AutomationList>(*audio_region()->envelope().get(), &before, &after));
1066 trackview.session()->commit_reversible_command ();
1070 AudioRegionView::remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent */*ev*/)
1072 ControlPoint *cp = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"));
1073 audio_region()->envelope()->erase (cp->model());
1077 AudioRegionView::store_flags()
1079 XMLNode *node = new XMLNode ("GUI");
1081 node->add_property ("waveform-visible", (_flags & WaveformVisible) ? "yes" : "no");
1082 node->add_property ("waveform-rectified", (_flags & WaveformRectified) ? "yes" : "no");
1083 node->add_property ("waveform-logscaled", (_flags & WaveformLogScaled) ? "yes" : "no");
1085 _region->add_extra_xml (*node);
1089 AudioRegionView::set_flags (XMLNode* node)
1093 if ((prop = node->property ("waveform-visible")) != 0) {
1094 if (string_is_affirmative (prop->value())) {
1095 _flags |= WaveformVisible;
1099 if ((prop = node->property ("waveform-rectified")) != 0) {
1100 if (string_is_affirmative (prop->value())) {
1101 _flags |= WaveformRectified;
1105 if ((prop = node->property ("waveform-logscaled")) != 0) {
1106 if (string_is_affirmative (prop->value())) {
1107 _flags |= WaveformLogScaled;
1113 AudioRegionView::set_waveform_shape (WaveformShape shape)
1117 /* this slightly odd approach is to leave the door open to
1118 other "shapes" such as spectral displays, etc.
1131 if (yn != (bool) (_flags & WaveformRectified)) {
1132 for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
1133 (*wave)->property_rectified() = yn;
1137 _flags |= WaveformRectified;
1139 _flags &= ~WaveformRectified;
1146 AudioRegionView::set_waveform_scale (WaveformScale scale)
1148 bool yn = (scale == Logarithmic);
1150 if (yn != (bool) (_flags & WaveformLogScaled)) {
1151 for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
1152 (*wave)->property_logscaled() = yn;
1156 _flags |= WaveformLogScaled;
1158 _flags &= ~WaveformLogScaled;
1166 AudioRegionView::add_ghost (TimeAxisView& tv)
1168 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&trackview);
1171 double unit_position = _region->position () / samples_per_unit;
1172 AudioGhostRegion* ghost = new AudioGhostRegion (tv, trackview, unit_position);
1175 nchans = rtv->track()->n_channels().n_audio();
1177 for (uint32_t n = 0; n < nchans; ++n) {
1179 if (n >= audio_region()->n_channels()) {
1183 WaveView *wave = new WaveView(*ghost->group);
1185 wave->property_data_src() = _region.get();
1186 wave->property_cache() = wave_caches[n];
1187 wave->property_cache_updater() = false;
1188 wave->property_channel() = n;
1189 wave->property_length_function() = (gpointer)region_length_from_c;
1190 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
1191 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
1192 wave->property_x() = 0.0;
1193 wave->property_samples_per_unit() = samples_per_unit;
1194 wave->property_amplitude_above_axis() = _amplitude_above_axis;
1196 wave->property_region_start() = _region->start();
1198 ghost->waves.push_back(wave);
1201 ghost->set_height ();
1202 ghost->set_duration (_region->length() / samples_per_unit);
1203 ghost->set_colors();
1204 ghosts.push_back (ghost);
1210 AudioRegionView::entered (bool internal_editing)
1212 trackview.editor().set_current_trimmable (_region);
1213 trackview.editor().set_current_movable (_region);
1215 if (gain_line && trackview.editor().current_mouse_mode() == Editing::MouseGain) {
1216 gain_line->add_visibility (AutomationLine::ControlPoints);
1219 if (fade_in_handle && !internal_editing) {
1220 fade_in_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 255);
1221 fade_out_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 255);
1226 AudioRegionView::exited ()
1228 trackview.editor().set_current_trimmable (boost::shared_ptr<Trimmable>());
1229 trackview.editor().set_current_movable (boost::shared_ptr<Movable>());
1231 if (gain_line && trackview.editor().current_mouse_mode() == Editing::MouseGain) {
1232 gain_line->remove_visibility (AutomationLine::ControlPoints);
1235 if (fade_in_handle) {
1236 fade_in_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 0);
1237 fade_out_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 0);
1242 AudioRegionView::envelope_active_changed ()
1245 gain_line->set_line_color (audio_region()->envelope_active() ? ARDOUR_UI::config()->canvasvar_GainLine.get() : ARDOUR_UI::config()->canvasvar_GainLineInactive.get());
1250 AudioRegionView::set_waveview_data_src()
1252 AudioGhostRegion* agr;
1253 double unit_length= _region->length() / samples_per_unit;
1255 for (uint32_t n = 0; n < waves.size(); ++n) {
1256 // TODO: something else to let it know the channel
1257 waves[n]->property_data_src() = _region.get();
1260 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
1262 (*i)->set_duration (unit_length);
1264 if((agr = dynamic_cast<AudioGhostRegion*>(*i)) != 0) {
1265 for (vector<WaveView*>::iterator w = agr->waves.begin(); w != agr->waves.end(); ++w) {
1266 (*w)->property_data_src() = _region.get();
1274 AudioRegionView::color_handler ()
1276 //case cMutedWaveForm:
1278 //case cWaveFormClip:
1282 //case cGainLineInactive:
1284 envelope_active_changed();
1289 AudioRegionView::set_frame_color ()
1295 if (_region->opaque()) {
1301 TimeAxisViewItem::set_frame_color ();
1307 if (_region->muted()) {
1308 wc = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_SelectedWaveForm.get(), MUTED_ALPHA);
1310 wc = ARDOUR_UI::config()->canvasvar_SelectedWaveForm.get();
1312 fc = ARDOUR_UI::config()->canvasvar_SelectedWaveFormFill.get();
1315 if (_region->muted()) {
1316 wc = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_RecWaveForm.get(), MUTED_ALPHA);
1318 wc = ARDOUR_UI::config()->canvasvar_RecWaveForm.get();
1320 fc = ARDOUR_UI::config()->canvasvar_RecWaveFormFill.get();
1322 if (_region->muted()) {
1323 wc = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_WaveForm.get(), MUTED_ALPHA);
1325 wc = ARDOUR_UI::config()->canvasvar_WaveForm.get();
1327 fc = ARDOUR_UI::config()->canvasvar_WaveFormFill.get();
1331 for (vector<ArdourCanvas::WaveView*>::iterator w = waves.begin(); w != waves.end(); ++w) {
1332 if (_region->muted()) {
1333 (*w)->property_wave_color() = wc;
1335 (*w)->property_wave_color() = wc;
1336 (*w)->property_fill_color() = fc;
1342 AudioRegionView::set_fade_visibility (bool yn)
1345 if (fade_in_shape) {
1346 fade_in_shape->show();
1348 if (fade_out_shape) {
1349 fade_out_shape->show ();
1351 if (fade_in_handle) {
1352 fade_in_handle->show ();
1354 if (fade_out_handle) {
1355 fade_out_handle->show ();
1358 if (fade_in_shape) {
1359 fade_in_shape->hide();
1361 if (fade_out_shape) {
1362 fade_out_shape->hide ();
1364 if (fade_in_handle) {
1365 fade_in_handle->hide ();
1367 if (fade_out_handle) {
1368 fade_out_handle->hide ();
1374 AudioRegionView::update_coverage_frames (LayerDisplay d)
1376 RegionView::update_coverage_frames (d);
1378 if (fade_in_handle) {
1379 fade_in_handle->raise_to_top ();
1380 fade_out_handle->raise_to_top ();
1385 AudioRegionView::show_region_editor ()
1388 editor = new AudioRegionEditor (trackview.session(), audio_region());
1392 editor->set_position (Gtk::WIN_POS_MOUSE);
1398 AudioRegionView::show_fade_line (framepos_t pos)
1400 fade_position_line->property_x1() = trackview.editor().frame_to_pixel (pos);
1401 fade_position_line->property_x2() = trackview.editor().frame_to_pixel (pos);
1402 fade_position_line->show ();
1403 fade_position_line->raise_to_top ();
1407 AudioRegionView::hide_fade_line ()
1409 fade_position_line->hide ();
1414 AudioRegionView::transients_changed ()
1416 AnalysisFeatureList analysis_features = _region->transients();
1418 while (feature_lines.size() < analysis_features.size()) {
1420 ArdourCanvas::Line* canvas_item = new ArdourCanvas::Line(*group);
1422 ArdourCanvas::Points points;
1424 points.push_back(Gnome::Art::Point(-1.0, 2.0)); // first x-coord needs to be a non-normal value
1425 points.push_back(Gnome::Art::Point(1.0, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1));
1427 canvas_item->property_points() = points;
1428 canvas_item->property_width_pixels() = 1;
1429 canvas_item->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ZeroLine.get();
1430 canvas_item->property_first_arrowhead() = TRUE;
1431 canvas_item->property_last_arrowhead() = TRUE;
1432 canvas_item->property_arrow_shape_a() = 11.0;
1433 canvas_item->property_arrow_shape_b() = 0.0;
1434 canvas_item->property_arrow_shape_c() = 4.0;
1436 canvas_item->raise_to_top ();
1437 canvas_item->show ();
1439 canvas_item->set_data ("regionview", this);
1440 canvas_item->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_feature_line_event), canvas_item, this));
1442 feature_lines.push_back (make_pair(0, canvas_item));
1445 while (feature_lines.size() > analysis_features.size()) {
1446 ArdourCanvas::Line* line = feature_lines.back().second;
1447 feature_lines.pop_back ();
1451 AnalysisFeatureList::const_iterator i;
1452 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
1454 for (i = analysis_features.begin(), l = feature_lines.begin(); i != analysis_features.end() && l != feature_lines.end(); ++i, ++l) {
1456 ArdourCanvas::Points points;
1458 float *pos = new float;
1459 *pos = trackview.editor().frame_to_pixel (*i);
1461 points.push_back(Gnome::Art::Point(*pos, 2.0)); // first x-coord needs to be a non-normal value
1462 points.push_back(Gnome::Art::Point(*pos, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1));
1464 (*l).second->property_points() = points;
1465 (*l).second->set_data ("position", pos);
1472 AudioRegionView::update_transient(float /*old_pos*/, float new_pos)
1474 /* Find frame at old pos, calulate new frame then update region transients*/
1475 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
1477 for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
1479 /* Line has been updated in drag so we compare to new_pos */
1481 float* pos = (float*) (*l).second->get_data ("position");
1483 if (rint(new_pos) == rint(*pos)) {
1485 framepos_t old_frame = (*l).first;
1486 framepos_t new_frame = trackview.editor().pixel_to_frame (new_pos);
1488 _region->update_transient (old_frame, new_frame);
1496 AudioRegionView::remove_transient(float pos)
1498 /* Find frame at old pos, calulate new frame then update region transients*/
1499 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
1501 for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
1503 /* Line has been updated in drag so we compare to new_pos */
1504 float *line_pos = (float*) (*l).second->get_data ("position");
1506 if (rint(pos) == rint(*line_pos)) {
1507 _region->remove_transient ((*l).first);
1514 AudioRegionView::thaw_after_trim ()
1516 RegionView::thaw_after_trim ();
1522 AudioRegionView::redraw_start_xfade ()
1524 boost::shared_ptr<AudioRegion> ar (audio_region());
1526 if (!ar->fade_in() || ar->fade_in()->empty()) {
1530 if (!ar->fade_in_is_xfade()) {
1531 if (start_xfade_in) {
1532 start_xfade_in->hide ();
1533 start_xfade_out->hide ();
1534 start_xfade_rect->hide ();
1539 redraw_start_xfade_to (ar, ar->fade_in()->back()->when);
1543 AudioRegionView::redraw_start_xfade_to (boost::shared_ptr<AudioRegion> ar, framecnt_t len)
1545 int32_t const npoints = trackview.editor().frame_to_pixel (len);
1551 if (!start_xfade_in) {
1552 start_xfade_in = new ArdourCanvas::Line (*group);
1553 start_xfade_in->property_width_pixels() = 1;
1554 start_xfade_in->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GainLine.get();
1557 if (!start_xfade_out) {
1558 start_xfade_out = new ArdourCanvas::Line (*group);
1559 start_xfade_out->property_width_pixels() = 1;
1560 uint32_t col = UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->canvasvar_GainLine.get(), 125);
1561 start_xfade_out->property_fill_color_rgba() = col;
1564 if (!start_xfade_rect) {
1565 start_xfade_rect = new ArdourCanvas::SimpleRect (*group);
1566 start_xfade_rect->property_draw() = true;
1567 start_xfade_rect->property_fill() = true;;
1568 start_xfade_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ActiveCrossfade.get();
1569 start_xfade_rect->property_outline_pixels() = 0;
1570 start_xfade_rect->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_start_xfade_event), start_xfade_rect, this));
1571 start_xfade_rect->set_data ("regionview", this);
1574 Points* points = get_canvas_points ("xfade edit redraw", npoints);
1575 boost::scoped_ptr<float> vec (new float[npoints]);
1576 double effective_height = _height - NAME_HIGHLIGHT_SIZE - 1.0;
1578 ar->fade_in()->curve().get_vector (0, ar->fade_in()->back()->when, vec.get(), npoints);
1580 for (int i = 0, pci = 0; i < npoints; ++i) {
1581 Gnome::Art::Point &p ((*points)[pci++]);
1583 p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
1586 start_xfade_rect->property_x1() = ((*points)[0]).get_x();
1587 start_xfade_rect->property_y1() = 1.0;
1588 start_xfade_rect->property_x2() = ((*points)[npoints-1]).get_x();
1589 start_xfade_rect->property_y2() = effective_height;
1590 start_xfade_rect->show ();
1591 start_xfade_rect->raise_to_top ();
1593 start_xfade_in->property_points() = *points;
1594 start_xfade_in->show ();
1595 start_xfade_in->raise_to_top ();
1599 boost::shared_ptr<AutomationList> inverse = ar->inverse_fade_in();
1603 for (int i = 0, pci = 0; i < npoints; ++i) {
1604 Gnome::Art::Point &p ((*points)[pci++]);
1606 p.set_y (1.0 + effective_height - (effective_height * (1.0 - vec.get()[i])));
1611 inverse->curve().get_vector (0, inverse->back()->when, vec.get(), npoints);
1613 for (int i = 0, pci = 0; i < npoints; ++i) {
1614 Gnome::Art::Point &p ((*points)[pci++]);
1616 p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
1620 start_xfade_out->property_points() = *points;
1621 start_xfade_out->show ();
1622 start_xfade_out->raise_to_top ();
1628 AudioRegionView::redraw_end_xfade ()
1630 boost::shared_ptr<AudioRegion> ar (audio_region());
1632 if (!ar->fade_out() || ar->fade_out()->empty()) {
1636 if (!ar->fade_out_is_xfade()) {
1638 end_xfade_in->hide ();
1639 end_xfade_out->hide ();
1640 end_xfade_rect->hide ();
1645 redraw_end_xfade_to (ar, ar->fade_out()->back()->when);
1649 AudioRegionView::redraw_end_xfade_to (boost::shared_ptr<AudioRegion> ar, framecnt_t len)
1651 int32_t const npoints = trackview.editor().frame_to_pixel (len);
1657 if (!end_xfade_in) {
1658 end_xfade_in = new ArdourCanvas::Line (*group);
1659 end_xfade_in->property_width_pixels() = 1;
1660 end_xfade_in->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GainLine.get();
1663 if (!end_xfade_out) {
1664 end_xfade_out = new ArdourCanvas::Line (*group);
1665 end_xfade_out->property_width_pixels() = 1;
1666 uint32_t col UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->canvasvar_GainLine.get(), 125);
1667 end_xfade_out->property_fill_color_rgba() = col;
1670 if (!end_xfade_rect) {
1671 end_xfade_rect = new ArdourCanvas::SimpleRect (*group);
1672 end_xfade_rect->property_draw() = true;
1673 end_xfade_rect->property_fill() = true;;
1674 end_xfade_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ActiveCrossfade.get();
1675 end_xfade_rect->property_outline_pixels() = 0;
1676 end_xfade_rect->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_end_xfade_event), end_xfade_rect, this));
1677 end_xfade_rect->set_data ("regionview", this);
1680 Points* points = get_canvas_points ("xfade edit redraw", npoints);
1681 boost::scoped_ptr<float> vec (new float[npoints]);
1683 ar->fade_out()->curve().get_vector (0, ar->fade_out()->back()->when, vec.get(), npoints);
1685 double rend = trackview.editor().frame_to_pixel (_region->length() - len);
1686 double effective_height = _height - NAME_HIGHLIGHT_SIZE - 1;
1688 for (int i = 0, pci = 0; i < npoints; ++i) {
1689 Gnome::Art::Point &p ((*points)[pci++]);
1691 p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
1694 end_xfade_rect->property_x1() = ((*points)[0]).get_x();
1695 end_xfade_rect->property_y1() = 1;
1696 end_xfade_rect->property_x2() = ((*points)[npoints-1]).get_x();
1697 end_xfade_rect->property_y2() = effective_height;
1698 end_xfade_rect->show ();
1699 end_xfade_rect->raise_to_top ();
1701 end_xfade_in->property_points() = *points;
1702 end_xfade_in->show ();
1703 end_xfade_in->raise_to_top ();
1707 boost::shared_ptr<AutomationList> inverse = ar->inverse_fade_out ();
1711 for (int i = 0, pci = 0; i < npoints; ++i) {
1712 Gnome::Art::Point &p ((*points)[pci++]);
1714 p.set_y (1.0 + effective_height - (effective_height * (1.0 - vec.get()[i])));
1719 inverse->curve().get_vector (inverse->front()->when, inverse->back()->when, vec.get(), npoints);
1721 for (int i = 0, pci = 0; i < npoints; ++i) {
1722 Gnome::Art::Point &p ((*points)[pci++]);
1724 p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
1728 end_xfade_out->property_points() = *points;
1729 end_xfade_out->show ();
1730 end_xfade_out->raise_to_top ();
1737 AudioRegionView::hide_xfades ()
1739 if (start_xfade_in) {
1740 start_xfade_in->hide();
1742 if (start_xfade_out) {
1743 start_xfade_out->hide();
1745 if (start_xfade_rect) {
1746 start_xfade_rect->hide ();
1749 end_xfade_in->hide();
1751 if (end_xfade_out) {
1752 end_xfade_out->hide();
1754 if (end_xfade_rect) {
1755 end_xfade_rect->hide ();
1760 AudioRegionView::show_xfades ()
1762 if (start_xfade_in) {
1763 start_xfade_in->show();
1765 if (start_xfade_out) {
1766 start_xfade_out->show();
1768 if (start_xfade_rect) {
1769 start_xfade_rect->show ();
1772 end_xfade_in->show();
1774 if (end_xfade_out) {
1775 end_xfade_out->show();
1777 if (end_xfade_rect) {
1778 end_xfade_rect->show ();
1783 AudioRegionView::drag_start ()
1785 TimeAxisViewItem::drag_start ();
1786 AudioTimeAxisView* atav = dynamic_cast<AudioTimeAxisView*> (&trackview);
1789 AudioStreamView* av = atav->audio_view();
1791 /* this will hide our xfades too */
1792 av->hide_xfades_with (audio_region());
1798 AudioRegionView::drag_end ()
1800 TimeAxisViewItem::drag_end ();
1801 /* fades will be redrawn if they changed */
1804 AutomationLine::VisibleAspects
1805 AudioRegionView::automation_line_visibility () const
1807 if (Config->get_show_region_gain() || trackview.editor().current_mouse_mode() == Editing::MouseGain) {
1808 return AutomationLine::Line;
1810 return AutomationLine::VisibleAspects (0);