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.
27 #include <gtkmm2ext/gtk_ui.h>
29 #include <ardour/playlist.h>
30 #include <ardour/audioregion.h>
31 #include <ardour/audiosource.h>
32 #include <ardour/audio_diskstream.h>
33 #include <pbd/memento_command.h>
34 #include <pbd/stacktrace.h>
36 #include "streamview.h"
37 #include "audio_region_view.h"
38 #include "audio_time_axis.h"
39 #include "simplerect.h"
40 #include "simpleline.h"
42 #include "public_editor.h"
43 #include "audio_region_editor.h"
44 #include "region_gain_line.h"
45 #include "ghostregion.h"
46 #include "audio_time_axis.h"
48 #include "rgb_macros.h"
49 #include "gui_thread.h"
54 using namespace ARDOUR;
56 using namespace Editing;
57 using namespace ArdourCanvas;
59 static const int32_t sync_mark_width = 9;
61 AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, boost::shared_ptr<AudioRegion> r, double spu,
62 Gdk::Color& basic_color)
63 : RegionView (parent, tv, r, spu, basic_color)
71 , _amplitude_above_axis(1.0)
77 AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, boost::shared_ptr<AudioRegion> r, double spu,
78 Gdk::Color& basic_color, TimeAxisViewItem::Visibility visibility)
79 : RegionView (parent, tv, r, spu, basic_color, visibility)
87 , _amplitude_above_axis(1.0)
94 AudioRegionView::init (Gdk::Color& basic_color, bool wfd)
96 // FIXME: Some redundancy here with RegionView::init. Need to figure out
97 // where order is important and where it isn't...
99 RegionView::init(basic_color, wfd);
103 _amplitude_above_axis = 1.0;
107 if ((node = _region->extra_xml ("GUI")) != 0) {
110 _flags = WaveformVisible;
114 if (trackview.editor.new_regionviews_display_gain()) {
115 _flags |= EnvelopeVisible;
118 compute_colors (basic_color);
122 fade_in_shape = new ArdourCanvas::Polygon (*group);
123 fade_in_shape->property_fill_color_rgba() = fade_color;
124 fade_in_shape->set_data ("regionview", this);
126 fade_out_shape = new ArdourCanvas::Polygon (*group);
127 fade_out_shape->property_fill_color_rgba() = fade_color;
128 fade_out_shape->set_data ("regionview", this);
133 UINT_TO_RGBA(fill_color,&r,&g,&b,&a);
136 fade_in_handle = new ArdourCanvas::SimpleRect (*group);
137 fade_in_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,0);
138 fade_in_handle->property_outline_pixels() = 0;
139 fade_in_handle->property_y1() = 2.0;
140 fade_in_handle->property_y2() = 7.0;
142 fade_in_handle->set_data ("regionview", this);
144 fade_out_handle = new ArdourCanvas::SimpleRect (*group);
145 fade_out_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,0);
146 fade_out_handle->property_outline_pixels() = 0;
147 fade_out_handle->property_y1() = 2.0;
148 fade_out_handle->property_y2() = 7.0;
150 fade_out_handle->set_data ("regionview", this);
153 string foo = _region->name();
157 gain_line = new AudioRegionGainLine (foo, trackview.session(), *this, *group, audio_region()->envelope());
159 if (!(_flags & EnvelopeVisible)) {
167 set_height (trackview.height);
170 region_sync_changed ();
171 region_resized (BoundsChanged);
172 set_waveview_data_src();
174 envelope_active_changed ();
175 fade_in_active_changed ();
176 fade_out_active_changed ();
178 _region->StateChanged.connect (mem_fun(*this, &AudioRegionView::region_changed));
180 fade_in_shape->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_event), fade_in_shape, this));
181 fade_in_handle->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_handle_event), fade_in_handle, this));
182 fade_out_shape->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_event), fade_out_shape, this));
183 fade_out_handle->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_handle_event), fade_out_handle, this));
187 /* XXX sync mark drag? */
190 AudioRegionView::~AudioRegionView ()
192 in_destructor = true;
194 RegionViewGoingAway (this); /* EMIT_SIGNAL */
196 for (vector<GnomeCanvasWaveViewCache *>::iterator cache = wave_caches.begin(); cache != wave_caches.end() ; ++cache) {
197 gnome_canvas_waveview_cache_destroy (*cache);
200 /* all waveviews etc will be destroyed when the group is destroyed */
207 boost::shared_ptr<ARDOUR::AudioRegion>
208 AudioRegionView::audio_region() const
210 // "Guaranteed" to succeed...
211 return boost::dynamic_pointer_cast<AudioRegion>(_region);
215 AudioRegionView::region_changed (Change what_changed)
217 ENSURE_GUI_THREAD (bind (mem_fun(*this, &AudioRegionView::region_changed), what_changed));
219 RegionView::region_changed(what_changed);
221 if (what_changed & AudioRegion::ScaleAmplitudeChanged) {
222 region_scale_amplitude_changed ();
224 if (what_changed & AudioRegion::FadeInChanged) {
227 if (what_changed & AudioRegion::FadeOutChanged) {
230 if (what_changed & AudioRegion::FadeInActiveChanged) {
231 fade_in_active_changed ();
233 if (what_changed & AudioRegion::FadeOutActiveChanged) {
234 fade_out_active_changed ();
236 if (what_changed & AudioRegion::EnvelopeActiveChanged) {
237 envelope_active_changed ();
242 AudioRegionView::fade_in_changed ()
244 reset_fade_in_shape ();
248 AudioRegionView::fade_out_changed ()
250 reset_fade_out_shape ();
254 AudioRegionView::set_fade_in_active (bool yn)
256 audio_region()->set_fade_in_active (yn);
260 AudioRegionView::set_fade_out_active (bool yn)
262 audio_region()->set_fade_out_active (yn);
266 AudioRegionView::fade_in_active_changed ()
270 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
272 if (audio_region()->fade_in_active()) {
273 col = RGBA_TO_UINT(r,g,b,120);
274 fade_in_shape->property_fill_color_rgba() = col;
275 fade_in_shape->property_width_pixels() = 0;
276 fade_in_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,0);
278 col = RGBA_TO_UINT(r,g,b,0);
279 fade_in_shape->property_fill_color_rgba() = col;
280 fade_in_shape->property_width_pixels() = 1;
281 fade_in_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,255);
286 AudioRegionView::fade_out_active_changed ()
290 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
292 if (audio_region()->fade_out_active()) {
293 col = RGBA_TO_UINT(r,g,b,120);
294 fade_out_shape->property_fill_color_rgba() = col;
295 fade_out_shape->property_width_pixels() = 0;
296 fade_out_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,0);
298 col = RGBA_TO_UINT(r,g,b,0);
299 fade_out_shape->property_fill_color_rgba() = col;
300 fade_out_shape->property_width_pixels() = 1;
301 fade_out_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,255);
307 AudioRegionView::region_scale_amplitude_changed ()
309 ENSURE_GUI_THREAD (mem_fun(*this, &AudioRegionView::region_scale_amplitude_changed));
311 for (uint32_t n = 0; n < waves.size(); ++n) {
312 // force a reload of the cache
313 waves[n]->property_data_src() = _region.get();
318 AudioRegionView::region_resized (Change what_changed)
320 RegionView::region_resized(what_changed);
322 if (what_changed & Change (StartChanged|LengthChanged)) {
324 for (uint32_t n = 0; n < waves.size(); ++n) {
325 waves[n]->property_region_start() = _region->start();
328 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
330 for (vector<WaveView*>::iterator w = (*i)->waves.begin(); w != (*i)->waves.end(); ++w) {
331 (*w)->property_region_start() = _region->start();
338 AudioRegionView::reset_width_dependent_items (double pixel_width)
340 RegionView::reset_width_dependent_items(pixel_width);
341 assert(_pixel_width == pixel_width);
344 zero_line->property_x2() = pixel_width - 1.0;
347 if (fade_in_handle) {
348 if (pixel_width <= 6.0) {
349 fade_in_handle->hide();
350 fade_out_handle->hide();
353 fade_in_handle->hide();
354 fade_out_handle->hide();
356 fade_in_handle->show();
357 fade_out_handle->show();
362 reset_fade_shapes ();
366 AudioRegionView::region_muted ()
368 RegionView::region_muted();
370 for (uint32_t n=0; n < waves.size(); ++n) {
371 if (_region->muted()) {
372 waves[n]->property_wave_color() = color_map[cMutedWaveForm];
374 waves[n]->property_wave_color() = color_map[cWaveForm];
381 AudioRegionView::set_height (gdouble height)
383 uint32_t wcnt = waves.size();
386 TimeAxisViewItem::set_height (height - 2);
390 for (uint32_t n=0; n < wcnt; ++n) {
393 if ((height) <= NAME_HIGHLIGHT_THRESH) {
394 ht = ((height-2*wcnt) / (double) wcnt);
396 ht = (((height-2*wcnt) - NAME_HIGHLIGHT_SIZE) / (double) wcnt);
399 gdouble yoff = n * (ht+1);
401 waves[n]->property_height() = ht;
402 waves[n]->property_y() = yoff + 2;
406 if ((height/wcnt) < NAME_HIGHLIGHT_SIZE) {
409 if (_flags & EnvelopeVisible) {
413 gain_line->set_height ((uint32_t) rint (height - NAME_HIGHLIGHT_SIZE));
417 reset_fade_shapes ();
420 name_text->raise_to_top();
425 AudioRegionView::manage_zero_line ()
431 if (_height >= 100) {
432 gdouble wave_midpoint = (_height - NAME_HIGHLIGHT_SIZE) / 2.0;
433 zero_line->property_y1() = wave_midpoint;
434 zero_line->property_y2() = wave_midpoint;
442 AudioRegionView::reset_fade_shapes ()
444 reset_fade_in_shape ();
445 reset_fade_out_shape ();
449 AudioRegionView::reset_fade_in_shape ()
451 reset_fade_in_shape_width ((nframes_t) audio_region()->fade_in().back()->when);
455 AudioRegionView::reset_fade_in_shape_width (nframes_t width)
457 if (fade_in_handle == 0) {
461 /* smallest size for a fade is 64 frames */
463 width = std::max ((nframes_t) 64, width);
466 double pwidth = width / samples_per_unit;
467 uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth);
471 fade_in_shape->hide();
472 fade_in_handle->hide();
476 double handle_center;
477 handle_center = pwidth;
479 if (handle_center > 7.0) {
480 handle_center -= 3.0;
485 fade_in_handle->property_x1() = handle_center - 3.0;
486 fade_in_handle->property_x2() = handle_center + 3.0;
489 fade_in_shape->hide();
493 fade_in_shape->show();
495 float curve[npoints];
496 audio_region()->fade_in().get_vector (0, audio_region()->fade_in().back()->when, curve, npoints);
498 points = get_canvas_points ("fade in shape", npoints+3);
500 if (_height > NAME_HIGHLIGHT_THRESH) {
501 h = _height - NAME_HIGHLIGHT_SIZE;
506 /* points *MUST* be in anti-clockwise order */
509 double xdelta = pwidth/npoints;
511 for (pi = 0, pc = 0; pc < npoints; ++pc) {
512 (*points)[pi].set_x(1 + (pc * xdelta));
513 (*points)[pi++].set_y(2 + (h - (curve[pc] * h)));
518 (*points)[pi].set_x(pwidth);
519 (*points)[pi++].set_y(2);
521 (*points)[pi].set_x(1);
522 (*points)[pi++].set_y(2);
524 /* connect the dots ... */
526 (*points)[pi] = (*points)[0];
528 fade_in_shape->property_points() = *points;
533 AudioRegionView::reset_fade_out_shape ()
535 reset_fade_out_shape_width ((nframes_t) audio_region()->fade_out().back()->when);
539 AudioRegionView::reset_fade_out_shape_width (nframes_t width)
541 if (fade_out_handle == 0) {
545 /* smallest size for a fade is 64 frames */
547 width = std::max ((nframes_t) 64, width);
550 double pwidth = width / samples_per_unit;
551 uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth);
555 fade_out_shape->hide();
556 fade_out_handle->hide();
560 double handle_center;
561 handle_center = (_region->length() - width) / samples_per_unit;
563 if (handle_center > 7.0) {
564 handle_center -= 3.0;
569 fade_out_handle->property_x1() = handle_center - 3.0;
570 fade_out_handle->property_x2() = handle_center + 3.0;
572 /* don't show shape if its too small */
575 fade_out_shape->hide();
579 fade_out_shape->show();
581 float curve[npoints];
582 audio_region()->fade_out().get_vector (0, audio_region()->fade_out().back()->when, curve, npoints);
584 if (_height > NAME_HIGHLIGHT_THRESH) {
585 h = _height - NAME_HIGHLIGHT_SIZE;
590 /* points *MUST* be in anti-clockwise order */
592 points = get_canvas_points ("fade out shape", npoints+3);
595 double xdelta = pwidth/npoints;
597 for (pi = 0, pc = 0; pc < npoints; ++pc) {
598 (*points)[pi].set_x(_pixel_width - 1 - pwidth + (pc*xdelta));
599 (*points)[pi++].set_y(2 + (h - (curve[pc] * h)));
604 (*points)[pi].set_x(_pixel_width);
605 (*points)[pi++].set_y(h);
607 (*points)[pi].set_x(_pixel_width);
608 (*points)[pi++].set_y(2);
610 /* connect the dots ... */
612 (*points)[pi] = (*points)[0];
614 fade_out_shape->property_points() = *points;
619 AudioRegionView::set_samples_per_unit (gdouble spu)
621 RegionView::set_samples_per_unit (spu);
623 for (uint32_t n=0; n < waves.size(); ++n) {
624 waves[n]->property_samples_per_unit() = spu;
630 reset_fade_shapes ();
634 AudioRegionView::set_amplitude_above_axis (gdouble spp)
636 for (uint32_t n=0; n < waves.size(); ++n) {
637 waves[n]->property_amplitude_above_axis() = spp;
642 AudioRegionView::compute_colors (Gdk::Color& basic_color)
644 RegionView::compute_colors(basic_color);
648 /* gain color computed in envelope_active_changed() */
650 UINT_TO_RGBA (fill_color, &r, &g, &b, &a);
651 fade_color = RGBA_TO_UINT(r,g,b,120);
655 AudioRegionView::set_colors ()
657 RegionView::set_colors();
660 gain_line->set_line_color (audio_region()->envelope_active() ? color_map[cGainLine] : color_map[cGainLineInactive]);
663 for (uint32_t n=0; n < waves.size(); ++n) {
664 if (_region->muted()) {
665 waves[n]->property_wave_color() = color_map[cMutedWaveForm];
667 waves[n]->property_wave_color() = color_map[cWaveForm];
673 AudioRegionView::show_region_editor ()
676 editor = new AudioRegionEditor (trackview.session(), audio_region(), *this);
677 // GTK2FIX : how to ensure float without realizing
678 // editor->realize ();
679 // trackview.editor.ensure_float (*editor);
683 editor->get_window()->raise();
687 AudioRegionView::set_waveform_visible (bool yn)
689 if (((_flags & WaveformVisible) != yn)) {
691 for (uint32_t n=0; n < waves.size(); ++n) {
694 _flags |= WaveformVisible;
696 for (uint32_t n=0; n < waves.size(); ++n) {
699 _flags &= ~WaveformVisible;
706 AudioRegionView::temporarily_hide_envelope ()
714 AudioRegionView::unhide_envelope ()
716 if (gain_line && (_flags & EnvelopeVisible)) {
722 AudioRegionView::set_envelope_visible (bool yn)
724 if (gain_line && ((_flags & EnvelopeVisible) != yn)) {
727 _flags |= EnvelopeVisible;
730 _flags &= ~EnvelopeVisible;
737 AudioRegionView::create_waves ()
739 bool create_zero_line = true;
741 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
743 if (!atv.get_diskstream()) {
747 uint32_t nchans = atv.get_diskstream()->n_channels();
749 /* in tmp_waves, set up null pointers for each channel so the vector is allocated */
750 for (uint32_t n = 0; n < nchans; ++n) {
751 tmp_waves.push_back (0);
754 for (uint32_t n = 0; n < nchans; ++n) {
756 if (n >= audio_region()->n_channels()) {
760 wave_caches.push_back (WaveView::create_cache ());
763 if (audio_region()->source(n)->peaks_ready (bind (mem_fun(*this, &AudioRegionView::peaks_ready_handler), n), data_ready_connection)) {
764 create_one_wave (n, true);
766 create_zero_line = false;
769 create_one_wave (n, true);
773 if (create_zero_line) {
777 zero_line = new ArdourCanvas::SimpleLine (*group);
778 zero_line->property_x1() = (gdouble) 1.0;
779 zero_line->property_x2() = (gdouble) (_region->length() / samples_per_unit) - 1.0;
780 zero_line->property_color_rgba() = (guint) color_map[cZeroLine];
786 AudioRegionView::create_one_wave (uint32_t which, bool direct)
788 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
789 uint32_t nchans = atv.get_diskstream()->n_channels();
791 uint32_t nwaves = std::min (nchans, audio_region()->n_channels());
794 if (trackview.height < NAME_HIGHLIGHT_SIZE) {
795 ht = ((trackview.height) / (double) nchans);
797 ht = ((trackview.height - NAME_HIGHLIGHT_SIZE) / (double) nchans);
800 gdouble yoff = which * ht;
802 WaveView *wave = new WaveView(*group);
804 wave->property_data_src() = (gpointer) _region.get();
805 wave->property_cache() = wave_caches[which];
806 wave->property_cache_updater() = true;
807 wave->property_channel() = which;
808 wave->property_length_function() = (gpointer) region_length_from_c;
809 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
810 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
811 wave->property_x() = 0.0;
812 wave->property_y() = yoff;
813 wave->property_height() = (double) ht;
814 wave->property_samples_per_unit() = samples_per_unit;
815 wave->property_amplitude_above_axis() = _amplitude_above_axis;
816 wave->property_wave_color() = _region->muted() ? color_map[cMutedWaveForm] : color_map[cWaveForm];
817 wave->property_region_start() = _region->start();
819 if (!(_flags & WaveformVisible)) {
823 /* note: calling this function is serialized by the lock
824 held in the peak building thread that signals that
825 peaks are ready for use *or* by the fact that it is
826 called one by one from the GUI thread.
829 if (which < nchans) {
830 tmp_waves[which] = wave;
832 /* n-channel track, >n-channel source */
835 /* see if we're all ready */
837 for (n = 0; n < nchans; ++n) {
838 if (tmp_waves[n] == 0) {
843 if (n == nwaves && waves.empty()) {
844 /* all waves are ready */
845 tmp_waves.resize(nwaves);
850 /* all waves created, don't hook into peaks ready anymore */
851 data_ready_connection.disconnect ();
854 zero_line = new ArdourCanvas::SimpleLine (*group);
855 zero_line->property_x1() = (gdouble) 1.0;
856 zero_line->property_x2() = (gdouble) (_region->length() / samples_per_unit) - 1.0;
857 zero_line->property_color_rgba() = (guint) color_map[cZeroLine];
864 AudioRegionView::peaks_ready_handler (uint32_t which)
866 Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun(*this, &AudioRegionView::create_one_wave), which, false));
870 AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
872 if (gain_line == 0) {
878 /* don't create points that can't be seen */
880 set_envelope_visible (true);
887 nframes_t fx = trackview.editor.pixel_to_frame (x);
889 if (fx > _region->length()) {
893 /* compute vertical fractional position */
895 y = 1.0 - (y / (trackview.height - NAME_HIGHLIGHT_SIZE));
897 /* map using gain line */
899 gain_line->view_to_model_y (y);
901 trackview.session().begin_reversible_command (_("add gain control point"));
902 XMLNode &before = audio_region()->envelope().get_state();
904 if (!audio_region()->envelope_active()) {
905 XMLNode ®ion_before = audio_region()->get_state();
906 audio_region()->set_envelope_active(true);
907 XMLNode ®ion_after = audio_region()->get_state();
908 trackview.session().add_command (new MementoCommand<AudioRegion>(*(audio_region().get()), ®ion_before, ®ion_after));
911 audio_region()->envelope().add (fx, y);
913 XMLNode &after = audio_region()->envelope().get_state();
914 trackview.session().add_command (new MementoCommand<Curve>(audio_region()->envelope(), &before, &after));
915 trackview.session().commit_reversible_command ();
919 AudioRegionView::remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
921 ControlPoint *cp = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"));
922 audio_region()->envelope().erase (cp->model);
926 AudioRegionView::store_flags()
928 XMLNode *node = new XMLNode ("GUI");
930 node->add_property ("waveform-visible", (_flags & WaveformVisible) ? "yes" : "no");
931 node->add_property ("envelope-visible", (_flags & EnvelopeVisible) ? "yes" : "no");
933 _region->add_extra_xml (*node);
937 AudioRegionView::set_flags (XMLNode* node)
941 if ((prop = node->property ("waveform-visible")) != 0) {
942 if (prop->value() == "yes") {
943 _flags |= WaveformVisible;
947 if ((prop = node->property ("envelope-visible")) != 0) {
948 if (prop->value() == "yes") {
949 _flags |= EnvelopeVisible;
955 AudioRegionView::set_waveform_shape (WaveformShape shape)
959 /* this slightly odd approach is to leave the door open to
960 other "shapes" such as spectral displays, etc.
973 if (yn != (bool) (_flags & WaveformRectified)) {
974 for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
975 (*wave)->property_rectified() = yn;
987 _flags |= WaveformRectified;
989 _flags &= ~WaveformRectified;
995 AudioRegionView::add_ghost (AutomationTimeAxisView& atv)
997 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&trackview);
1000 double unit_position = _region->position () / samples_per_unit;
1001 GhostRegion* ghost = new GhostRegion (atv, unit_position);
1004 nchans = rtv->get_diskstream()->n_channels();
1006 for (uint32_t n = 0; n < nchans; ++n) {
1008 if (n >= audio_region()->n_channels()) {
1012 WaveView *wave = new WaveView(*ghost->group);
1014 wave->property_data_src() = _region.get();
1015 wave->property_cache() = wave_caches[n];
1016 wave->property_cache_updater() = false;
1017 wave->property_channel() = n;
1018 wave->property_length_function() = (gpointer)region_length_from_c;
1019 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
1020 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
1021 wave->property_x() = 0.0;
1022 wave->property_samples_per_unit() = samples_per_unit;
1023 wave->property_amplitude_above_axis() = _amplitude_above_axis;
1024 wave->property_wave_color() = color_map[cGhostTrackWave];
1025 wave->property_region_start() = _region->start();
1027 ghost->waves.push_back(wave);
1030 ghost->set_height ();
1031 ghost->set_duration (_region->length() / samples_per_unit);
1032 ghosts.push_back (ghost);
1034 ghost->GoingAway.connect (mem_fun(*this, &AudioRegionView::remove_ghost));
1040 AudioRegionView::entered ()
1042 if (gain_line && _flags & EnvelopeVisible) {
1043 gain_line->show_all_control_points ();
1047 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
1050 if (fade_in_handle) {
1051 fade_in_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1052 fade_out_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1057 AudioRegionView::exited ()
1060 gain_line->hide_all_but_selected_control_points ();
1064 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
1067 if (fade_in_handle) {
1068 fade_in_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1069 fade_out_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1074 AudioRegionView::envelope_active_changed ()
1077 gain_line->set_line_color (audio_region()->envelope_active() ? color_map[cGainLine] : color_map[cGainLineInactive]);
1082 AudioRegionView::set_waveview_data_src()
1085 double unit_length= _region->length() / samples_per_unit;
1087 for (uint32_t n = 0; n < waves.size(); ++n) {
1088 // TODO: something else to let it know the channel
1089 waves[n]->property_data_src() = _region.get();
1092 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
1094 (*i)->set_duration (unit_length);
1096 for (vector<WaveView*>::iterator w = (*i)->waves.begin(); w != (*i)->waves.end(); ++w) {
1097 (*w)->property_data_src() = _region.get();
1104 AudioRegionView::color_handler (ColorID id, uint32_t val)
1107 case cMutedWaveForm:
1112 case cGainLineInactive:
1114 envelope_active_changed();
1119 zero_line->property_color_rgba() = (guint) color_map[cZeroLine];
1123 case cGhostTrackWave: