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>
32 #include <pbd/stacktrace.h>
34 #include "streamview.h"
35 #include "audio_region_view.h"
36 #include "audio_time_axis.h"
37 #include "simplerect.h"
38 #include "simpleline.h"
40 #include "public_editor.h"
41 #include "audio_region_editor.h"
42 #include "region_gain_line.h"
43 #include "ghostregion.h"
44 #include "audio_time_axis.h"
46 #include "rgb_macros.h"
47 #include "gui_thread.h"
52 using namespace ARDOUR;
54 using namespace Editing;
55 using namespace ArdourCanvas;
57 static const int32_t sync_mark_width = 9;
59 AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, boost::shared_ptr<AudioRegion> r, double spu,
60 Gdk::Color& basic_color)
61 : RegionView (parent, tv, r, spu, basic_color)
69 , _amplitude_above_axis(1.0)
75 AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, boost::shared_ptr<AudioRegion> r, double spu,
76 Gdk::Color& basic_color, TimeAxisViewItem::Visibility visibility)
77 : RegionView (parent, tv, r, spu, basic_color, visibility)
85 , _amplitude_above_axis(1.0)
92 AudioRegionView::AudioRegionView (const AudioRegionView& other)
100 , _amplitude_above_axis(1.0)
108 UINT_TO_RGBA (other.fill_color, &r, &g, &b, &a);
109 c.set_rgb_p (r/255.0, g/255.0, b/255.0);
115 AudioRegionView::init (Gdk::Color& basic_color, bool wfd)
117 // FIXME: Some redundancy here with RegionView::init. Need to figure out
118 // where order is important and where it isn't...
120 RegionView::init(basic_color, false);
124 _amplitude_above_axis = 1.0;
128 if ((node = _region->extra_xml ("GUI")) != 0) {
131 _flags = WaveformVisible;
135 if (trackview.editor.new_regionviews_display_gain()) {
136 _flags |= EnvelopeVisible;
139 compute_colors (basic_color);
143 fade_in_shape = new ArdourCanvas::Polygon (*group);
144 fade_in_shape->property_fill_color_rgba() = fade_color;
145 fade_in_shape->set_data ("regionview", this);
147 fade_out_shape = new ArdourCanvas::Polygon (*group);
148 fade_out_shape->property_fill_color_rgba() = fade_color;
149 fade_out_shape->set_data ("regionview", this);
154 UINT_TO_RGBA(fill_color,&r,&g,&b,&a);
157 fade_in_handle = new ArdourCanvas::SimpleRect (*group);
158 fade_in_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,0);
159 fade_in_handle->property_outline_pixels() = 0;
160 fade_in_handle->property_y1() = 2.0;
161 fade_in_handle->property_y2() = 7.0;
163 fade_in_handle->set_data ("regionview", this);
165 fade_out_handle = new ArdourCanvas::SimpleRect (*group);
166 fade_out_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,0);
167 fade_out_handle->property_outline_pixels() = 0;
168 fade_out_handle->property_y1() = 2.0;
169 fade_out_handle->property_y2() = 7.0;
171 fade_out_handle->set_data ("regionview", this);
174 string foo = _region->name();
178 gain_line = new AudioRegionGainLine (foo, trackview.session(), *this, *group, audio_region()->envelope());
180 if (!(_flags & EnvelopeVisible)) {
188 set_height (trackview.height);
191 region_sync_changed ();
192 region_resized (BoundsChanged);
193 set_waveview_data_src();
195 envelope_active_changed ();
196 fade_in_active_changed ();
197 fade_out_active_changed ();
199 fade_in_shape->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_event), fade_in_shape, this));
200 fade_in_handle->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_handle_event), fade_in_handle, this));
201 fade_out_shape->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_event), fade_out_shape, this));
202 fade_out_handle->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_handle_event), fade_out_handle, this));
206 /* XXX sync mark drag? */
209 AudioRegionView::~AudioRegionView ()
211 in_destructor = true;
213 RegionViewGoingAway (this); /* EMIT_SIGNAL */
215 for (vector<GnomeCanvasWaveViewCache *>::iterator cache = wave_caches.begin(); cache != wave_caches.end() ; ++cache) {
216 gnome_canvas_waveview_cache_destroy (*cache);
219 /* all waveviews etc will be destroyed when the group is destroyed */
226 boost::shared_ptr<ARDOUR::AudioRegion>
227 AudioRegionView::audio_region() const
229 // "Guaranteed" to succeed...
230 return boost::dynamic_pointer_cast<AudioRegion>(_region);
234 AudioRegionView::region_changed (Change what_changed)
236 ENSURE_GUI_THREAD (bind (mem_fun(*this, &AudioRegionView::region_changed), what_changed));
238 RegionView::region_changed(what_changed);
240 if (what_changed & AudioRegion::ScaleAmplitudeChanged) {
241 region_scale_amplitude_changed ();
243 if (what_changed & AudioRegion::FadeInChanged) {
246 if (what_changed & AudioRegion::FadeOutChanged) {
249 if (what_changed & AudioRegion::FadeInActiveChanged) {
250 fade_in_active_changed ();
252 if (what_changed & AudioRegion::FadeOutActiveChanged) {
253 fade_out_active_changed ();
255 if (what_changed & AudioRegion::EnvelopeActiveChanged) {
256 envelope_active_changed ();
261 AudioRegionView::fade_in_changed ()
263 reset_fade_in_shape ();
267 AudioRegionView::fade_out_changed ()
269 reset_fade_out_shape ();
272 AudioRegionView::fade_in_active_changed ()
276 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
278 if (audio_region()->fade_in_active()) {
279 col = RGBA_TO_UINT(r,g,b,120);
280 fade_in_shape->property_fill_color_rgba() = col;
281 fade_in_shape->property_width_pixels() = 0;
282 fade_in_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,0);
284 col = RGBA_TO_UINT(r,g,b,0);
285 fade_in_shape->property_fill_color_rgba() = col;
286 fade_in_shape->property_width_pixels() = 1;
287 fade_in_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,255);
292 AudioRegionView::fade_out_active_changed ()
296 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
298 if (audio_region()->fade_out_active()) {
299 col = RGBA_TO_UINT(r,g,b,120);
300 fade_out_shape->property_fill_color_rgba() = col;
301 fade_out_shape->property_width_pixels() = 0;
302 fade_out_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,0);
304 col = RGBA_TO_UINT(r,g,b,0);
305 fade_out_shape->property_fill_color_rgba() = col;
306 fade_out_shape->property_width_pixels() = 1;
307 fade_out_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,255);
313 AudioRegionView::region_scale_amplitude_changed ()
315 ENSURE_GUI_THREAD (mem_fun(*this, &AudioRegionView::region_scale_amplitude_changed));
317 for (uint32_t n = 0; n < waves.size(); ++n) {
318 // force a reload of the cache
319 waves[n]->property_data_src() = _region.get();
324 AudioRegionView::region_renamed ()
326 Glib::ustring str = RegionView::make_name ();
328 if (audio_region()->speed_mismatch (trackview.session().frame_rate())) {
329 str = string ("*") + str;
332 if (_region->muted()) {
333 str = string ("!") + str;
336 set_item_name (str, this);
341 AudioRegionView::region_resized (Change what_changed)
343 RegionView::region_resized(what_changed);
345 if (what_changed & Change (StartChanged|LengthChanged)) {
347 for (uint32_t n = 0; n < waves.size(); ++n) {
348 waves[n]->property_region_start() = _region->start();
351 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
353 for (vector<WaveView*>::iterator w = (*i)->waves.begin(); w != (*i)->waves.end(); ++w) {
354 (*w)->property_region_start() = _region->start();
361 AudioRegionView::reset_width_dependent_items (double pixel_width)
363 RegionView::reset_width_dependent_items(pixel_width);
364 assert(_pixel_width == pixel_width);
367 zero_line->property_x2() = pixel_width - 1.0;
370 if (fade_in_handle) {
371 if (pixel_width <= 6.0) {
372 fade_in_handle->hide();
373 fade_out_handle->hide();
376 fade_in_handle->hide();
377 fade_out_handle->hide();
379 fade_in_handle->show();
380 fade_out_handle->show();
385 reset_fade_shapes ();
389 AudioRegionView::region_muted ()
391 RegionView::region_muted();
393 for (uint32_t n=0; n < waves.size(); ++n) {
394 if (_region->muted()) {
395 waves[n]->property_wave_color() = color_map[cMutedWaveForm];
397 waves[n]->property_wave_color() = color_map[cWaveForm];
403 AudioRegionView::set_height (gdouble height)
405 RegionView::set_height(height);
407 uint32_t wcnt = waves.size();
409 for (uint32_t n=0; n < wcnt; ++n) {
412 if ((height) <= NAME_HIGHLIGHT_THRESH) {
413 ht = ((height-2*wcnt) / (double) wcnt);
415 ht = (((height-2*wcnt) - NAME_HIGHLIGHT_SIZE) / (double) wcnt);
418 gdouble yoff = n * (ht+1);
420 waves[n]->property_height() = ht;
421 waves[n]->property_y() = yoff + 2;
425 if ((height/wcnt) < NAME_HIGHLIGHT_SIZE) {
428 if (_flags & EnvelopeVisible) {
432 gain_line->set_height ((uint32_t) rint (height - NAME_HIGHLIGHT_SIZE));
436 reset_fade_shapes ();
439 name_text->raise_to_top();
444 AudioRegionView::manage_zero_line ()
450 if (_height >= 100) {
451 gdouble wave_midpoint = (_height - NAME_HIGHLIGHT_SIZE) / 2.0;
452 zero_line->property_y1() = wave_midpoint;
453 zero_line->property_y2() = wave_midpoint;
461 AudioRegionView::reset_fade_shapes ()
463 reset_fade_in_shape ();
464 reset_fade_out_shape ();
468 AudioRegionView::reset_fade_in_shape ()
470 reset_fade_in_shape_width ((nframes_t) audio_region()->fade_in().back()->when);
474 AudioRegionView::reset_fade_in_shape_width (nframes_t width)
476 if (fade_in_handle == 0) {
480 /* smallest size for a fade is 64 frames */
482 width = std::max ((nframes_t) 64, width);
485 double pwidth = width / samples_per_unit;
486 uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth);
490 fade_in_shape->hide();
491 fade_in_handle->hide();
495 double handle_center;
496 handle_center = pwidth;
498 if (handle_center > 7.0) {
499 handle_center -= 3.0;
504 fade_in_handle->property_x1() = handle_center - 3.0;
505 fade_in_handle->property_x2() = handle_center + 3.0;
508 fade_in_shape->hide();
512 fade_in_shape->show();
514 float curve[npoints];
515 audio_region()->fade_in().get_vector (0, audio_region()->fade_in().back()->when, curve, npoints);
517 points = get_canvas_points ("fade in shape", npoints+3);
519 if (_height > NAME_HIGHLIGHT_THRESH) {
520 h = _height - NAME_HIGHLIGHT_SIZE;
525 /* points *MUST* be in anti-clockwise order */
528 double xdelta = pwidth/npoints;
530 for (pi = 0, pc = 0; pc < npoints; ++pc) {
531 (*points)[pi].set_x(1 + (pc * xdelta));
532 (*points)[pi++].set_y(2 + (h - (curve[pc] * h)));
537 (*points)[pi].set_x(pwidth);
538 (*points)[pi++].set_y(2);
540 (*points)[pi].set_x(1);
541 (*points)[pi++].set_y(2);
543 /* connect the dots ... */
545 (*points)[pi] = (*points)[0];
547 fade_in_shape->property_points() = *points;
552 AudioRegionView::reset_fade_out_shape ()
554 reset_fade_out_shape_width ((nframes_t) audio_region()->fade_out().back()->when);
558 AudioRegionView::reset_fade_out_shape_width (nframes_t width)
560 if (fade_out_handle == 0) {
564 /* smallest size for a fade is 64 frames */
566 width = std::max ((nframes_t) 64, width);
569 double pwidth = width / samples_per_unit;
570 uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth);
574 fade_out_shape->hide();
575 fade_out_handle->hide();
579 double handle_center;
580 handle_center = (_region->length() - width) / samples_per_unit;
582 if (handle_center > 7.0) {
583 handle_center -= 3.0;
588 fade_out_handle->property_x1() = handle_center - 3.0;
589 fade_out_handle->property_x2() = handle_center + 3.0;
591 /* don't show shape if its too small */
594 fade_out_shape->hide();
598 fade_out_shape->show();
600 float curve[npoints];
601 audio_region()->fade_out().get_vector (0, audio_region()->fade_out().back()->when, curve, npoints);
603 if (_height > NAME_HIGHLIGHT_THRESH) {
604 h = _height - NAME_HIGHLIGHT_SIZE;
609 /* points *MUST* be in anti-clockwise order */
611 points = get_canvas_points ("fade out shape", npoints+3);
614 double xdelta = pwidth/npoints;
616 for (pi = 0, pc = 0; pc < npoints; ++pc) {
617 (*points)[pi].set_x(_pixel_width - 1 - pwidth + (pc*xdelta));
618 (*points)[pi++].set_y(2 + (h - (curve[pc] * h)));
623 (*points)[pi].set_x(_pixel_width);
624 (*points)[pi++].set_y(h);
626 (*points)[pi].set_x(_pixel_width);
627 (*points)[pi++].set_y(2);
629 /* connect the dots ... */
631 (*points)[pi] = (*points)[0];
633 fade_out_shape->property_points() = *points;
638 AudioRegionView::set_samples_per_unit (gdouble spu)
640 RegionView::set_samples_per_unit (spu);
642 if (_flags & WaveformVisible) {
643 for (uint32_t n=0; n < waves.size(); ++n) {
644 waves[n]->property_samples_per_unit() = spu;
652 reset_fade_shapes ();
656 AudioRegionView::set_amplitude_above_axis (gdouble spp)
658 for (uint32_t n=0; n < waves.size(); ++n) {
659 waves[n]->property_amplitude_above_axis() = spp;
664 AudioRegionView::compute_colors (Gdk::Color& basic_color)
666 RegionView::compute_colors(basic_color);
670 /* gain color computed in envelope_active_changed() */
672 UINT_TO_RGBA (fill_color, &r, &g, &b, &a);
673 fade_color = RGBA_TO_UINT(r,g,b,120);
677 AudioRegionView::set_colors ()
679 RegionView::set_colors();
682 gain_line->set_line_color (audio_region()->envelope_active() ? color_map[cGainLine] : color_map[cGainLineInactive]);
685 for (uint32_t n=0; n < waves.size(); ++n) {
686 if (_region->muted()) {
687 waves[n]->property_wave_color() = color_map[cMutedWaveForm];
689 waves[n]->property_wave_color() = color_map[cWaveForm];
692 waves[n]->property_clip_color() = color_map[cWaveFormClip];
693 waves[n]->property_zero_color() = color_map[cZeroLine];
698 AudioRegionView::show_region_editor ()
701 editor = new AudioRegionEditor (trackview.session(), audio_region(), *this);
702 // GTK2FIX : how to ensure float without realizing
703 // editor->realize ();
704 // trackview.editor.ensure_float (*editor);
712 AudioRegionView::set_waveform_visible (bool yn)
714 if (((_flags & WaveformVisible) != yn)) {
716 for (uint32_t n=0; n < waves.size(); ++n) {
717 /* make sure the zoom level is correct, since we don't update
718 this when waveforms are hidden.
720 waves[n]->property_samples_per_unit() = samples_per_unit;
723 _flags |= WaveformVisible;
725 for (uint32_t n=0; n < waves.size(); ++n) {
728 _flags &= ~WaveformVisible;
735 AudioRegionView::temporarily_hide_envelope ()
743 AudioRegionView::unhide_envelope ()
745 if (gain_line && (_flags & EnvelopeVisible)) {
751 AudioRegionView::set_envelope_visible (bool yn)
753 if (gain_line && ((_flags & EnvelopeVisible) != yn)) {
756 _flags |= EnvelopeVisible;
759 _flags &= ~EnvelopeVisible;
766 AudioRegionView::create_waves ()
768 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
770 if (!atv.get_diskstream()) {
774 uint32_t nchans = atv.get_diskstream()->n_channels().n_audio();
776 /* in tmp_waves, set up null pointers for each channel so the vector is allocated */
777 for (uint32_t n = 0; n < nchans; ++n) {
778 tmp_waves.push_back (0);
781 for (uint32_t n = 0; n < nchans; ++n) {
783 if (n >= audio_region()->n_channels()) {
787 wave_caches.push_back (WaveView::create_cache ());
790 if (audio_region()->audio_source(n)->peaks_ready (bind (mem_fun(*this, &AudioRegionView::peaks_ready_handler), n), data_ready_connection)) {
791 create_one_wave (n, true);
795 create_one_wave (n, true);
801 AudioRegionView::create_one_wave (uint32_t which, bool direct)
803 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
804 uint32_t nchans = atv.get_diskstream()->n_channels().n_audio();
806 uint32_t nwaves = std::min (nchans, audio_region()->n_channels());
809 if (trackview.height < NAME_HIGHLIGHT_SIZE) {
810 ht = ((trackview.height) / (double) nchans);
812 ht = ((trackview.height - NAME_HIGHLIGHT_SIZE) / (double) nchans);
815 gdouble yoff = which * ht;
817 WaveView *wave = new WaveView(*group);
819 wave->property_data_src() = (gpointer) _region.get();
820 wave->property_cache() = wave_caches[which];
821 wave->property_cache_updater() = true;
822 wave->property_channel() = which;
823 wave->property_length_function() = (gpointer) region_length_from_c;
824 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
825 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
826 wave->property_x() = 0.0;
827 wave->property_y() = yoff;
828 wave->property_height() = (double) ht;
829 wave->property_samples_per_unit() = samples_per_unit;
830 wave->property_amplitude_above_axis() = _amplitude_above_axis;
831 wave->property_wave_color() = _region->muted() ? color_map[cMutedWaveForm] : color_map[cWaveForm];
832 wave->property_clip_color() = color_map[cWaveFormClip];
833 wave->property_zero_color() = color_map[cZeroLine];
834 wave->property_region_start() = _region->start();
835 wave->property_rectified() = (bool) (_flags & WaveformRectified);
836 wave->property_logscaled() = (bool) (_flags & WaveformLogScaled);
838 if (!(_flags & WaveformVisible)) {
842 /* note: calling this function is serialized by the lock
843 held in the peak building thread that signals that
844 peaks are ready for use *or* by the fact that it is
845 called one by one from the GUI thread.
848 if (which < nchans) {
849 tmp_waves[which] = wave;
851 /* n-channel track, >n-channel source */
854 /* see if we're all ready */
856 for (n = 0; n < nchans; ++n) {
857 if (tmp_waves[n] == 0) {
862 if (n == nwaves && waves.empty()) {
863 /* all waves are ready */
864 tmp_waves.resize(nwaves);
869 /* all waves created, don't hook into peaks ready anymore */
870 data_ready_connection.disconnect ();
874 zero_line = new ArdourCanvas::SimpleLine (*group);
875 zero_line->property_x1() = (gdouble) 1.0;
876 zero_line->property_x2() = (gdouble) (_region->length() / samples_per_unit) - 1.0;
877 zero_line->property_color_rgba() = (guint) color_map[cZeroLine];
884 AudioRegionView::peaks_ready_handler (uint32_t which)
886 Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun(*this, &AudioRegionView::create_one_wave), which, false));
890 AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
892 if (gain_line == 0) {
898 /* don't create points that can't be seen */
900 set_envelope_visible (true);
907 nframes_t fx = trackview.editor.pixel_to_frame (x);
909 if (fx > _region->length()) {
913 /* compute vertical fractional position */
915 y = 1.0 - (y / (trackview.height - NAME_HIGHLIGHT_SIZE));
917 /* map using gain line */
919 gain_line->view_to_model_y (y);
921 trackview.session().begin_reversible_command (_("add gain control point"));
922 XMLNode &before = audio_region()->envelope().get_state();
924 if (!audio_region()->envelope_active()) {
925 XMLNode ®ion_before = audio_region()->get_state();
926 audio_region()->set_envelope_active(true);
927 XMLNode ®ion_after = audio_region()->get_state();
928 trackview.session().add_command (new MementoCommand<AudioRegion>(*(audio_region().get()), ®ion_before, ®ion_after));
931 audio_region()->envelope().add (fx, y);
933 XMLNode &after = audio_region()->envelope().get_state();
934 trackview.session().add_command (new MementoCommand<Curve>(audio_region()->envelope(), &before, &after));
935 trackview.session().commit_reversible_command ();
939 AudioRegionView::remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
941 ControlPoint *cp = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"));
942 audio_region()->envelope().erase (cp->model);
946 AudioRegionView::store_flags()
948 XMLNode *node = new XMLNode ("GUI");
950 node->add_property ("waveform-visible", (_flags & WaveformVisible) ? "yes" : "no");
951 node->add_property ("envelope-visible", (_flags & EnvelopeVisible) ? "yes" : "no");
952 node->add_property ("waveform-rectified", (_flags & WaveformRectified) ? "yes" : "no");
953 node->add_property ("waveform-logscaled", (_flags & WaveformLogScaled) ? "yes" : "no");
955 _region->add_extra_xml (*node);
959 AudioRegionView::set_flags (XMLNode* node)
963 if ((prop = node->property ("waveform-visible")) != 0) {
964 if (prop->value() == "yes") {
965 _flags |= WaveformVisible;
969 if ((prop = node->property ("envelope-visible")) != 0) {
970 if (prop->value() == "yes") {
971 _flags |= EnvelopeVisible;
975 if ((prop = node->property ("waveform-rectified")) != 0) {
976 if (prop->value() == "yes") {
977 _flags |= WaveformRectified;
981 if ((prop = node->property ("waveform-logscaled")) != 0) {
982 if (prop->value() == "yes") {
983 _flags |= WaveformLogScaled;
989 AudioRegionView::set_waveform_shape (WaveformShape shape)
993 /* this slightly odd approach is to leave the door open to
994 other "shapes" such as spectral displays, etc.
1007 if (yn != (bool) (_flags & WaveformRectified)) {
1008 for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
1009 (*wave)->property_rectified() = yn;
1021 _flags |= WaveformRectified;
1023 _flags &= ~WaveformRectified;
1030 AudioRegionView::set_waveform_scale (WaveformScale scale)
1032 bool yn = (scale == LogWaveform);
1034 if (yn != (bool) (_flags & WaveformLogScaled)) {
1035 for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
1036 (*wave)->property_logscaled() = yn;
1040 _flags |= WaveformLogScaled;
1042 _flags &= ~WaveformLogScaled;
1050 AudioRegionView::add_ghost (AutomationTimeAxisView& atv)
1052 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&trackview);
1055 double unit_position = _region->position () / samples_per_unit;
1056 GhostRegion* ghost = new GhostRegion (atv, unit_position);
1059 nchans = rtv->get_diskstream()->n_channels().n_audio();
1061 for (uint32_t n = 0; n < nchans; ++n) {
1063 if (n >= audio_region()->n_channels()) {
1067 WaveView *wave = new WaveView(*ghost->group);
1069 wave->property_data_src() = _region.get();
1070 wave->property_cache() = wave_caches[n];
1071 wave->property_cache_updater() = false;
1072 wave->property_channel() = n;
1073 wave->property_length_function() = (gpointer)region_length_from_c;
1074 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
1075 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
1076 wave->property_x() = 0.0;
1077 wave->property_samples_per_unit() = samples_per_unit;
1078 wave->property_amplitude_above_axis() = _amplitude_above_axis;
1079 wave->property_wave_color() = color_map[cGhostTrackWave];
1080 wave->property_clip_color() = color_map[cGhostTrackWaveClip];
1081 wave->property_zero_color() = color_map[cGhostTrackZeroLine];
1082 wave->property_region_start() = _region->start();
1084 ghost->waves.push_back(wave);
1087 ghost->set_height ();
1088 ghost->set_duration (_region->length() / samples_per_unit);
1089 ghosts.push_back (ghost);
1091 ghost->GoingAway.connect (mem_fun(*this, &AudioRegionView::remove_ghost));
1097 AudioRegionView::entered ()
1099 if (gain_line && _flags & EnvelopeVisible) {
1100 gain_line->show_all_control_points ();
1104 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
1107 if (fade_in_handle) {
1108 fade_in_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1109 fade_out_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1114 AudioRegionView::exited ()
1117 gain_line->hide_all_but_selected_control_points ();
1121 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
1124 if (fade_in_handle) {
1125 fade_in_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1126 fade_out_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1131 AudioRegionView::envelope_active_changed ()
1134 gain_line->set_line_color (audio_region()->envelope_active() ? color_map[cGainLine] : color_map[cGainLineInactive]);
1139 AudioRegionView::set_waveview_data_src()
1142 double unit_length= _region->length() / samples_per_unit;
1144 for (uint32_t n = 0; n < waves.size(); ++n) {
1145 // TODO: something else to let it know the channel
1146 waves[n]->property_data_src() = _region.get();
1149 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
1151 (*i)->set_duration (unit_length);
1153 for (vector<WaveView*>::iterator w = (*i)->waves.begin(); w != (*i)->waves.end(); ++w) {
1154 (*w)->property_data_src() = _region.get();
1161 AudioRegionView::color_handler (ColorID id, uint32_t val)
1164 case cMutedWaveForm:
1171 case cGainLineInactive:
1173 envelope_active_changed();