2 Copyright (C) 2001-2006 Paul Davis
4 This program is free software; you can redistribute 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.
25 #include <gtkmm2ext/gtk_ui.h>
27 #include <ardour/playlist.h>
28 #include <ardour/audioregion.h>
29 #include <ardour/audiosource.h>
30 #include <ardour/audio_diskstream.h>
31 #include <pbd/memento_command.h>
33 #include "streamview.h"
34 #include "audio_region_view.h"
35 #include "audio_time_axis.h"
36 #include "simplerect.h"
37 #include "simpleline.h"
39 #include "public_editor.h"
40 #include "audio_region_editor.h"
41 #include "region_gain_line.h"
42 #include "ghostregion.h"
43 #include "audio_time_axis.h"
45 #include "rgb_macros.h"
46 #include "gui_thread.h"
51 using namespace ARDOUR;
53 using namespace Editing;
54 using namespace ArdourCanvas;
56 static const int32_t sync_mark_width = 9;
58 AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, AudioRegion& r, double spu,
59 Gdk::Color& basic_color)
60 : RegionView (parent, tv, r, spu, basic_color)
68 , _amplitude_above_axis(1.0)
74 AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, AudioRegion& r, double spu,
75 Gdk::Color& basic_color, TimeAxisViewItem::Visibility visibility)
76 : RegionView (parent, tv, r, spu, basic_color, visibility)
84 , _amplitude_above_axis(1.0)
91 AudioRegionView::init (Gdk::Color& basic_color, bool wfd)
93 // FIXME: Some redundancy here with RegionView::init. Need to figure out
94 // where order is important and where it isn't...
96 RegionView::init(basic_color, wfd);
100 _amplitude_above_axis = 1.0;
104 if ((node = _region.extra_xml ("GUI")) != 0) {
107 _flags = WaveformVisible;
111 if (trackview.editor.new_regionviews_display_gain()) {
112 _flags |= EnvelopeVisible;
115 compute_colors (basic_color);
119 fade_in_shape = new ArdourCanvas::Polygon (*group);
120 fade_in_shape->property_fill_color_rgba() = fade_color;
121 fade_in_shape->set_data ("regionview", this);
123 fade_out_shape = new ArdourCanvas::Polygon (*group);
124 fade_out_shape->property_fill_color_rgba() = fade_color;
125 fade_out_shape->set_data ("regionview", this);
130 UINT_TO_RGBA(fill_color,&r,&g,&b,&a);
133 fade_in_handle = new ArdourCanvas::SimpleRect (*group);
134 fade_in_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,0);
135 fade_in_handle->property_outline_pixels() = 0;
136 fade_in_handle->property_y1() = 2.0;
137 fade_in_handle->property_y2() = 7.0;
139 fade_in_handle->set_data ("regionview", this);
141 fade_out_handle = new ArdourCanvas::SimpleRect (*group);
142 fade_out_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,0);
143 fade_out_handle->property_outline_pixels() = 0;
144 fade_out_handle->property_y1() = 2.0;
145 fade_out_handle->property_y2() = 7.0;
147 fade_out_handle->set_data ("regionview", this);
150 string foo = _region.name();
154 gain_line = new AudioRegionGainLine (foo, trackview.session(), *this, *group, audio_region().envelope());
156 if (!(_flags & EnvelopeVisible)) {
162 reset_width_dependent_items ((double) _region.length() / samples_per_unit);
166 set_height (trackview.height);
169 region_sync_changed ();
170 region_resized (BoundsChanged);
171 set_waveview_data_src();
173 envelope_active_changed ();
174 fade_in_active_changed ();
175 fade_out_active_changed ();
177 _region.StateChanged.connect (mem_fun(*this, &AudioRegionView::region_changed));
179 fade_in_shape->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_event), fade_in_shape, this));
180 fade_in_handle->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_handle_event), fade_in_handle, this));
181 fade_out_shape->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_event), fade_out_shape, this));
182 fade_out_handle->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_handle_event), fade_out_handle, this));
186 /* XXX sync mark drag? */
189 AudioRegionView::~AudioRegionView ()
191 in_destructor = true;
193 RegionViewGoingAway (this); /* EMIT_SIGNAL */
195 for (vector<GnomeCanvasWaveViewCache *>::iterator cache = wave_caches.begin(); cache != wave_caches.end() ; ++cache) {
196 gnome_canvas_waveview_cache_destroy (*cache);
199 /* all waveviews etc will be destroyed when the group is destroyed */
207 AudioRegionView::audio_region() const
209 // "Guaranteed" to succeed...
210 return dynamic_cast<AudioRegion&>(_region);
214 AudioRegionView::region_changed (Change what_changed)
216 ENSURE_GUI_THREAD (bind (mem_fun(*this, &AudioRegionView::region_changed), what_changed));
218 RegionView::region_changed(what_changed);
220 if (what_changed & AudioRegion::ScaleAmplitudeChanged) {
221 region_scale_amplitude_changed ();
223 if (what_changed & AudioRegion::FadeInChanged) {
226 if (what_changed & AudioRegion::FadeOutChanged) {
229 if (what_changed & AudioRegion::FadeInActiveChanged) {
230 fade_in_active_changed ();
232 if (what_changed & AudioRegion::FadeOutActiveChanged) {
233 fade_out_active_changed ();
235 if (what_changed & AudioRegion::EnvelopeActiveChanged) {
236 envelope_active_changed ();
241 AudioRegionView::fade_in_changed ()
243 reset_fade_in_shape ();
247 AudioRegionView::fade_out_changed ()
249 reset_fade_out_shape ();
253 AudioRegionView::set_fade_in_active (bool yn)
255 audio_region().set_fade_in_active (yn);
259 AudioRegionView::set_fade_out_active (bool yn)
261 audio_region().set_fade_out_active (yn);
265 AudioRegionView::fade_in_active_changed ()
269 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
271 if (audio_region().fade_in_active()) {
272 col = RGBA_TO_UINT(r,g,b,120);
273 fade_in_shape->property_fill_color_rgba() = col;
274 fade_in_shape->property_width_pixels() = 0;
275 fade_in_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,0);
277 col = RGBA_TO_UINT(r,g,b,0);
278 fade_in_shape->property_fill_color_rgba() = col;
279 fade_in_shape->property_width_pixels() = 1;
280 fade_in_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,255);
285 AudioRegionView::fade_out_active_changed ()
289 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
291 if (audio_region().fade_out_active()) {
292 col = RGBA_TO_UINT(r,g,b,120);
293 fade_out_shape->property_fill_color_rgba() = col;
294 fade_out_shape->property_width_pixels() = 0;
295 fade_out_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,0);
297 col = RGBA_TO_UINT(r,g,b,0);
298 fade_out_shape->property_fill_color_rgba() = col;
299 fade_out_shape->property_width_pixels() = 1;
300 fade_out_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,255);
306 AudioRegionView::region_scale_amplitude_changed ()
308 ENSURE_GUI_THREAD (mem_fun(*this, &AudioRegionView::region_scale_amplitude_changed));
310 for (uint32_t n = 0; n < waves.size(); ++n) {
311 // force a reload of the cache
312 waves[n]->property_data_src() = &_region;
317 AudioRegionView::region_resized (Change what_changed)
319 RegionView::region_resized(what_changed);
321 if (what_changed & Change (StartChanged|LengthChanged)) {
323 for (uint32_t n = 0; n < waves.size(); ++n) {
324 waves[n]->property_region_start() = _region.start();
327 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
329 for (vector<WaveView*>::iterator w = (*i)->waves.begin(); w != (*i)->waves.end(); ++w) {
330 (*w)->property_region_start() = _region.start();
337 AudioRegionView::reset_width_dependent_items (double pixel_width)
339 RegionView::reset_width_dependent_items(pixel_width);
340 assert(_pixel_width == pixel_width);
343 zero_line->property_x2() = pixel_width - 1.0;
346 if (fade_in_handle) {
347 if (pixel_width <= 6.0) {
348 fade_in_handle->hide();
349 fade_out_handle->hide();
352 fade_in_handle->hide();
353 fade_out_handle->hide();
355 fade_in_handle->show();
356 fade_out_handle->show();
361 reset_fade_shapes ();
365 AudioRegionView::region_muted ()
367 RegionView::region_muted();
369 for (uint32_t n=0; n < waves.size(); ++n) {
370 if (_region.muted()) {
371 waves[n]->property_wave_color() = color_map[cMutedWaveForm];
373 waves[n]->property_wave_color() = color_map[cWaveForm];
380 AudioRegionView::set_height (gdouble height)
382 uint32_t wcnt = waves.size();
385 TimeAxisViewItem::set_height (height - 2);
389 for (uint32_t n=0; n < wcnt; ++n) {
392 if ((height) <= NAME_HIGHLIGHT_THRESH) {
393 ht = ((height-2*wcnt) / (double) wcnt);
395 ht = (((height-2*wcnt) - NAME_HIGHLIGHT_SIZE) / (double) wcnt);
398 gdouble yoff = n * (ht+1);
400 waves[n]->property_height() = ht;
401 waves[n]->property_y() = yoff + 2;
405 if ((height/wcnt) < NAME_HIGHLIGHT_SIZE) {
408 if (_flags & EnvelopeVisible) {
412 gain_line->set_height ((uint32_t) rint (height - NAME_HIGHLIGHT_SIZE));
416 reset_fade_shapes ();
419 name_text->raise_to_top();
424 AudioRegionView::manage_zero_line ()
430 if (_height >= 100) {
431 gdouble wave_midpoint = (_height - NAME_HIGHLIGHT_SIZE) / 2.0;
432 zero_line->property_y1() = wave_midpoint;
433 zero_line->property_y2() = wave_midpoint;
441 AudioRegionView::reset_fade_shapes ()
443 reset_fade_in_shape ();
444 reset_fade_out_shape ();
448 AudioRegionView::reset_fade_in_shape ()
450 reset_fade_in_shape_width ((jack_nframes_t) audio_region().fade_in().back()->when);
454 AudioRegionView::reset_fade_in_shape_width (jack_nframes_t width)
456 if (fade_in_handle == 0) {
460 /* smallest size for a fade is 64 frames */
462 width = std::max ((jack_nframes_t) 64, width);
465 double pwidth = width / samples_per_unit;
466 uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth);
470 fade_in_shape->hide();
471 fade_in_handle->hide();
475 double handle_center;
476 handle_center = pwidth;
478 if (handle_center > 7.0) {
479 handle_center -= 3.0;
484 fade_in_handle->property_x1() = handle_center - 3.0;
485 fade_in_handle->property_x2() = handle_center + 3.0;
488 fade_in_shape->hide();
492 fade_in_shape->show();
494 float curve[npoints];
495 audio_region().fade_in().get_vector (0, audio_region().fade_in().back()->when, curve, npoints);
497 points = get_canvas_points ("fade in shape", npoints+3);
499 if (_height > NAME_HIGHLIGHT_THRESH) {
500 h = _height - NAME_HIGHLIGHT_SIZE;
505 /* points *MUST* be in anti-clockwise order */
508 double xdelta = pwidth/npoints;
510 for (pi = 0, pc = 0; pc < npoints; ++pc) {
511 (*points)[pi].set_x(1 + (pc * xdelta));
512 (*points)[pi++].set_y(2 + (h - (curve[pc] * h)));
517 (*points)[pi].set_x(pwidth);
518 (*points)[pi++].set_y(2);
520 (*points)[pi].set_x(1);
521 (*points)[pi++].set_y(2);
523 /* connect the dots ... */
525 (*points)[pi] = (*points)[0];
527 fade_in_shape->property_points() = *points;
532 AudioRegionView::reset_fade_out_shape ()
534 reset_fade_out_shape_width ((jack_nframes_t) audio_region().fade_out().back()->when);
538 AudioRegionView::reset_fade_out_shape_width (jack_nframes_t width)
540 if (fade_out_handle == 0) {
544 /* smallest size for a fade is 64 frames */
546 width = std::max ((jack_nframes_t) 64, width);
549 double pwidth = width / samples_per_unit;
550 uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth);
554 fade_out_shape->hide();
555 fade_out_handle->hide();
559 double handle_center;
560 handle_center = (_region.length() - width) / samples_per_unit;
562 if (handle_center > 7.0) {
563 handle_center -= 3.0;
568 fade_out_handle->property_x1() = handle_center - 3.0;
569 fade_out_handle->property_x2() = handle_center + 3.0;
571 /* don't show shape if its too small */
574 fade_out_shape->hide();
578 fade_out_shape->show();
580 float curve[npoints];
581 audio_region().fade_out().get_vector (0, audio_region().fade_out().back()->when, curve, npoints);
583 if (_height > NAME_HIGHLIGHT_THRESH) {
584 h = _height - NAME_HIGHLIGHT_SIZE;
589 /* points *MUST* be in anti-clockwise order */
591 points = get_canvas_points ("fade out shape", npoints+3);
594 double xdelta = pwidth/npoints;
596 for (pi = 0, pc = 0; pc < npoints; ++pc) {
597 (*points)[pi].set_x(_pixel_width - 1 - pwidth + (pc*xdelta));
598 (*points)[pi++].set_y(2 + (h - (curve[pc] * h)));
603 (*points)[pi].set_x(_pixel_width);
604 (*points)[pi++].set_y(h);
606 (*points)[pi].set_x(_pixel_width);
607 (*points)[pi++].set_y(2);
609 /* connect the dots ... */
611 (*points)[pi] = (*points)[0];
613 fade_out_shape->property_points() = *points;
618 AudioRegionView::set_samples_per_unit (gdouble spu)
620 RegionView::set_samples_per_unit (spu);
622 for (uint32_t n=0; n < waves.size(); ++n) {
623 waves[n]->property_samples_per_unit() = spu;
629 reset_fade_shapes ();
633 AudioRegionView::set_amplitude_above_axis (gdouble spp)
635 for (uint32_t n=0; n < waves.size(); ++n) {
636 waves[n]->property_amplitude_above_axis() = spp;
641 AudioRegionView::compute_colors (Gdk::Color& basic_color)
643 RegionView::compute_colors(basic_color);
647 /* gain color computed in envelope_active_changed() */
649 UINT_TO_RGBA (fill_color, &r, &g, &b, &a);
650 fade_color = RGBA_TO_UINT(r,g,b,120);
654 AudioRegionView::set_colors ()
656 RegionView::set_colors();
659 gain_line->set_line_color (audio_region().envelope_active() ? color_map[cGainLine] : color_map[cGainLineInactive]);
662 for (uint32_t n=0; n < waves.size(); ++n) {
663 if (_region.muted()) {
664 waves[n]->property_wave_color() = color_map[cMutedWaveForm];
666 waves[n]->property_wave_color() = color_map[cWaveForm];
672 AudioRegionView::show_region_editor ()
675 editor = new AudioRegionEditor (trackview.session(), audio_region(), *this);
676 // GTK2FIX : how to ensure float without realizing
677 // editor->realize ();
678 // trackview.editor.ensure_float (*editor);
682 editor->get_window()->raise();
686 AudioRegionView::set_waveform_visible (bool yn)
688 if (((_flags & WaveformVisible) != yn)) {
690 for (uint32_t n=0; n < waves.size(); ++n) {
693 _flags |= WaveformVisible;
695 for (uint32_t n=0; n < waves.size(); ++n) {
698 _flags &= ~WaveformVisible;
705 AudioRegionView::temporarily_hide_envelope ()
713 AudioRegionView::unhide_envelope ()
715 if (gain_line && (_flags & EnvelopeVisible)) {
721 AudioRegionView::set_envelope_visible (bool yn)
723 if (gain_line && ((_flags & EnvelopeVisible) != yn)) {
726 _flags |= EnvelopeVisible;
729 _flags &= ~EnvelopeVisible;
736 AudioRegionView::create_waves ()
738 bool create_zero_line = true;
740 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
742 if (!atv.get_diskstream()) {
746 uint32_t nchans = atv.get_diskstream()->n_channels();
748 /* in tmp_waves, set up null pointers for each channel so the vector is allocated */
749 for (uint32_t n = 0; n < nchans; ++n) {
750 tmp_waves.push_back (0);
753 for (uint32_t n = 0; n < nchans; ++n) {
755 if (n >= audio_region().n_channels()) {
759 wave_caches.push_back (WaveView::create_cache ());
762 if (audio_region().source(n).peaks_ready (bind (mem_fun(*this, &AudioRegionView::peaks_ready_handler), n), data_ready_connection)) {
763 create_one_wave (n, true);
765 create_zero_line = false;
768 create_one_wave (n, true);
772 if (create_zero_line) {
773 zero_line = new ArdourCanvas::SimpleLine (*group);
774 zero_line->property_x1() = (gdouble) 1.0;
775 zero_line->property_x2() = (gdouble) (_region.length() / samples_per_unit) - 1.0;
776 zero_line->property_color_rgba() = (guint) color_map[cZeroLine];
782 AudioRegionView::create_one_wave (uint32_t which, bool direct)
784 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
785 uint32_t nchans = atv.get_diskstream()->n_channels();
787 uint32_t nwaves = std::min (nchans, audio_region().n_channels());
790 if (trackview.height < NAME_HIGHLIGHT_SIZE) {
791 ht = ((trackview.height) / (double) nchans);
793 ht = ((trackview.height - NAME_HIGHLIGHT_SIZE) / (double) nchans);
796 gdouble yoff = which * ht;
798 WaveView *wave = new WaveView(*group);
800 wave->property_data_src() = (gpointer) &_region;
801 wave->property_cache() = wave_caches[which];
802 wave->property_cache_updater() = true;
803 wave->property_channel() = which;
804 wave->property_length_function() = (gpointer) region_length_from_c;
805 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
806 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
807 wave->property_x() = 0.0;
808 wave->property_y() = yoff;
809 wave->property_height() = (double) ht;
810 wave->property_samples_per_unit() = samples_per_unit;
811 wave->property_amplitude_above_axis() = _amplitude_above_axis;
812 wave->property_wave_color() = _region.muted() ? color_map[cMutedWaveForm] : color_map[cWaveForm];
813 wave->property_region_start() = _region.start();
815 if (!(_flags & WaveformVisible)) {
819 /* note: calling this function is serialized by the lock
820 held in the peak building thread that signals that
821 peaks are ready for use *or* by the fact that it is
822 called one by one from the GUI thread.
825 if (which < nchans) {
826 tmp_waves[which] = wave;
828 /* n-channel track, >n-channel source */
831 /* see if we're all ready */
833 for (n = 0; n < nchans; ++n) {
834 if (tmp_waves[n] == 0) {
839 if (n == nwaves && waves.empty()) {
840 /* all waves are ready */
841 tmp_waves.resize(nwaves);
847 zero_line = new ArdourCanvas::SimpleLine (*group);
848 zero_line->property_x1() = (gdouble) 1.0;
849 zero_line->property_x2() = (gdouble) (_region.length() / samples_per_unit) - 1.0;
850 zero_line->property_color_rgba() = (guint) color_map[cZeroLine];
857 AudioRegionView::peaks_ready_handler (uint32_t which)
859 Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun(*this, &AudioRegionView::create_one_wave), which, false));
861 if (!waves.empty()) {
862 /* all waves created, don't hook into peaks ready anymore */
863 data_ready_connection.disconnect ();
868 AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
870 if (gain_line == 0) {
876 /* don't create points that can't be seen */
878 set_envelope_visible (true);
885 jack_nframes_t fx = trackview.editor.pixel_to_frame (x);
887 if (fx > _region.length()) {
891 /* compute vertical fractional position */
893 y = 1.0 - (y / (trackview.height - NAME_HIGHLIGHT_SIZE));
895 /* map using gain line */
897 gain_line->view_to_model_y (y);
899 trackview.session().begin_reversible_command (_("add gain control point"));
900 XMLNode &before = audio_region().envelope().get_state();
903 if (!audio_region().envelope_active()) {
904 XMLNode &before = audio_region().get_state();
905 audio_region().set_envelope_active(true);
906 XMLNode &after = audio_region().get_state();
907 trackview.session().add_command (new MementoCommand<AudioRegion>(audio_region(), before, after));
910 audio_region().envelope().add (fx, y);
912 XMLNode &after = audio_region().envelope().get_state();
913 trackview.session().add_command (new MementoCommand<Curve>(audio_region().envelope(), before, after));
914 trackview.session().commit_reversible_command ();
918 AudioRegionView::remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
920 ControlPoint *cp = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"));
921 audio_region().envelope().erase (cp->model);
925 AudioRegionView::store_flags()
927 XMLNode *node = new XMLNode ("GUI");
929 node->add_property ("waveform-visible", (_flags & WaveformVisible) ? "yes" : "no");
930 node->add_property ("envelope-visible", (_flags & EnvelopeVisible) ? "yes" : "no");
932 _region.add_extra_xml (*node);
936 AudioRegionView::set_flags (XMLNode* node)
940 if ((prop = node->property ("waveform-visible")) != 0) {
941 if (prop->value() == "yes") {
942 _flags |= WaveformVisible;
946 if ((prop = node->property ("envelope-visible")) != 0) {
947 if (prop->value() == "yes") {
948 _flags |= EnvelopeVisible;
954 AudioRegionView::set_waveform_shape (WaveformShape shape)
958 /* this slightly odd approach is to leave the door open to
959 other "shapes" such as spectral displays, etc.
972 if (yn != (bool) (_flags & WaveformRectified)) {
973 for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
974 (*wave)->property_rectified() = yn;
986 _flags |= WaveformRectified;
988 _flags &= ~WaveformRectified;
994 AudioRegionView::add_ghost (AutomationTimeAxisView& atv)
996 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&trackview);
999 double unit_position = _region.position () / samples_per_unit;
1000 GhostRegion* ghost = new GhostRegion (atv, unit_position);
1003 nchans = rtv->get_diskstream()->n_channels();
1005 for (uint32_t n = 0; n < nchans; ++n) {
1007 if (n >= audio_region().n_channels()) {
1011 WaveView *wave = new WaveView(*ghost->group);
1013 wave->property_data_src() = &_region;
1014 wave->property_cache() = wave_caches[n];
1015 wave->property_cache_updater() = false;
1016 wave->property_channel() = n;
1017 wave->property_length_function() = (gpointer)region_length_from_c;
1018 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
1019 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
1020 wave->property_x() = 0.0;
1021 wave->property_samples_per_unit() = samples_per_unit;
1022 wave->property_amplitude_above_axis() = _amplitude_above_axis;
1023 wave->property_wave_color() = color_map[cGhostTrackWave];
1024 wave->property_region_start() = _region.start();
1026 ghost->waves.push_back(wave);
1029 ghost->set_height ();
1030 ghost->set_duration (_region.length() / samples_per_unit);
1031 ghosts.push_back (ghost);
1033 ghost->GoingAway.connect (mem_fun(*this, &AudioRegionView::remove_ghost));
1039 AudioRegionView::entered ()
1041 if (gain_line && _flags & EnvelopeVisible) {
1042 gain_line->show_all_control_points ();
1046 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
1049 if (fade_in_handle) {
1050 fade_in_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1051 fade_out_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1056 AudioRegionView::exited ()
1059 gain_line->hide_all_but_selected_control_points ();
1063 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
1066 if (fade_in_handle) {
1067 fade_in_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1068 fade_out_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1073 AudioRegionView::envelope_active_changed ()
1076 gain_line->set_line_color (audio_region().envelope_active() ? color_map[cGainLine] : color_map[cGainLineInactive]);
1081 AudioRegionView::set_waveview_data_src()
1084 double unit_length= _region.length() / samples_per_unit;
1086 for (uint32_t n = 0; n < waves.size(); ++n) {
1087 // TODO: something else to let it know the channel
1088 waves[n]->property_data_src() = &_region;
1091 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
1093 (*i)->set_duration (unit_length);
1095 for (vector<WaveView*>::iterator w = (*i)->waves.begin(); w != (*i)->waves.end(); ++w) {
1096 (*w)->property_data_src() = &_region;
1103 AudioRegionView::color_handler (ColorID id, uint32_t val)
1106 case cMutedWaveForm:
1111 case cGainLineInactive:
1113 envelope_active_changed();
1118 zero_line->property_color_rgba() = (guint) color_map[cZeroLine];
1122 case cGhostTrackWave: