2 Copyright (C) 2001-2006 Paul Davis
4 This program is free software; you can r>edistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <boost/scoped_ptr.hpp>
27 #include <gtkmm2ext/gtk_ui.h>
29 #include "ardour/playlist.h"
30 #include "ardour/audioregion.h"
31 #include "ardour/audiosource.h"
32 #include "ardour/profile.h"
33 #include "ardour/session.h"
35 #include "pbd/memento_command.h"
36 #include "pbd/stacktrace.h"
38 #include "evoral/Curve.hpp"
40 #include "streamview.h"
41 #include "audio_region_view.h"
42 #include "audio_time_axis.h"
43 #include "simplerect.h"
44 #include "simpleline.h"
46 #include "public_editor.h"
47 #include "audio_region_editor.h"
48 #include "audio_streamview.h"
49 #include "region_gain_line.h"
50 #include "control_point.h"
51 #include "ghostregion.h"
52 #include "audio_time_axis.h"
54 #include "rgb_macros.h"
55 #include "gui_thread.h"
56 #include "ardour_ui.h"
60 #define MUTED_ALPHA 10
63 using namespace ARDOUR;
65 using namespace Editing;
66 using namespace ArdourCanvas;
68 static const int32_t sync_mark_width = 9;
69 static double const handle_size = 6; /* height of fade handles */
71 AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, boost::shared_ptr<AudioRegion> r, double spu,
72 Gdk::Color const & basic_color)
73 : RegionView (parent, tv, r, spu, basic_color)
79 , fade_position_line(0)
82 , start_xfade_rect (0)
83 , _start_xfade_visible (false)
87 , _end_xfade_visible (false)
88 , _amplitude_above_axis(1.0)
91 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&AudioRegionView::parameter_changed, this, _1), gui_context());
94 AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, boost::shared_ptr<AudioRegion> r, double spu,
95 Gdk::Color const & basic_color, bool recording, TimeAxisViewItem::Visibility visibility)
96 : RegionView (parent, tv, r, spu, basic_color, recording, visibility)
102 , fade_position_line(0)
104 , start_xfade_out (0)
105 , start_xfade_rect (0)
106 , _start_xfade_visible (false)
110 , _end_xfade_visible (false)
111 , _amplitude_above_axis(1.0)
114 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&AudioRegionView::parameter_changed, this, _1), gui_context());
117 AudioRegionView::AudioRegionView (const AudioRegionView& other, boost::shared_ptr<AudioRegion> other_region)
118 : RegionView (other, boost::shared_ptr<Region> (other_region))
123 , fade_position_line(0)
125 , start_xfade_out (0)
126 , start_xfade_rect (0)
127 , _start_xfade_visible (false)
131 , _end_xfade_visible (false)
132 , _amplitude_above_axis (other._amplitude_above_axis)
138 UINT_TO_RGBA (other.fill_color, &r, &g, &b, &a);
139 c.set_rgb_p (r/255.0, g/255.0, b/255.0);
143 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&AudioRegionView::parameter_changed, this, _1), gui_context());
147 AudioRegionView::init (Gdk::Color const & basic_color, bool wfd)
149 // FIXME: Some redundancy here with RegionView::init. Need to figure out
150 // where order is important and where it isn't...
152 RegionView::init (basic_color, wfd);
154 _amplitude_above_axis = 1.0;
156 compute_colors (basic_color);
160 fade_in_shape = new ArdourCanvas::Polygon (*group);
161 fade_in_shape->property_fill_color_rgba() = fade_color;
162 fade_in_shape->set_data ("regionview", this);
164 fade_out_shape = new ArdourCanvas::Polygon (*group);
165 fade_out_shape->property_fill_color_rgba() = fade_color;
166 fade_out_shape->set_data ("regionview", this);
169 fade_in_handle = new ArdourCanvas::SimpleRect (*group);
170 fade_in_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fill_color, 0);
171 fade_in_handle->property_outline_color_rgba() = RGBA_TO_UINT (0, 0, 0, 0);
173 fade_in_handle->set_data ("regionview", this);
175 fade_out_handle = new ArdourCanvas::SimpleRect (*group);
176 fade_out_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fill_color, 0);
177 fade_out_handle->property_outline_color_rgba() = RGBA_TO_UINT (0, 0, 0, 0);
179 fade_out_handle->set_data ("regionview", this);
181 fade_position_line = new ArdourCanvas::SimpleLine (*group);
182 fade_position_line->property_color_rgba() = 0xBBBBBBAA;
183 fade_position_line->property_y1() = 7;
184 fade_position_line->property_y2() = _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1;
186 fade_position_line->hide();
189 setup_fade_handle_positions ();
191 if (!trackview.session()->config.get_show_region_fades()) {
192 set_fade_visibility (false);
195 const string line_name = _region->name() + ":gain";
197 if (!Profile->get_sae()) {
198 gain_line.reset (new AudioRegionGainLine (line_name, *this, *group, audio_region()->envelope()));
201 update_envelope_visibility ();
204 set_height (trackview.current_height());
207 region_sync_changed ();
209 region_resized (ARDOUR::bounds_change);
210 set_waveview_data_src();
212 envelope_active_changed ();
213 fade_in_active_changed ();
214 fade_out_active_changed ();
216 reset_width_dependent_items (_pixel_width);
218 fade_in_shape->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_event), fade_in_shape, this));
219 if (fade_in_handle) {
220 fade_in_handle->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_handle_event), fade_in_handle, this));
223 fade_out_shape->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_event), fade_out_shape, this));
225 if (fade_out_handle) {
226 fade_out_handle->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_handle_event), fade_out_handle, this));
231 setup_waveform_visibility ();
232 setup_waveform_shape ();
233 setup_waveform_scale ();
235 /* XXX sync mark drag? */
238 AudioRegionView::~AudioRegionView ()
240 in_destructor = true;
242 RegionViewGoingAway (this); /* EMIT_SIGNAL */
244 for (vector<GnomeCanvasWaveViewCache *>::iterator cache = wave_caches.begin(); cache != wave_caches.end() ; ++cache) {
245 gnome_canvas_waveview_cache_destroy (*cache);
248 for (vector<ScopedConnection*>::iterator i = _data_ready_connections.begin(); i != _data_ready_connections.end(); ++i) {
252 for (list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator i = feature_lines.begin(); i != feature_lines.end(); ++i) {
253 delete ((*i).second);
256 /* all waveviews etc will be destroyed when the group is destroyed */
259 boost::shared_ptr<ARDOUR::AudioRegion>
260 AudioRegionView::audio_region() const
262 // "Guaranteed" to succeed...
263 return boost::dynamic_pointer_cast<AudioRegion>(_region);
267 AudioRegionView::region_changed (const PropertyChange& what_changed)
269 ENSURE_GUI_THREAD (*this, &AudioRegionView::region_changed, what_changed);
270 // cerr << "AudioRegionView::region_changed() called" << endl;
272 RegionView::region_changed (what_changed);
274 if (what_changed.contains (ARDOUR::Properties::scale_amplitude)) {
275 region_scale_amplitude_changed ();
277 if (what_changed.contains (ARDOUR::Properties::fade_in)) {
280 if (what_changed.contains (ARDOUR::Properties::fade_out)) {
283 if (what_changed.contains (ARDOUR::Properties::fade_in_active)) {
284 fade_in_active_changed ();
286 if (what_changed.contains (ARDOUR::Properties::fade_out_active)) {
287 fade_out_active_changed ();
289 if (what_changed.contains (ARDOUR::Properties::envelope_active)) {
290 envelope_active_changed ();
292 if (what_changed.contains (ARDOUR::Properties::valid_transients)) {
293 transients_changed ();
298 AudioRegionView::fade_in_changed ()
300 reset_fade_in_shape ();
304 AudioRegionView::fade_out_changed ()
306 reset_fade_out_shape ();
310 AudioRegionView::fade_in_active_changed ()
312 if (audio_region()->fade_in_active()) {
313 fade_in_shape->property_fill_color_rgba() = RGBA_TO_UINT(45,45,45,90); // FIXME make a themeable colour
314 fade_in_shape->property_width_pixels() = 1;
316 fade_in_shape->property_fill_color_rgba() = RGBA_TO_UINT(45,45,45,20); // FIXME make a themeable colour
317 fade_in_shape->property_width_pixels() = 1;
322 AudioRegionView::fade_out_active_changed ()
324 if (audio_region()->fade_out_active()) {
325 fade_out_shape->property_fill_color_rgba() = RGBA_TO_UINT(45,45,45,90); // FIXME make a themeable colour
326 fade_out_shape->property_width_pixels() = 1;
328 fade_out_shape->property_fill_color_rgba() = RGBA_TO_UINT(45,45,45,20); // FIXME make a themeable colour
329 fade_out_shape->property_width_pixels() = 1;
335 AudioRegionView::region_scale_amplitude_changed ()
337 ENSURE_GUI_THREAD (*this, &AudioRegionView::region_scale_amplitude_changed)
339 for (uint32_t n = 0; n < waves.size(); ++n) {
340 // force a reload of the cache
341 waves[n]->property_data_src() = _region.get();
346 AudioRegionView::region_renamed ()
348 std::string str = RegionView::make_name ();
350 if (audio_region()->speed_mismatch (trackview.session()->frame_rate())) {
351 str = string ("*") + str;
354 if (_region->muted()) {
355 str = string ("!") + str;
358 set_item_name (str, this);
363 AudioRegionView::region_resized (const PropertyChange& what_changed)
365 AudioGhostRegion* agr;
367 RegionView::region_resized(what_changed);
368 PropertyChange interesting_stuff;
370 interesting_stuff.add (ARDOUR::Properties::start);
371 interesting_stuff.add (ARDOUR::Properties::length);
373 if (what_changed.contains (interesting_stuff)) {
375 for (uint32_t n = 0; n < waves.size(); ++n) {
376 waves[n]->property_region_start() = _region->start();
379 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
380 if ((agr = dynamic_cast<AudioGhostRegion*>(*i)) != 0) {
382 for (vector<WaveView*>::iterator w = agr->waves.begin(); w != agr->waves.end(); ++w) {
383 (*w)->property_region_start() = _region->start();
388 /* hide transient lines that extend beyond the region end */
390 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
392 for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
393 if (l->first > _region->length() - 1) {
403 AudioRegionView::reset_width_dependent_items (double pixel_width)
405 RegionView::reset_width_dependent_items(pixel_width);
406 assert(_pixel_width == pixel_width);
408 if (fade_in_handle) {
409 if (pixel_width <= 6.0 || _height < 5.0 || !trackview.session()->config.get_show_region_fades()) {
410 fade_in_handle->hide();
411 fade_out_handle->hide();
414 fade_in_handle->show();
415 fade_out_handle->show();
419 AnalysisFeatureList analysis_features = _region->transients();
420 AnalysisFeatureList::const_iterator i;
422 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
424 for (i = analysis_features.begin(), l = feature_lines.begin(); i != analysis_features.end() && l != feature_lines.end(); ++i, ++l) {
426 float x_pos = trackview.editor().frame_to_pixel (*i);
428 ArdourCanvas::Points points;
429 points.push_back(Gnome::Art::Point(x_pos, 2.0)); // first x-coord needs to be a non-normal value
430 points.push_back(Gnome::Art::Point(x_pos, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1));
433 (*l).second->property_points() = points;
436 reset_fade_shapes ();
440 AudioRegionView::region_muted ()
442 RegionView::region_muted();
444 for (uint32_t n=0; n < waves.size(); ++n) {
445 if (_region->muted()) {
446 waves[n]->property_wave_color() = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_WaveForm.get(), MUTED_ALPHA);
448 waves[n]->property_wave_color() = ARDOUR_UI::config()->canvasvar_WaveForm.get();
454 AudioRegionView::setup_fade_handle_positions()
456 /* position of fade handle offset from the top of the region view */
457 double const handle_pos = 2;
459 if (fade_in_handle) {
460 fade_in_handle->property_y1() = handle_pos;
461 fade_in_handle->property_y2() = handle_pos + handle_size;
464 if (fade_out_handle) {
465 fade_out_handle->property_y1() = handle_pos;
466 fade_out_handle->property_y2() = handle_pos + handle_size;
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 ();
567 _start_xfade_visible = false;
571 if (fade_in_handle == 0) {
575 fade_in_handle->show ();
577 /* smallest size for a fade is 64 frames */
579 width = std::max ((framecnt_t) 64, width);
583 /* round here to prevent little visual glitches with sub-pixel placement */
584 double const pwidth = rint (width / samples_per_unit);
585 uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth);
589 fade_in_shape->hide();
590 fade_in_handle->hide();
594 double const handle_center = pwidth;
596 /* Put the fade in handle so that its left side is at the end-of-fade line */
597 fade_in_handle->property_x1() = handle_center;
598 fade_in_handle->property_x2() = handle_center + handle_size;
601 fade_in_shape->hide();
605 if (trackview.session()->config.get_show_region_fades()) {
606 fade_in_shape->show();
609 float curve[npoints];
610 audio_region()->fade_in()->curve().get_vector (0, audio_region()->fade_in()->back()->when, curve, npoints);
612 points = get_canvas_points ("fade in shape", npoints + 3);
614 if (_height >= NAME_HIGHLIGHT_THRESH) {
615 h = _height - NAME_HIGHLIGHT_SIZE - 2;
620 /* points *MUST* be in anti-clockwise order */
623 double xdelta = pwidth/npoints;
625 for (pi = 0, pc = 0; pc < npoints; ++pc) {
626 (*points)[pi].set_x(1 + (pc * xdelta));
627 (*points)[pi++].set_y(2 + (h - (curve[pc] * h)));
632 (*points)[pi].set_x(pwidth);
633 (*points)[pi++].set_y(2);
635 (*points)[pi].set_x(1);
636 (*points)[pi++].set_y(2);
638 /* connect the dots ... */
640 (*points)[pi] = (*points)[0];
642 fade_in_shape->property_points() = *points;
645 /* ensure trim handle stays on top */
646 if (frame_handle_start) {
647 frame_handle_start->raise_to_top();
652 AudioRegionView::reset_fade_out_shape ()
654 reset_fade_out_shape_width ((framecnt_t) audio_region()->fade_out()->back()->when);
658 AudioRegionView::reset_fade_out_shape_width (framecnt_t width)
660 if (dragging() && audio_region()->fade_out_is_xfade()) {
661 /* we hide xfades while dragging regions */
665 if (audio_region()->fade_out_is_xfade()) {
666 if (fade_out_handle) {
667 fade_out_handle->hide ();
668 fade_out_shape->hide ();
674 end_xfade_in->hide ();
675 end_xfade_out->hide ();
676 end_xfade_rect->hide ();
677 _end_xfade_visible = false;
681 if (fade_out_handle == 0) {
685 fade_out_handle->show ();
687 /* smallest size for a fade is 64 frames */
689 width = std::max ((framecnt_t) 64, width);
693 /* round here to prevent little visual glitches with sub-pixel placement */
694 double const pwidth = rint (width / samples_per_unit);
695 uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth);
699 fade_out_shape->hide();
700 fade_out_handle->hide();
704 double const handle_center = (_region->length() - width) / samples_per_unit;
706 /* Put the fade out handle so that its right side is at the end-of-fade line;
707 * it's `one out' for precise pixel accuracy.
709 fade_out_handle->property_x1() = handle_center - 5;
710 fade_out_handle->property_x2() = handle_center + 1;
712 /* don't show shape if its too small */
715 fade_out_shape->hide();
719 if (trackview.session()->config.get_show_region_fades()) {
720 fade_out_shape->show();
723 float curve[npoints];
724 audio_region()->fade_out()->curve().get_vector (0, audio_region()->fade_out()->back()->when, curve, npoints);
726 if (_height >= NAME_HIGHLIGHT_THRESH) {
727 h = _height - NAME_HIGHLIGHT_SIZE - 2;
732 /* points *MUST* be in anti-clockwise order */
734 points = get_canvas_points ("fade out shape", npoints + 3);
737 double xdelta = pwidth/npoints;
739 for (pi = 0, pc = 0; pc < npoints; ++pc) {
740 (*points)[pi].set_x(_pixel_width - pwidth + (pc * xdelta));
741 (*points)[pi++].set_y(2 + (h - (curve[pc] * h)));
746 (*points)[pi].set_x(_pixel_width);
747 (*points)[pi++].set_y(h);
749 (*points)[pi].set_x(_pixel_width);
750 (*points)[pi++].set_y(2);
752 /* connect the dots ... */
754 (*points)[pi] = (*points)[0];
756 fade_out_shape->property_points() = *points;
759 /* ensure trim handle stays on top */
760 if (frame_handle_end) {
761 frame_handle_end->raise_to_top();
766 AudioRegionView::set_samples_per_unit (gdouble spu)
768 RegionView::set_samples_per_unit (spu);
770 if (Config->get_show_waveforms ()) {
771 for (uint32_t n = 0; n < waves.size(); ++n) {
772 waves[n]->property_samples_per_unit() = spu;
780 reset_fade_shapes ();
784 AudioRegionView::set_amplitude_above_axis (gdouble spp)
786 for (uint32_t n=0; n < waves.size(); ++n) {
787 waves[n]->property_amplitude_above_axis() = spp;
792 AudioRegionView::compute_colors (Gdk::Color const & basic_color)
794 RegionView::compute_colors (basic_color);
796 /* gain color computed in envelope_active_changed() */
798 fade_color = UINT_RGBA_CHANGE_A (fill_color, 120);
802 AudioRegionView::set_colors ()
804 RegionView::set_colors();
807 gain_line->set_line_color (audio_region()->envelope_active() ? ARDOUR_UI::config()->canvasvar_GainLine.get() : ARDOUR_UI::config()->canvasvar_GainLineInactive.get());
810 for (uint32_t n=0; n < waves.size(); ++n) {
811 if (_region->muted()) {
812 waves[n]->property_wave_color() = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_WaveForm.get(), MUTED_ALPHA);
814 waves[n]->property_wave_color() = ARDOUR_UI::config()->canvasvar_WaveForm.get();
817 waves[n]->property_clip_color() = ARDOUR_UI::config()->canvasvar_WaveFormClip.get();
818 waves[n]->property_zero_color() = ARDOUR_UI::config()->canvasvar_ZeroLine.get();
823 AudioRegionView::setup_waveform_visibility ()
825 if (Config->get_show_waveforms ()) {
826 for (uint32_t n = 0; n < waves.size(); ++n) {
827 /* make sure the zoom level is correct, since we don't update
828 this when waveforms are hidden.
830 waves[n]->property_samples_per_unit() = samples_per_unit;
834 for (uint32_t n = 0; n < waves.size(); ++n) {
841 AudioRegionView::temporarily_hide_envelope ()
849 AudioRegionView::unhide_envelope ()
851 update_envelope_visibility ();
855 AudioRegionView::update_envelope_visibility ()
861 if (Config->get_show_region_gain() || trackview.editor().current_mouse_mode() == Editing::MouseGain) {
862 gain_line->add_visibility (AutomationLine::Line);
869 AudioRegionView::create_waves ()
871 // cerr << "AudioRegionView::create_waves() called on " << this << endl;//DEBUG
872 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
878 ChanCount nchans = atv.track()->n_channels();
880 // cerr << "creating waves for " << _region->name() << " with wfd = " << wait_for_data
881 // << " and channels = " << nchans.n_audio() << endl;
883 /* in tmp_waves, set up null pointers for each channel so the vector is allocated */
884 for (uint32_t n = 0; n < nchans.n_audio(); ++n) {
885 tmp_waves.push_back (0);
888 for (vector<ScopedConnection*>::iterator i = _data_ready_connections.begin(); i != _data_ready_connections.end(); ++i) {
892 _data_ready_connections.clear ();
894 for (uint32_t i = 0; i < nchans.n_audio(); ++i) {
895 _data_ready_connections.push_back (0);
898 for (uint32_t n = 0; n < nchans.n_audio(); ++n) {
900 if (n >= audio_region()->n_channels()) {
904 wave_caches.push_back (WaveView::create_cache ());
906 // cerr << "\tchannel " << n << endl;
909 if (audio_region()->audio_source(n)->peaks_ready (boost::bind (&AudioRegionView::peaks_ready_handler, this, n), &_data_ready_connections[n], gui_context())) {
910 // cerr << "\tData is ready\n";
911 create_one_wave (n, true);
913 // cerr << "\tdata is not ready\n";
914 // we'll get a PeaksReady signal from the source in the future
915 // and will call create_one_wave(n) then.
919 // cerr << "\tdon't delay, display today!\n";
920 create_one_wave (n, true);
927 AudioRegionView::create_one_wave (uint32_t which, bool /*direct*/)
929 //cerr << "AudioRegionView::create_one_wave() called which: " << which << " this: " << this << endl;//DEBUG
930 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
931 uint32_t nchans = atv.track()->n_channels().n_audio();
933 uint32_t nwaves = std::min (nchans, audio_region()->n_channels());
936 if (trackview.current_height() < NAME_HIGHLIGHT_THRESH) {
937 ht = ((trackview.current_height()) / (double) nchans);
939 ht = ((trackview.current_height() - NAME_HIGHLIGHT_SIZE) / (double) nchans);
942 gdouble yoff = which * ht;
944 WaveView *wave = new WaveView(*group);
946 wave->property_data_src() = (gpointer) _region.get();
947 wave->property_cache() = wave_caches[which];
948 wave->property_cache_updater() = true;
949 wave->property_channel() = which;
950 wave->property_length_function() = (gpointer) region_length_from_c;
951 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
952 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
953 wave->property_x() = 0.0;
954 wave->property_y() = yoff;
955 wave->property_height() = (double) ht;
956 wave->property_samples_per_unit() = samples_per_unit;
957 wave->property_amplitude_above_axis() = _amplitude_above_axis;
960 wave->property_wave_color() = _region->muted() ? UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_RecWaveForm.get(), MUTED_ALPHA) : ARDOUR_UI::config()->canvasvar_RecWaveForm.get();
961 wave->property_fill_color() = ARDOUR_UI::config()->canvasvar_RecWaveFormFill.get();
963 wave->property_wave_color() = _region->muted() ? UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_WaveForm.get(), MUTED_ALPHA) : ARDOUR_UI::config()->canvasvar_WaveForm.get();
964 wave->property_fill_color() = ARDOUR_UI::config()->canvasvar_WaveFormFill.get();
967 wave->property_clip_color() = ARDOUR_UI::config()->canvasvar_WaveFormClip.get();
968 wave->property_zero_color() = ARDOUR_UI::config()->canvasvar_ZeroLine.get();
969 wave->property_zero_line() = true;
970 wave->property_region_start() = _region->start();
971 wave->property_rectified() = Config->get_waveform_shape() == Rectified;
972 wave->property_logscaled() = Config->get_waveform_scale() == Logarithmic;
974 if (!Config->get_show_waveforms ()) {
978 /* note: calling this function is serialized by the lock
979 held in the peak building thread that signals that
980 peaks are ready for use *or* by the fact that it is
981 called one by one from the GUI thread.
984 if (which < nchans) {
985 tmp_waves[which] = wave;
987 /* n-channel track, >n-channel source */
990 /* see if we're all ready */
992 for (n = 0; n < nchans; ++n) {
993 if (tmp_waves[n] == 0) {
998 if (n == nwaves && waves.empty()) {
999 /* all waves are ready */
1000 tmp_waves.resize(nwaves);
1005 /* all waves created, don't hook into peaks ready anymore */
1006 delete _data_ready_connections[which];
1007 _data_ready_connections[which] = 0;
1012 AudioRegionView::peaks_ready_handler (uint32_t which)
1014 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&AudioRegionView::create_one_wave, this, which, false));
1015 // cerr << "AudioRegionView::peaks_ready_handler() called on " << which << " this: " << this << endl;
1019 AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
1027 /* don't create points that can't be seen */
1029 update_envelope_visibility ();
1036 framepos_t fx = trackview.editor().pixel_to_frame (x);
1038 if (fx > _region->length()) {
1042 /* compute vertical fractional position */
1044 y = 1.0 - (y / (_height - NAME_HIGHLIGHT_SIZE));
1046 /* map using gain line */
1048 gain_line->view_to_model_coord (x, y);
1050 /* XXX STATEFUL: can't convert to stateful diff until we
1051 can represent automation data with it.
1054 trackview.session()->begin_reversible_command (_("add gain control point"));
1055 XMLNode &before = audio_region()->envelope()->get_state();
1057 if (!audio_region()->envelope_active()) {
1058 XMLNode ®ion_before = audio_region()->get_state();
1059 audio_region()->set_envelope_active(true);
1060 XMLNode ®ion_after = audio_region()->get_state();
1061 trackview.session()->add_command (new MementoCommand<AudioRegion>(*(audio_region().get()), ®ion_before, ®ion_after));
1064 audio_region()->envelope()->add (fx, y);
1066 XMLNode &after = audio_region()->envelope()->get_state();
1067 trackview.session()->add_command (new MementoCommand<AutomationList>(*audio_region()->envelope().get(), &before, &after));
1068 trackview.session()->commit_reversible_command ();
1072 AudioRegionView::remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent */*ev*/)
1074 ControlPoint *cp = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"));
1075 audio_region()->envelope()->erase (cp->model());
1079 AudioRegionView::setup_waveform_shape ()
1081 for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
1082 (*wave)->property_rectified() = Config->get_waveform_shape() == Rectified;
1087 AudioRegionView::setup_waveform_scale ()
1089 for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
1090 (*wave)->property_logscaled() = Config->get_waveform_scale() == Logarithmic;
1096 AudioRegionView::add_ghost (TimeAxisView& tv)
1098 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&trackview);
1101 double unit_position = _region->position () / samples_per_unit;
1102 AudioGhostRegion* ghost = new AudioGhostRegion (tv, trackview, unit_position);
1105 nchans = rtv->track()->n_channels().n_audio();
1107 for (uint32_t n = 0; n < nchans; ++n) {
1109 if (n >= audio_region()->n_channels()) {
1113 WaveView *wave = new WaveView(*ghost->group);
1115 wave->property_data_src() = _region.get();
1116 wave->property_cache() = wave_caches[n];
1117 wave->property_cache_updater() = false;
1118 wave->property_channel() = n;
1119 wave->property_length_function() = (gpointer)region_length_from_c;
1120 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
1121 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
1122 wave->property_x() = 0.0;
1123 wave->property_samples_per_unit() = samples_per_unit;
1124 wave->property_amplitude_above_axis() = _amplitude_above_axis;
1126 wave->property_region_start() = _region->start();
1128 ghost->waves.push_back(wave);
1131 ghost->set_height ();
1132 ghost->set_duration (_region->length() / samples_per_unit);
1133 ghost->set_colors();
1134 ghosts.push_back (ghost);
1140 AudioRegionView::entered (bool internal_editing)
1142 trackview.editor().set_current_trimmable (_region);
1143 trackview.editor().set_current_movable (_region);
1145 if (gain_line && trackview.editor().current_mouse_mode() == Editing::MouseGain) {
1146 gain_line->add_visibility (AutomationLine::ControlPoints);
1149 if (fade_in_handle && !internal_editing) {
1150 fade_in_handle->property_outline_color_rgba() = RGBA_TO_UINT (0, 0, 0, 255);
1151 fade_in_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 255);
1152 fade_out_handle->property_outline_color_rgba() = RGBA_TO_UINT (0, 0, 0, 255);
1153 fade_out_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 255);
1158 AudioRegionView::exited ()
1160 trackview.editor().set_current_trimmable (boost::shared_ptr<Trimmable>());
1161 trackview.editor().set_current_movable (boost::shared_ptr<Movable>());
1163 if (gain_line && trackview.editor().current_mouse_mode() == Editing::MouseGain) {
1164 gain_line->remove_visibility (AutomationLine::ControlPoints);
1167 if (fade_in_handle) {
1168 fade_in_handle->property_outline_color_rgba() = RGBA_TO_UINT (0, 0, 0, 0);
1169 fade_in_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 0);
1170 fade_out_handle->property_outline_color_rgba() = RGBA_TO_UINT (0, 0, 0, 0);
1171 fade_out_handle->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (fade_color, 0);
1176 AudioRegionView::envelope_active_changed ()
1179 gain_line->set_line_color (audio_region()->envelope_active() ? ARDOUR_UI::config()->canvasvar_GainLine.get() : ARDOUR_UI::config()->canvasvar_GainLineInactive.get());
1184 AudioRegionView::set_waveview_data_src()
1186 AudioGhostRegion* agr;
1187 double unit_length= _region->length() / samples_per_unit;
1189 for (uint32_t n = 0; n < waves.size(); ++n) {
1190 // TODO: something else to let it know the channel
1191 waves[n]->property_data_src() = _region.get();
1194 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
1196 (*i)->set_duration (unit_length);
1198 if((agr = dynamic_cast<AudioGhostRegion*>(*i)) != 0) {
1199 for (vector<WaveView*>::iterator w = agr->waves.begin(); w != agr->waves.end(); ++w) {
1200 (*w)->property_data_src() = _region.get();
1208 AudioRegionView::color_handler ()
1210 //case cMutedWaveForm:
1212 //case cWaveFormClip:
1216 //case cGainLineInactive:
1218 envelope_active_changed();
1223 AudioRegionView::set_frame_color ()
1229 if (_region->opaque()) {
1235 TimeAxisViewItem::set_frame_color ();
1241 if (_region->muted()) {
1242 wc = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_SelectedWaveForm.get(), MUTED_ALPHA);
1244 wc = ARDOUR_UI::config()->canvasvar_SelectedWaveForm.get();
1246 fc = ARDOUR_UI::config()->canvasvar_SelectedWaveFormFill.get();
1249 if (_region->muted()) {
1250 wc = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_RecWaveForm.get(), MUTED_ALPHA);
1252 wc = ARDOUR_UI::config()->canvasvar_RecWaveForm.get();
1254 fc = ARDOUR_UI::config()->canvasvar_RecWaveFormFill.get();
1256 if (_region->muted()) {
1257 wc = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_WaveForm.get(), MUTED_ALPHA);
1259 wc = ARDOUR_UI::config()->canvasvar_WaveForm.get();
1261 fc = ARDOUR_UI::config()->canvasvar_WaveFormFill.get();
1265 for (vector<ArdourCanvas::WaveView*>::iterator w = waves.begin(); w != waves.end(); ++w) {
1266 if (_region->muted()) {
1267 (*w)->property_wave_color() = wc;
1269 (*w)->property_wave_color() = wc;
1270 (*w)->property_fill_color() = fc;
1276 AudioRegionView::set_fade_visibility (bool yn)
1279 if (fade_in_shape) {
1280 fade_in_shape->show();
1282 if (fade_out_shape) {
1283 fade_out_shape->show ();
1285 if (fade_in_handle) {
1286 fade_in_handle->show ();
1288 if (fade_out_handle) {
1289 fade_out_handle->show ();
1292 if (fade_in_shape) {
1293 fade_in_shape->hide();
1295 if (fade_out_shape) {
1296 fade_out_shape->hide ();
1298 if (fade_in_handle) {
1299 fade_in_handle->hide ();
1301 if (fade_out_handle) {
1302 fade_out_handle->hide ();
1308 AudioRegionView::update_coverage_frames (LayerDisplay d)
1310 RegionView::update_coverage_frames (d);
1312 if (fade_in_handle) {
1313 fade_in_handle->raise_to_top ();
1314 fade_out_handle->raise_to_top ();
1319 AudioRegionView::show_region_editor ()
1322 editor = new AudioRegionEditor (trackview.session(), audio_region());
1326 editor->set_position (Gtk::WIN_POS_MOUSE);
1332 AudioRegionView::show_fade_line (framepos_t pos)
1334 fade_position_line->property_x1() = trackview.editor().frame_to_pixel (pos);
1335 fade_position_line->property_x2() = trackview.editor().frame_to_pixel (pos);
1336 fade_position_line->show ();
1337 fade_position_line->raise_to_top ();
1341 AudioRegionView::hide_fade_line ()
1343 fade_position_line->hide ();
1348 AudioRegionView::transients_changed ()
1350 AnalysisFeatureList analysis_features = _region->transients();
1352 while (feature_lines.size() < analysis_features.size()) {
1354 ArdourCanvas::Line* canvas_item = new ArdourCanvas::Line(*group);
1356 ArdourCanvas::Points points;
1358 points.push_back(Gnome::Art::Point(-1.0, 2.0)); // first x-coord needs to be a non-normal value
1359 points.push_back(Gnome::Art::Point(1.0, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1));
1361 canvas_item->property_points() = points;
1362 canvas_item->property_width_pixels() = 1;
1363 canvas_item->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ZeroLine.get();
1364 canvas_item->property_first_arrowhead() = TRUE;
1365 canvas_item->property_last_arrowhead() = TRUE;
1366 canvas_item->property_arrow_shape_a() = 11.0;
1367 canvas_item->property_arrow_shape_b() = 0.0;
1368 canvas_item->property_arrow_shape_c() = 4.0;
1370 canvas_item->raise_to_top ();
1371 canvas_item->show ();
1373 canvas_item->set_data ("regionview", this);
1374 canvas_item->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_feature_line_event), canvas_item, this));
1376 feature_lines.push_back (make_pair(0, canvas_item));
1379 while (feature_lines.size() > analysis_features.size()) {
1380 ArdourCanvas::Line* line = feature_lines.back().second;
1381 feature_lines.pop_back ();
1385 AnalysisFeatureList::const_iterator i;
1386 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
1388 for (i = analysis_features.begin(), l = feature_lines.begin(); i != analysis_features.end() && l != feature_lines.end(); ++i, ++l) {
1390 ArdourCanvas::Points points;
1392 float *pos = new float;
1393 *pos = trackview.editor().frame_to_pixel (*i);
1395 points.push_back(Gnome::Art::Point(*pos, 2.0)); // first x-coord needs to be a non-normal value
1396 points.push_back(Gnome::Art::Point(*pos, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1));
1398 (*l).second->property_points() = points;
1399 (*l).second->set_data ("position", pos);
1406 AudioRegionView::update_transient(float /*old_pos*/, float new_pos)
1408 /* Find frame at old pos, calulate new frame then update region transients*/
1409 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
1411 for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
1413 /* Line has been updated in drag so we compare to new_pos */
1415 float* pos = (float*) (*l).second->get_data ("position");
1417 if (rint(new_pos) == rint(*pos)) {
1419 framepos_t old_frame = (*l).first;
1420 framepos_t new_frame = trackview.editor().pixel_to_frame (new_pos);
1422 _region->update_transient (old_frame, new_frame);
1430 AudioRegionView::remove_transient(float pos)
1432 /* Find frame at old pos, calulate new frame then update region transients*/
1433 list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
1435 for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
1437 /* Line has been updated in drag so we compare to new_pos */
1438 float *line_pos = (float*) (*l).second->get_data ("position");
1440 if (rint(pos) == rint(*line_pos)) {
1441 _region->remove_transient ((*l).first);
1448 AudioRegionView::thaw_after_trim ()
1450 RegionView::thaw_after_trim ();
1456 AudioRegionView::redraw_start_xfade ()
1458 boost::shared_ptr<AudioRegion> ar (audio_region());
1460 if (!ar->fade_in() || ar->fade_in()->empty()) {
1464 if (!ar->fade_in_is_xfade()) {
1465 if (start_xfade_in) {
1466 start_xfade_in->hide ();
1467 start_xfade_out->hide ();
1468 start_xfade_rect->hide ();
1469 _start_xfade_visible = false;
1474 redraw_start_xfade_to (ar, ar->fade_in()->back()->when);
1478 AudioRegionView::redraw_start_xfade_to (boost::shared_ptr<AudioRegion> ar, framecnt_t len)
1480 int32_t const npoints = trackview.editor().frame_to_pixel (len);
1486 if (!start_xfade_in) {
1487 start_xfade_in = new ArdourCanvas::Line (*group);
1488 start_xfade_in->property_width_pixels() = 1;
1489 start_xfade_in->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GainLine.get();
1492 if (!start_xfade_out) {
1493 start_xfade_out = new ArdourCanvas::Line (*group);
1494 start_xfade_out->property_width_pixels() = 1;
1495 uint32_t col = UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->canvasvar_GainLine.get(), 125);
1496 start_xfade_out->property_fill_color_rgba() = col;
1499 if (!start_xfade_rect) {
1500 start_xfade_rect = new ArdourCanvas::SimpleRect (*group);
1501 start_xfade_rect->property_draw() = true;
1502 start_xfade_rect->property_fill() = true;;
1503 start_xfade_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ActiveCrossfade.get();
1504 start_xfade_rect->property_outline_pixels() = 0;
1505 start_xfade_rect->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_start_xfade_event), start_xfade_rect, this));
1506 start_xfade_rect->set_data ("regionview", this);
1509 Points* points = get_canvas_points ("xfade edit redraw", npoints);
1510 boost::scoped_ptr<float> vec (new float[npoints]);
1511 double effective_height = _height - NAME_HIGHLIGHT_SIZE - 1.0;
1513 ar->fade_in()->curve().get_vector (0, ar->fade_in()->back()->when, vec.get(), npoints);
1515 for (int i = 0, pci = 0; i < npoints; ++i) {
1516 Gnome::Art::Point &p ((*points)[pci++]);
1518 p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
1521 start_xfade_rect->property_x1() = ((*points)[0]).get_x();
1522 start_xfade_rect->property_y1() = 1.0;
1523 start_xfade_rect->property_x2() = ((*points)[npoints-1]).get_x();
1524 start_xfade_rect->property_y2() = effective_height;
1525 start_xfade_rect->show ();
1526 start_xfade_rect->raise_to_top ();
1528 start_xfade_in->property_points() = *points;
1529 start_xfade_in->show ();
1530 start_xfade_in->raise_to_top ();
1534 boost::shared_ptr<AutomationList> inverse = ar->inverse_fade_in();
1538 for (int i = 0, pci = 0; i < npoints; ++i) {
1539 Gnome::Art::Point &p ((*points)[pci++]);
1541 p.set_y (1.0 + effective_height - (effective_height * (1.0 - vec.get()[i])));
1546 inverse->curve().get_vector (0, inverse->back()->when, vec.get(), npoints);
1548 for (int i = 0, pci = 0; i < npoints; ++i) {
1549 Gnome::Art::Point &p ((*points)[pci++]);
1551 p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
1555 start_xfade_out->property_points() = *points;
1556 start_xfade_out->show ();
1557 start_xfade_out->raise_to_top ();
1559 _start_xfade_visible = true;
1565 AudioRegionView::redraw_end_xfade ()
1567 boost::shared_ptr<AudioRegion> ar (audio_region());
1569 if (!ar->fade_out() || ar->fade_out()->empty()) {
1573 if (!ar->fade_out_is_xfade()) {
1575 end_xfade_in->hide ();
1576 end_xfade_out->hide ();
1577 end_xfade_rect->hide ();
1578 _end_xfade_visible = false;
1583 redraw_end_xfade_to (ar, ar->fade_out()->back()->when);
1587 AudioRegionView::redraw_end_xfade_to (boost::shared_ptr<AudioRegion> ar, framecnt_t len)
1589 int32_t const npoints = trackview.editor().frame_to_pixel (len);
1595 if (!end_xfade_in) {
1596 end_xfade_in = new ArdourCanvas::Line (*group);
1597 end_xfade_in->property_width_pixels() = 1;
1598 end_xfade_in->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GainLine.get();
1601 if (!end_xfade_out) {
1602 end_xfade_out = new ArdourCanvas::Line (*group);
1603 end_xfade_out->property_width_pixels() = 1;
1604 uint32_t col UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->canvasvar_GainLine.get(), 125);
1605 end_xfade_out->property_fill_color_rgba() = col;
1608 if (!end_xfade_rect) {
1609 end_xfade_rect = new ArdourCanvas::SimpleRect (*group);
1610 end_xfade_rect->property_draw() = true;
1611 end_xfade_rect->property_fill() = true;;
1612 end_xfade_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ActiveCrossfade.get();
1613 end_xfade_rect->property_outline_pixels() = 0;
1614 end_xfade_rect->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_end_xfade_event), end_xfade_rect, this));
1615 end_xfade_rect->set_data ("regionview", this);
1618 Points* points = get_canvas_points ("xfade edit redraw", npoints);
1619 boost::scoped_ptr<float> vec (new float[npoints]);
1621 ar->fade_out()->curve().get_vector (0, ar->fade_out()->back()->when, vec.get(), npoints);
1623 double rend = trackview.editor().frame_to_pixel (_region->length() - len);
1624 double effective_height = _height - NAME_HIGHLIGHT_SIZE - 1;
1626 for (int i = 0, pci = 0; i < npoints; ++i) {
1627 Gnome::Art::Point &p ((*points)[pci++]);
1629 p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
1632 end_xfade_rect->property_x1() = ((*points)[0]).get_x();
1633 end_xfade_rect->property_y1() = 1;
1634 end_xfade_rect->property_x2() = ((*points)[npoints-1]).get_x();
1635 end_xfade_rect->property_y2() = effective_height;
1636 end_xfade_rect->show ();
1637 end_xfade_rect->raise_to_top ();
1639 end_xfade_in->property_points() = *points;
1640 end_xfade_in->show ();
1641 end_xfade_in->raise_to_top ();
1645 boost::shared_ptr<AutomationList> inverse = ar->inverse_fade_out ();
1649 for (int i = 0, pci = 0; i < npoints; ++i) {
1650 Gnome::Art::Point &p ((*points)[pci++]);
1652 p.set_y (1.0 + effective_height - (effective_height * (1.0 - vec.get()[i])));
1657 inverse->curve().get_vector (inverse->front()->when, inverse->back()->when, vec.get(), npoints);
1659 for (int i = 0, pci = 0; i < npoints; ++i) {
1660 Gnome::Art::Point &p ((*points)[pci++]);
1662 p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
1666 end_xfade_out->property_points() = *points;
1667 end_xfade_out->show ();
1668 end_xfade_out->raise_to_top ();
1670 _end_xfade_visible = true;
1676 AudioRegionView::hide_xfades ()
1678 hide_start_xfade ();
1683 AudioRegionView::hide_start_xfade ()
1685 if (start_xfade_in) {
1686 start_xfade_in->hide();
1688 if (start_xfade_out) {
1689 start_xfade_out->hide();
1691 if (start_xfade_rect) {
1692 start_xfade_rect->hide ();
1695 _start_xfade_visible = false;
1699 AudioRegionView::hide_end_xfade ()
1702 end_xfade_in->hide();
1704 if (end_xfade_out) {
1705 end_xfade_out->hide();
1707 if (end_xfade_rect) {
1708 end_xfade_rect->hide ();
1711 _end_xfade_visible = false;
1715 AudioRegionView::show_start_xfade ()
1717 if (start_xfade_in) {
1718 start_xfade_in->show();
1720 if (start_xfade_out) {
1721 start_xfade_out->show();
1723 if (start_xfade_rect) {
1724 start_xfade_rect->show ();
1727 _start_xfade_visible = true;
1731 AudioRegionView::show_end_xfade ()
1734 end_xfade_in->show();
1736 if (end_xfade_out) {
1737 end_xfade_out->show();
1739 if (end_xfade_rect) {
1740 end_xfade_rect->show ();
1743 _end_xfade_visible = true;
1747 AudioRegionView::show_xfades ()
1749 show_start_xfade ();
1754 AudioRegionView::drag_start ()
1756 TimeAxisViewItem::drag_start ();
1757 AudioTimeAxisView* atav = dynamic_cast<AudioTimeAxisView*> (&trackview);
1760 AudioStreamView* av = atav->audio_view();
1762 /* this will hide our xfades too */
1763 _hidden_xfades = av->hide_xfades_with (audio_region());
1769 AudioRegionView::drag_end ()
1771 TimeAxisViewItem::drag_end ();
1773 for (list<AudioRegionView*>::iterator i = _hidden_xfades.first.begin(); i != _hidden_xfades.first.end(); ++i) {
1774 (*i)->show_start_xfade ();
1777 for (list<AudioRegionView*>::iterator i = _hidden_xfades.second.begin(); i != _hidden_xfades.second.end(); ++i) {
1778 (*i)->show_end_xfade ();
1781 _hidden_xfades.first.clear ();
1782 _hidden_xfades.second.clear ();
1786 AudioRegionView::parameter_changed (string const & p)
1788 if (p == "show-waveforms") {
1789 setup_waveform_visibility ();
1790 } else if (p == "waveform-scale") {
1791 setup_waveform_scale ();
1792 } else if (p == "waveform-shape") {
1793 setup_waveform_shape ();