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, boost::shared_ptr<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, boost::shared_ptr<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)) {
164 set_height (trackview.height);
167 region_sync_changed ();
168 region_resized (BoundsChanged);
169 set_waveview_data_src();
171 envelope_active_changed ();
172 fade_in_active_changed ();
173 fade_out_active_changed ();
175 _region->StateChanged.connect (mem_fun(*this, &AudioRegionView::region_changed));
177 fade_in_shape->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_event), fade_in_shape, this));
178 fade_in_handle->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_handle_event), fade_in_handle, this));
179 fade_out_shape->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_event), fade_out_shape, this));
180 fade_out_handle->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_handle_event), fade_out_handle, this));
184 /* XXX sync mark drag? */
187 AudioRegionView::~AudioRegionView ()
189 in_destructor = true;
191 RegionViewGoingAway (this); /* EMIT_SIGNAL */
193 for (vector<GnomeCanvasWaveViewCache *>::iterator cache = wave_caches.begin(); cache != wave_caches.end() ; ++cache) {
194 gnome_canvas_waveview_cache_destroy (*cache);
197 /* all waveviews etc will be destroyed when the group is destroyed */
204 boost::shared_ptr<ARDOUR::AudioRegion>
205 AudioRegionView::audio_region() const
207 // "Guaranteed" to succeed...
208 return boost::dynamic_pointer_cast<AudioRegion>(_region);
212 AudioRegionView::region_changed (Change what_changed)
214 ENSURE_GUI_THREAD (bind (mem_fun(*this, &AudioRegionView::region_changed), what_changed));
216 RegionView::region_changed(what_changed);
218 if (what_changed & AudioRegion::ScaleAmplitudeChanged) {
219 region_scale_amplitude_changed ();
221 if (what_changed & AudioRegion::FadeInChanged) {
224 if (what_changed & AudioRegion::FadeOutChanged) {
227 if (what_changed & AudioRegion::FadeInActiveChanged) {
228 fade_in_active_changed ();
230 if (what_changed & AudioRegion::FadeOutActiveChanged) {
231 fade_out_active_changed ();
233 if (what_changed & AudioRegion::EnvelopeActiveChanged) {
234 envelope_active_changed ();
239 AudioRegionView::fade_in_changed ()
241 reset_fade_in_shape ();
245 AudioRegionView::fade_out_changed ()
247 reset_fade_out_shape ();
251 AudioRegionView::set_fade_in_active (bool yn)
253 audio_region()->set_fade_in_active (yn);
257 AudioRegionView::set_fade_out_active (bool yn)
259 audio_region()->set_fade_out_active (yn);
263 AudioRegionView::fade_in_active_changed ()
267 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
269 if (audio_region()->fade_in_active()) {
270 col = RGBA_TO_UINT(r,g,b,120);
271 fade_in_shape->property_fill_color_rgba() = col;
272 fade_in_shape->property_width_pixels() = 0;
273 fade_in_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,0);
275 col = RGBA_TO_UINT(r,g,b,0);
276 fade_in_shape->property_fill_color_rgba() = col;
277 fade_in_shape->property_width_pixels() = 1;
278 fade_in_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,255);
283 AudioRegionView::fade_out_active_changed ()
287 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
289 if (audio_region()->fade_out_active()) {
290 col = RGBA_TO_UINT(r,g,b,120);
291 fade_out_shape->property_fill_color_rgba() = col;
292 fade_out_shape->property_width_pixels() = 0;
293 fade_out_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,0);
295 col = RGBA_TO_UINT(r,g,b,0);
296 fade_out_shape->property_fill_color_rgba() = col;
297 fade_out_shape->property_width_pixels() = 1;
298 fade_out_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,255);
304 AudioRegionView::region_scale_amplitude_changed ()
306 ENSURE_GUI_THREAD (mem_fun(*this, &AudioRegionView::region_scale_amplitude_changed));
308 for (uint32_t n = 0; n < waves.size(); ++n) {
309 // force a reload of the cache
310 waves[n]->property_data_src() = _region.get();
315 AudioRegionView::region_renamed ()
317 // FIXME: ugly duplication with RegionView...
321 if (_region->locked()) {
323 str += _region->name();
326 str = _region->name();
329 // ... because of this
330 if (audio_region()->speed_mismatch (trackview.session().frame_rate())) {
331 str = string ("*") + str;
334 if (_region->muted()) {
335 str = string ("!") + str;
338 set_item_name (str, this);
343 AudioRegionView::region_resized (Change what_changed)
345 RegionView::region_resized(what_changed);
347 if (what_changed & Change (StartChanged|LengthChanged)) {
349 for (uint32_t n = 0; n < waves.size(); ++n) {
350 waves[n]->property_region_start() = _region->start();
353 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
355 for (vector<WaveView*>::iterator w = (*i)->waves.begin(); w != (*i)->waves.end(); ++w) {
356 (*w)->property_region_start() = _region->start();
363 AudioRegionView::reset_width_dependent_items (double pixel_width)
365 RegionView::reset_width_dependent_items(pixel_width);
366 assert(_pixel_width == pixel_width);
369 zero_line->property_x2() = pixel_width - 1.0;
372 if (fade_in_handle) {
373 if (pixel_width <= 6.0) {
374 fade_in_handle->hide();
375 fade_out_handle->hide();
378 fade_in_handle->hide();
379 fade_out_handle->hide();
381 fade_in_handle->show();
382 fade_out_handle->show();
387 reset_fade_shapes ();
391 AudioRegionView::region_muted ()
393 RegionView::region_muted();
395 for (uint32_t n=0; n < waves.size(); ++n) {
396 if (_region->muted()) {
397 waves[n]->property_wave_color() = color_map[cMutedWaveForm];
399 waves[n]->property_wave_color() = color_map[cWaveForm];
405 AudioRegionView::set_height (gdouble height)
407 RegionView::set_height(height);
409 uint32_t wcnt = waves.size();
411 for (uint32_t n=0; n < wcnt; ++n) {
414 if ((height) <= NAME_HIGHLIGHT_THRESH) {
415 ht = ((height-2*wcnt) / (double) wcnt);
417 ht = (((height-2*wcnt) - NAME_HIGHLIGHT_SIZE) / (double) wcnt);
420 gdouble yoff = n * (ht+1);
422 waves[n]->property_height() = ht;
423 waves[n]->property_y() = yoff + 2;
427 if ((height/wcnt) < NAME_HIGHLIGHT_SIZE) {
430 if (_flags & EnvelopeVisible) {
434 gain_line->set_height ((uint32_t) rint (height - NAME_HIGHLIGHT_SIZE));
438 reset_fade_shapes ();
441 name_text->raise_to_top();
446 AudioRegionView::manage_zero_line ()
452 if (_height >= 100) {
453 gdouble wave_midpoint = (_height - NAME_HIGHLIGHT_SIZE) / 2.0;
454 zero_line->property_y1() = wave_midpoint;
455 zero_line->property_y2() = wave_midpoint;
463 AudioRegionView::reset_fade_shapes ()
465 reset_fade_in_shape ();
466 reset_fade_out_shape ();
470 AudioRegionView::reset_fade_in_shape ()
472 reset_fade_in_shape_width ((nframes_t) audio_region()->fade_in().back()->when);
476 AudioRegionView::reset_fade_in_shape_width (nframes_t width)
478 if (fade_in_handle == 0) {
482 /* smallest size for a fade is 64 frames */
484 width = std::max ((nframes_t) 64, width);
487 double pwidth = width / samples_per_unit;
488 uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth);
492 fade_in_shape->hide();
493 fade_in_handle->hide();
497 double handle_center;
498 handle_center = pwidth;
500 if (handle_center > 7.0) {
501 handle_center -= 3.0;
506 fade_in_handle->property_x1() = handle_center - 3.0;
507 fade_in_handle->property_x2() = handle_center + 3.0;
510 fade_in_shape->hide();
514 fade_in_shape->show();
516 float curve[npoints];
517 audio_region()->fade_in().get_vector (0, audio_region()->fade_in().back()->when, curve, npoints);
519 points = get_canvas_points ("fade in shape", npoints+3);
521 if (_height > NAME_HIGHLIGHT_THRESH) {
522 h = _height - NAME_HIGHLIGHT_SIZE;
527 /* points *MUST* be in anti-clockwise order */
530 double xdelta = pwidth/npoints;
532 for (pi = 0, pc = 0; pc < npoints; ++pc) {
533 (*points)[pi].set_x(1 + (pc * xdelta));
534 (*points)[pi++].set_y(2 + (h - (curve[pc] * h)));
539 (*points)[pi].set_x(pwidth);
540 (*points)[pi++].set_y(2);
542 (*points)[pi].set_x(1);
543 (*points)[pi++].set_y(2);
545 /* connect the dots ... */
547 (*points)[pi] = (*points)[0];
549 fade_in_shape->property_points() = *points;
554 AudioRegionView::reset_fade_out_shape ()
556 reset_fade_out_shape_width ((nframes_t) audio_region()->fade_out().back()->when);
560 AudioRegionView::reset_fade_out_shape_width (nframes_t width)
562 if (fade_out_handle == 0) {
566 /* smallest size for a fade is 64 frames */
568 width = std::max ((nframes_t) 64, width);
571 double pwidth = width / samples_per_unit;
572 uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth);
576 fade_out_shape->hide();
577 fade_out_handle->hide();
581 double handle_center;
582 handle_center = (_region->length() - width) / samples_per_unit;
584 if (handle_center > 7.0) {
585 handle_center -= 3.0;
590 fade_out_handle->property_x1() = handle_center - 3.0;
591 fade_out_handle->property_x2() = handle_center + 3.0;
593 /* don't show shape if its too small */
596 fade_out_shape->hide();
600 fade_out_shape->show();
602 float curve[npoints];
603 audio_region()->fade_out().get_vector (0, audio_region()->fade_out().back()->when, curve, npoints);
605 if (_height > NAME_HIGHLIGHT_THRESH) {
606 h = _height - NAME_HIGHLIGHT_SIZE;
611 /* points *MUST* be in anti-clockwise order */
613 points = get_canvas_points ("fade out shape", npoints+3);
616 double xdelta = pwidth/npoints;
618 for (pi = 0, pc = 0; pc < npoints; ++pc) {
619 (*points)[pi].set_x(_pixel_width - 1 - pwidth + (pc*xdelta));
620 (*points)[pi++].set_y(2 + (h - (curve[pc] * h)));
625 (*points)[pi].set_x(_pixel_width);
626 (*points)[pi++].set_y(h);
628 (*points)[pi].set_x(_pixel_width);
629 (*points)[pi++].set_y(2);
631 /* connect the dots ... */
633 (*points)[pi] = (*points)[0];
635 fade_out_shape->property_points() = *points;
640 AudioRegionView::set_samples_per_unit (gdouble spu)
642 RegionView::set_samples_per_unit (spu);
644 for (uint32_t n=0; n < waves.size(); ++n) {
645 waves[n]->property_samples_per_unit() = spu;
651 reset_fade_shapes ();
655 AudioRegionView::set_amplitude_above_axis (gdouble spp)
657 for (uint32_t n=0; n < waves.size(); ++n) {
658 waves[n]->property_amplitude_above_axis() = spp;
663 AudioRegionView::compute_colors (Gdk::Color& basic_color)
665 RegionView::compute_colors(basic_color);
669 /* gain color computed in envelope_active_changed() */
671 UINT_TO_RGBA (fill_color, &r, &g, &b, &a);
672 fade_color = RGBA_TO_UINT(r,g,b,120);
676 AudioRegionView::set_colors ()
678 RegionView::set_colors();
681 gain_line->set_line_color (audio_region()->envelope_active() ? color_map[cGainLine] : color_map[cGainLineInactive]);
684 for (uint32_t n=0; n < waves.size(); ++n) {
685 if (_region->muted()) {
686 waves[n]->property_wave_color() = color_map[cMutedWaveForm];
688 waves[n]->property_wave_color() = color_map[cWaveForm];
694 AudioRegionView::show_region_editor ()
697 editor = new AudioRegionEditor (trackview.session(), audio_region(), *this);
698 // GTK2FIX : how to ensure float without realizing
699 // editor->realize ();
700 // trackview.editor.ensure_float (*editor);
704 editor->get_window()->raise();
708 AudioRegionView::set_waveform_visible (bool yn)
710 if (((_flags & WaveformVisible) != yn)) {
712 for (uint32_t n=0; n < waves.size(); ++n) {
715 _flags |= WaveformVisible;
717 for (uint32_t n=0; n < waves.size(); ++n) {
720 _flags &= ~WaveformVisible;
727 AudioRegionView::temporarily_hide_envelope ()
735 AudioRegionView::unhide_envelope ()
737 if (gain_line && (_flags & EnvelopeVisible)) {
743 AudioRegionView::set_envelope_visible (bool yn)
745 if (gain_line && ((_flags & EnvelopeVisible) != yn)) {
748 _flags |= EnvelopeVisible;
751 _flags &= ~EnvelopeVisible;
758 AudioRegionView::create_waves ()
760 bool create_zero_line = true;
762 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
764 if (!atv.get_diskstream()) {
768 uint32_t nchans = atv.get_diskstream()->n_channels().get(DataType::AUDIO);
770 /* in tmp_waves, set up null pointers for each channel so the vector is allocated */
771 for (uint32_t n = 0; n < nchans; ++n) {
772 tmp_waves.push_back (0);
775 for (uint32_t n = 0; n < nchans; ++n) {
777 if (n >= audio_region()->n_channels()) {
781 wave_caches.push_back (WaveView::create_cache ());
784 if (audio_region()->audio_source(n)->peaks_ready (bind (mem_fun(*this, &AudioRegionView::peaks_ready_handler), n), data_ready_connection)) {
785 create_one_wave (n, true);
787 create_zero_line = false;
790 create_one_wave (n, true);
794 if (create_zero_line) {
798 zero_line = new ArdourCanvas::SimpleLine (*group);
799 zero_line->property_x1() = (gdouble) 1.0;
800 zero_line->property_x2() = (gdouble) (_region->length() / samples_per_unit) - 1.0;
801 zero_line->property_color_rgba() = (guint) color_map[cZeroLine];
807 AudioRegionView::create_one_wave (uint32_t which, bool direct)
809 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
810 uint32_t nchans = atv.get_diskstream()->n_channels().get(DataType::AUDIO);
812 uint32_t nwaves = std::min (nchans, audio_region()->n_channels());
815 if (trackview.height < NAME_HIGHLIGHT_SIZE) {
816 ht = ((trackview.height) / (double) nchans);
818 ht = ((trackview.height - NAME_HIGHLIGHT_SIZE) / (double) nchans);
821 gdouble yoff = which * ht;
823 WaveView *wave = new WaveView(*group);
825 wave->property_data_src() = (gpointer) _region.get();
826 wave->property_cache() = wave_caches[which];
827 wave->property_cache_updater() = true;
828 wave->property_channel() = which;
829 wave->property_length_function() = (gpointer) region_length_from_c;
830 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
831 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
832 wave->property_x() = 0.0;
833 wave->property_y() = yoff;
834 wave->property_height() = (double) ht;
835 wave->property_samples_per_unit() = samples_per_unit;
836 wave->property_amplitude_above_axis() = _amplitude_above_axis;
837 wave->property_wave_color() = _region->muted() ? color_map[cMutedWaveForm] : color_map[cWaveForm];
838 wave->property_region_start() = _region->start();
840 if (!(_flags & WaveformVisible)) {
844 /* note: calling this function is serialized by the lock
845 held in the peak building thread that signals that
846 peaks are ready for use *or* by the fact that it is
847 called one by one from the GUI thread.
850 if (which < nchans) {
851 tmp_waves[which] = wave;
853 /* n-channel track, >n-channel source */
856 /* see if we're all ready */
858 for (n = 0; n < nchans; ++n) {
859 if (tmp_waves[n] == 0) {
864 if (n == nwaves && waves.empty()) {
865 /* all waves are ready */
866 tmp_waves.resize(nwaves);
872 zero_line = new ArdourCanvas::SimpleLine (*group);
873 zero_line->property_x1() = (gdouble) 1.0;
874 zero_line->property_x2() = (gdouble) (_region->length() / samples_per_unit) - 1.0;
875 zero_line->property_color_rgba() = (guint) color_map[cZeroLine];
882 AudioRegionView::peaks_ready_handler (uint32_t which)
884 Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun(*this, &AudioRegionView::create_one_wave), which, false));
886 if (!waves.empty()) {
887 /* all waves created, don't hook into peaks ready anymore */
888 data_ready_connection.disconnect ();
893 AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
895 if (gain_line == 0) {
901 /* don't create points that can't be seen */
903 set_envelope_visible (true);
910 nframes_t fx = trackview.editor.pixel_to_frame (x);
912 if (fx > _region->length()) {
916 /* compute vertical fractional position */
918 y = 1.0 - (y / (trackview.height - NAME_HIGHLIGHT_SIZE));
920 /* map using gain line */
922 gain_line->view_to_model_y (y);
924 trackview.session().begin_reversible_command (_("add gain control point"));
925 XMLNode &before = audio_region()->envelope().get_state();
928 if (!audio_region()->envelope_active()) {
929 XMLNode &before = audio_region()->get_state();
930 audio_region()->set_envelope_active(true);
931 XMLNode &after = audio_region()->get_state();
932 trackview.session().add_command (new MementoCommand<AudioRegion>(*(audio_region().get()), &before, &after));
935 audio_region()->envelope().add (fx, y);
937 XMLNode &after = audio_region()->envelope().get_state();
938 trackview.session().add_command (new MementoCommand<Curve>(audio_region()->envelope(), &before, &after));
939 trackview.session().commit_reversible_command ();
943 AudioRegionView::remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
945 ControlPoint *cp = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"));
946 audio_region()->envelope().erase (cp->model);
950 AudioRegionView::store_flags()
952 XMLNode *node = new XMLNode ("GUI");
954 node->add_property ("waveform-visible", (_flags & WaveformVisible) ? "yes" : "no");
955 node->add_property ("envelope-visible", (_flags & EnvelopeVisible) ? "yes" : "no");
957 _region->add_extra_xml (*node);
961 AudioRegionView::set_flags (XMLNode* node)
965 if ((prop = node->property ("waveform-visible")) != 0) {
966 if (prop->value() == "yes") {
967 _flags |= WaveformVisible;
971 if ((prop = node->property ("envelope-visible")) != 0) {
972 if (prop->value() == "yes") {
973 _flags |= EnvelopeVisible;
979 AudioRegionView::set_waveform_shape (WaveformShape shape)
983 /* this slightly odd approach is to leave the door open to
984 other "shapes" such as spectral displays, etc.
997 if (yn != (bool) (_flags & WaveformRectified)) {
998 for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
999 (*wave)->property_rectified() = yn;
1011 _flags |= WaveformRectified;
1013 _flags &= ~WaveformRectified;
1019 AudioRegionView::add_ghost (AutomationTimeAxisView& atv)
1021 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&trackview);
1024 double unit_position = _region->position () / samples_per_unit;
1025 GhostRegion* ghost = new GhostRegion (atv, unit_position);
1028 nchans = rtv->get_diskstream()->n_channels().get(DataType::AUDIO);
1030 for (uint32_t n = 0; n < nchans; ++n) {
1032 if (n >= audio_region()->n_channels()) {
1036 WaveView *wave = new WaveView(*ghost->group);
1038 wave->property_data_src() = _region.get();
1039 wave->property_cache() = wave_caches[n];
1040 wave->property_cache_updater() = false;
1041 wave->property_channel() = n;
1042 wave->property_length_function() = (gpointer)region_length_from_c;
1043 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
1044 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
1045 wave->property_x() = 0.0;
1046 wave->property_samples_per_unit() = samples_per_unit;
1047 wave->property_amplitude_above_axis() = _amplitude_above_axis;
1048 wave->property_wave_color() = color_map[cGhostTrackWave];
1049 wave->property_region_start() = _region->start();
1051 ghost->waves.push_back(wave);
1054 ghost->set_height ();
1055 ghost->set_duration (_region->length() / samples_per_unit);
1056 ghosts.push_back (ghost);
1058 ghost->GoingAway.connect (mem_fun(*this, &AudioRegionView::remove_ghost));
1064 AudioRegionView::entered ()
1066 if (gain_line && _flags & EnvelopeVisible) {
1067 gain_line->show_all_control_points ();
1071 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
1074 if (fade_in_handle) {
1075 fade_in_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1076 fade_out_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1081 AudioRegionView::exited ()
1084 gain_line->hide_all_but_selected_control_points ();
1088 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
1091 if (fade_in_handle) {
1092 fade_in_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1093 fade_out_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1098 AudioRegionView::envelope_active_changed ()
1101 gain_line->set_line_color (audio_region()->envelope_active() ? color_map[cGainLine] : color_map[cGainLineInactive]);
1106 AudioRegionView::set_waveview_data_src()
1109 double unit_length= _region->length() / samples_per_unit;
1111 for (uint32_t n = 0; n < waves.size(); ++n) {
1112 // TODO: something else to let it know the channel
1113 waves[n]->property_data_src() = _region.get();
1116 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
1118 (*i)->set_duration (unit_length);
1120 for (vector<WaveView*>::iterator w = (*i)->waves.begin(); w != (*i)->waves.end(); ++w) {
1121 (*w)->property_data_src() = _region.get();
1128 AudioRegionView::color_handler (ColorID id, uint32_t val)
1131 case cMutedWaveForm:
1136 case cGainLineInactive:
1138 envelope_active_changed();
1143 zero_line->property_color_rgba() = (guint) color_map[cZeroLine];
1147 case cGhostTrackWave: