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.
26 #include <gtkmm2ext/gtk_ui.h>
28 #include <ardour/playlist.h>
29 #include <ardour/audioregion.h>
30 #include <ardour/audiosource.h>
31 #include <ardour/audio_diskstream.h>
32 #include <pbd/memento_command.h>
33 #include <pbd/stacktrace.h>
35 #include "streamview.h"
36 #include "audio_region_view.h"
37 #include "audio_time_axis.h"
38 #include "simplerect.h"
39 #include "simpleline.h"
41 #include "public_editor.h"
42 #include "audio_region_editor.h"
43 #include "region_gain_line.h"
44 #include "ghostregion.h"
45 #include "audio_time_axis.h"
47 #include "rgb_macros.h"
48 #include "gui_thread.h"
53 using namespace ARDOUR;
55 using namespace Editing;
56 using namespace ArdourCanvas;
58 static const int32_t sync_mark_width = 9;
60 AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, boost::shared_ptr<AudioRegion> r, double spu,
61 Gdk::Color& basic_color)
62 : RegionView (parent, tv, r, spu, basic_color)
70 , _amplitude_above_axis(1.0)
76 AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, boost::shared_ptr<AudioRegion> r, double spu,
77 Gdk::Color& basic_color, TimeAxisViewItem::Visibility visibility)
78 : RegionView (parent, tv, r, spu, basic_color, visibility)
86 , _amplitude_above_axis(1.0)
93 AudioRegionView::AudioRegionView (const AudioRegionView& other)
101 , _amplitude_above_axis(1.0)
109 UINT_TO_RGBA (other.fill_color, &r, &g, &b, &a);
110 c.set_rgb_p (r/255.0, g/255.0, b/255.0);
116 AudioRegionView::init (Gdk::Color& basic_color, bool wfd)
118 // FIXME: Some redundancy here with RegionView::init. Need to figure out
119 // where order is important and where it isn't...
121 RegionView::init(basic_color, false);
125 _amplitude_above_axis = 1.0;
129 if ((node = _region->extra_xml ("GUI")) != 0) {
132 _flags = WaveformVisible;
136 if (trackview.editor.new_regionviews_display_gain()) {
137 _flags |= EnvelopeVisible;
140 compute_colors (basic_color);
144 fade_in_shape = new ArdourCanvas::Polygon (*group);
145 fade_in_shape->property_fill_color_rgba() = fade_color;
146 fade_in_shape->set_data ("regionview", this);
148 fade_out_shape = new ArdourCanvas::Polygon (*group);
149 fade_out_shape->property_fill_color_rgba() = fade_color;
150 fade_out_shape->set_data ("regionview", this);
155 UINT_TO_RGBA(fill_color,&r,&g,&b,&a);
158 fade_in_handle = new ArdourCanvas::SimpleRect (*group);
159 fade_in_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,0);
160 fade_in_handle->property_outline_pixels() = 0;
161 fade_in_handle->property_y1() = 2.0;
162 fade_in_handle->property_y2() = 7.0;
164 fade_in_handle->set_data ("regionview", this);
166 fade_out_handle = new ArdourCanvas::SimpleRect (*group);
167 fade_out_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,0);
168 fade_out_handle->property_outline_pixels() = 0;
169 fade_out_handle->property_y1() = 2.0;
170 fade_out_handle->property_y2() = 7.0;
172 fade_out_handle->set_data ("regionview", this);
175 string foo = _region->name();
179 gain_line = new AudioRegionGainLine (foo, trackview.session(), *this, *group, audio_region()->envelope());
181 if (!(_flags & EnvelopeVisible)) {
189 set_height (trackview.height);
192 region_sync_changed ();
193 region_resized (BoundsChanged);
194 set_waveview_data_src();
196 envelope_active_changed ();
197 fade_in_active_changed ();
198 fade_out_active_changed ();
200 _region->StateChanged.connect (mem_fun(*this, &AudioRegionView::region_changed));
202 fade_in_shape->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_event), fade_in_shape, this));
203 fade_in_handle->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_handle_event), fade_in_handle, this));
204 fade_out_shape->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_event), fade_out_shape, this));
205 fade_out_handle->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_handle_event), fade_out_handle, this));
209 /* XXX sync mark drag? */
212 AudioRegionView::~AudioRegionView ()
214 in_destructor = true;
216 RegionViewGoingAway (this); /* EMIT_SIGNAL */
218 for (vector<GnomeCanvasWaveViewCache *>::iterator cache = wave_caches.begin(); cache != wave_caches.end() ; ++cache) {
219 gnome_canvas_waveview_cache_destroy (*cache);
222 /* all waveviews etc will be destroyed when the group is destroyed */
229 boost::shared_ptr<ARDOUR::AudioRegion>
230 AudioRegionView::audio_region() const
232 // "Guaranteed" to succeed...
233 return boost::dynamic_pointer_cast<AudioRegion>(_region);
237 AudioRegionView::region_changed (Change what_changed)
239 ENSURE_GUI_THREAD (bind (mem_fun(*this, &AudioRegionView::region_changed), what_changed));
241 RegionView::region_changed(what_changed);
243 if (what_changed & AudioRegion::ScaleAmplitudeChanged) {
244 region_scale_amplitude_changed ();
246 if (what_changed & AudioRegion::FadeInChanged) {
249 if (what_changed & AudioRegion::FadeOutChanged) {
252 if (what_changed & AudioRegion::FadeInActiveChanged) {
253 fade_in_active_changed ();
255 if (what_changed & AudioRegion::FadeOutActiveChanged) {
256 fade_out_active_changed ();
258 if (what_changed & AudioRegion::EnvelopeActiveChanged) {
259 envelope_active_changed ();
264 AudioRegionView::fade_in_changed ()
266 reset_fade_in_shape ();
270 AudioRegionView::fade_out_changed ()
272 reset_fade_out_shape ();
275 AudioRegionView::fade_in_active_changed ()
279 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
281 if (audio_region()->fade_in_active()) {
282 col = RGBA_TO_UINT(r,g,b,120);
283 fade_in_shape->property_fill_color_rgba() = col;
284 fade_in_shape->property_width_pixels() = 0;
285 fade_in_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,0);
287 col = RGBA_TO_UINT(r,g,b,0);
288 fade_in_shape->property_fill_color_rgba() = col;
289 fade_in_shape->property_width_pixels() = 1;
290 fade_in_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,255);
295 AudioRegionView::fade_out_active_changed ()
299 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
301 if (audio_region()->fade_out_active()) {
302 col = RGBA_TO_UINT(r,g,b,120);
303 fade_out_shape->property_fill_color_rgba() = col;
304 fade_out_shape->property_width_pixels() = 0;
305 fade_out_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,0);
307 col = RGBA_TO_UINT(r,g,b,0);
308 fade_out_shape->property_fill_color_rgba() = col;
309 fade_out_shape->property_width_pixels() = 1;
310 fade_out_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,255);
316 AudioRegionView::region_scale_amplitude_changed ()
318 ENSURE_GUI_THREAD (mem_fun(*this, &AudioRegionView::region_scale_amplitude_changed));
320 for (uint32_t n = 0; n < waves.size(); ++n) {
321 // force a reload of the cache
322 waves[n]->property_data_src() = _region.get();
327 AudioRegionView::region_resized (Change what_changed)
329 RegionView::region_resized(what_changed);
331 if (what_changed & Change (StartChanged|LengthChanged)) {
333 for (uint32_t n = 0; n < waves.size(); ++n) {
334 waves[n]->property_region_start() = _region->start();
337 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
339 for (vector<WaveView*>::iterator w = (*i)->waves.begin(); w != (*i)->waves.end(); ++w) {
340 (*w)->property_region_start() = _region->start();
347 AudioRegionView::reset_width_dependent_items (double pixel_width)
349 RegionView::reset_width_dependent_items(pixel_width);
350 assert(_pixel_width == pixel_width);
353 zero_line->property_x2() = pixel_width - 1.0;
356 if (fade_in_handle) {
357 if (pixel_width <= 6.0) {
358 fade_in_handle->hide();
359 fade_out_handle->hide();
362 fade_in_handle->hide();
363 fade_out_handle->hide();
365 fade_in_handle->show();
366 fade_out_handle->show();
371 reset_fade_shapes ();
375 AudioRegionView::region_muted ()
377 RegionView::region_muted();
379 for (uint32_t n=0; n < waves.size(); ++n) {
380 if (_region->muted()) {
381 waves[n]->property_wave_color() = color_map[cMutedWaveForm];
383 waves[n]->property_wave_color() = color_map[cWaveForm];
390 AudioRegionView::set_height (gdouble height)
392 uint32_t wcnt = waves.size();
395 TimeAxisViewItem::set_height (height - 2);
399 for (uint32_t n=0; n < wcnt; ++n) {
402 if ((height) <= NAME_HIGHLIGHT_THRESH) {
403 ht = ((height-2*wcnt) / (double) wcnt);
405 ht = (((height-2*wcnt) - NAME_HIGHLIGHT_SIZE) / (double) wcnt);
408 gdouble yoff = n * (ht+1);
410 waves[n]->property_height() = ht;
411 waves[n]->property_y() = yoff + 2;
415 if ((height/wcnt) < NAME_HIGHLIGHT_SIZE) {
418 if (_flags & EnvelopeVisible) {
422 gain_line->set_height ((uint32_t) rint (height - NAME_HIGHLIGHT_SIZE));
426 reset_fade_shapes ();
429 name_text->raise_to_top();
434 AudioRegionView::manage_zero_line ()
440 if (_height >= 100) {
441 gdouble wave_midpoint = (_height - NAME_HIGHLIGHT_SIZE) / 2.0;
442 zero_line->property_y1() = wave_midpoint;
443 zero_line->property_y2() = wave_midpoint;
451 AudioRegionView::reset_fade_shapes ()
453 reset_fade_in_shape ();
454 reset_fade_out_shape ();
458 AudioRegionView::reset_fade_in_shape ()
460 reset_fade_in_shape_width ((nframes_t) audio_region()->fade_in().back()->when);
464 AudioRegionView::reset_fade_in_shape_width (nframes_t width)
466 if (fade_in_handle == 0) {
470 /* smallest size for a fade is 64 frames */
472 width = std::max ((nframes_t) 64, width);
475 double pwidth = width / samples_per_unit;
476 uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth);
480 fade_in_shape->hide();
481 fade_in_handle->hide();
485 double handle_center;
486 handle_center = pwidth;
488 if (handle_center > 7.0) {
489 handle_center -= 3.0;
494 fade_in_handle->property_x1() = handle_center - 3.0;
495 fade_in_handle->property_x2() = handle_center + 3.0;
498 fade_in_shape->hide();
502 fade_in_shape->show();
504 float curve[npoints];
505 audio_region()->fade_in().get_vector (0, audio_region()->fade_in().back()->when, curve, npoints);
507 points = get_canvas_points ("fade in shape", npoints+3);
509 if (_height > NAME_HIGHLIGHT_THRESH) {
510 h = _height - NAME_HIGHLIGHT_SIZE;
515 /* points *MUST* be in anti-clockwise order */
518 double xdelta = pwidth/npoints;
520 for (pi = 0, pc = 0; pc < npoints; ++pc) {
521 (*points)[pi].set_x(1 + (pc * xdelta));
522 (*points)[pi++].set_y(2 + (h - (curve[pc] * h)));
527 (*points)[pi].set_x(pwidth);
528 (*points)[pi++].set_y(2);
530 (*points)[pi].set_x(1);
531 (*points)[pi++].set_y(2);
533 /* connect the dots ... */
535 (*points)[pi] = (*points)[0];
537 fade_in_shape->property_points() = *points;
542 AudioRegionView::reset_fade_out_shape ()
544 reset_fade_out_shape_width ((nframes_t) audio_region()->fade_out().back()->when);
548 AudioRegionView::reset_fade_out_shape_width (nframes_t width)
550 if (fade_out_handle == 0) {
554 /* smallest size for a fade is 64 frames */
556 width = std::max ((nframes_t) 64, width);
559 double pwidth = width / samples_per_unit;
560 uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth);
564 fade_out_shape->hide();
565 fade_out_handle->hide();
569 double handle_center;
570 handle_center = (_region->length() - width) / samples_per_unit;
572 if (handle_center > 7.0) {
573 handle_center -= 3.0;
578 fade_out_handle->property_x1() = handle_center - 3.0;
579 fade_out_handle->property_x2() = handle_center + 3.0;
581 /* don't show shape if its too small */
584 fade_out_shape->hide();
588 fade_out_shape->show();
590 float curve[npoints];
591 audio_region()->fade_out().get_vector (0, audio_region()->fade_out().back()->when, curve, npoints);
593 if (_height > NAME_HIGHLIGHT_THRESH) {
594 h = _height - NAME_HIGHLIGHT_SIZE;
599 /* points *MUST* be in anti-clockwise order */
601 points = get_canvas_points ("fade out shape", npoints+3);
604 double xdelta = pwidth/npoints;
606 for (pi = 0, pc = 0; pc < npoints; ++pc) {
607 (*points)[pi].set_x(_pixel_width - 1 - pwidth + (pc*xdelta));
608 (*points)[pi++].set_y(2 + (h - (curve[pc] * h)));
613 (*points)[pi].set_x(_pixel_width);
614 (*points)[pi++].set_y(h);
616 (*points)[pi].set_x(_pixel_width);
617 (*points)[pi++].set_y(2);
619 /* connect the dots ... */
621 (*points)[pi] = (*points)[0];
623 fade_out_shape->property_points() = *points;
628 AudioRegionView::set_samples_per_unit (gdouble spu)
630 RegionView::set_samples_per_unit (spu);
632 if (_flags & WaveformVisible) {
633 for (uint32_t n=0; n < waves.size(); ++n) {
634 waves[n]->property_samples_per_unit() = spu;
642 reset_fade_shapes ();
646 AudioRegionView::set_amplitude_above_axis (gdouble spp)
648 for (uint32_t n=0; n < waves.size(); ++n) {
649 waves[n]->property_amplitude_above_axis() = spp;
654 AudioRegionView::compute_colors (Gdk::Color& basic_color)
656 RegionView::compute_colors(basic_color);
660 /* gain color computed in envelope_active_changed() */
662 UINT_TO_RGBA (fill_color, &r, &g, &b, &a);
663 fade_color = RGBA_TO_UINT(r,g,b,120);
667 AudioRegionView::set_colors ()
669 RegionView::set_colors();
672 gain_line->set_line_color (audio_region()->envelope_active() ? color_map[cGainLine] : color_map[cGainLineInactive]);
675 for (uint32_t n=0; n < waves.size(); ++n) {
676 if (_region->muted()) {
677 waves[n]->property_wave_color() = color_map[cMutedWaveForm];
679 waves[n]->property_wave_color() = color_map[cWaveForm];
682 waves[n]->property_clip_color() = color_map[cWaveFormClip];
683 waves[n]->property_zero_color() = color_map[cZeroLine];
688 AudioRegionView::show_region_editor ()
691 editor = new AudioRegionEditor (trackview.session(), audio_region(), *this);
692 // GTK2FIX : how to ensure float without realizing
693 // editor->realize ();
694 // trackview.editor.ensure_float (*editor);
702 AudioRegionView::set_waveform_visible (bool yn)
704 if (((_flags & WaveformVisible) != yn)) {
706 for (uint32_t n=0; n < waves.size(); ++n) {
707 /* make sure the zoom level is correct, since we don't update
708 this when waveforms are hidden.
710 waves[n]->property_samples_per_unit() = samples_per_unit;
713 _flags |= WaveformVisible;
715 for (uint32_t n=0; n < waves.size(); ++n) {
718 _flags &= ~WaveformVisible;
725 AudioRegionView::temporarily_hide_envelope ()
733 AudioRegionView::unhide_envelope ()
735 if (gain_line && (_flags & EnvelopeVisible)) {
741 AudioRegionView::set_envelope_visible (bool yn)
743 if (gain_line && ((_flags & EnvelopeVisible) != yn)) {
746 _flags |= EnvelopeVisible;
749 _flags &= ~EnvelopeVisible;
756 AudioRegionView::create_waves ()
758 bool create_zero_line = false;
760 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
762 if (!atv.get_diskstream()) {
766 uint32_t nchans = atv.get_diskstream()->n_channels();
768 /* in tmp_waves, set up null pointers for each channel so the vector is allocated */
769 for (uint32_t n = 0; n < nchans; ++n) {
770 tmp_waves.push_back (0);
773 for (uint32_t n = 0; n < nchans; ++n) {
775 if (n >= audio_region()->n_channels()) {
779 wave_caches.push_back (WaveView::create_cache ());
782 if (audio_region()->source(n)->peaks_ready (bind (mem_fun(*this, &AudioRegionView::peaks_ready_handler), n), data_ready_connection)) {
783 create_one_wave (n, true);
785 create_zero_line = false;
788 create_one_wave (n, true);
793 //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();
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_clip_color() = color_map[cWaveFormClip];
839 wave->property_zero_color() = color_map[cZeroLine];
840 wave->property_region_start() = _region->start();
841 wave->property_rectified() = (bool) (_flags & WaveformRectified);
842 wave->property_logscaled() = (bool) (_flags & WaveformLogScaled);
844 if (!(_flags & WaveformVisible)) {
848 /* note: calling this function is serialized by the lock
849 held in the peak building thread that signals that
850 peaks are ready for use *or* by the fact that it is
851 called one by one from the GUI thread.
854 if (which < nchans) {
855 tmp_waves[which] = wave;
857 /* n-channel track, >n-channel source */
860 /* see if we're all ready */
862 for (n = 0; n < nchans; ++n) {
863 if (tmp_waves[n] == 0) {
868 if (n == nwaves && waves.empty()) {
869 /* all waves are ready */
870 tmp_waves.resize(nwaves);
875 /* all waves created, don't hook into peaks ready anymore */
876 data_ready_connection.disconnect ();
880 zero_line = new ArdourCanvas::SimpleLine (*group);
881 zero_line->property_x1() = (gdouble) 1.0;
882 zero_line->property_x2() = (gdouble) (_region->length() / samples_per_unit) - 1.0;
883 zero_line->property_color_rgba() = (guint) color_map[cZeroLine];
890 AudioRegionView::peaks_ready_handler (uint32_t which)
892 Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun(*this, &AudioRegionView::create_one_wave), which, false));
896 AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
898 if (gain_line == 0) {
904 /* don't create points that can't be seen */
906 set_envelope_visible (true);
913 nframes_t fx = trackview.editor.pixel_to_frame (x);
915 if (fx > _region->length()) {
919 /* compute vertical fractional position */
921 y = 1.0 - (y / (trackview.height - NAME_HIGHLIGHT_SIZE));
923 /* map using gain line */
925 gain_line->view_to_model_y (y);
927 trackview.session().begin_reversible_command (_("add gain control point"));
928 XMLNode &before = audio_region()->envelope().get_state();
930 if (!audio_region()->envelope_active()) {
931 XMLNode ®ion_before = audio_region()->get_state();
932 audio_region()->set_envelope_active(true);
933 XMLNode ®ion_after = audio_region()->get_state();
934 trackview.session().add_command (new MementoCommand<AudioRegion>(*(audio_region().get()), ®ion_before, ®ion_after));
937 audio_region()->envelope().add (fx, y);
939 XMLNode &after = audio_region()->envelope().get_state();
940 trackview.session().add_command (new MementoCommand<Curve>(audio_region()->envelope(), &before, &after));
941 trackview.session().commit_reversible_command ();
945 AudioRegionView::remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
947 ControlPoint *cp = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"));
948 audio_region()->envelope().erase (cp->model);
952 AudioRegionView::store_flags()
954 XMLNode *node = new XMLNode ("GUI");
956 node->add_property ("waveform-visible", (_flags & WaveformVisible) ? "yes" : "no");
957 node->add_property ("envelope-visible", (_flags & EnvelopeVisible) ? "yes" : "no");
958 node->add_property ("waveform-rectified", (_flags & WaveformRectified) ? "yes" : "no");
959 node->add_property ("waveform-logscaled", (_flags & WaveformLogScaled) ? "yes" : "no");
961 _region->add_extra_xml (*node);
965 AudioRegionView::set_flags (XMLNode* node)
969 if ((prop = node->property ("waveform-visible")) != 0) {
970 if (prop->value() == "yes") {
971 _flags |= WaveformVisible;
975 if ((prop = node->property ("envelope-visible")) != 0) {
976 if (prop->value() == "yes") {
977 _flags |= EnvelopeVisible;
981 if ((prop = node->property ("waveform-rectified")) != 0) {
982 if (prop->value() == "yes") {
983 _flags |= WaveformRectified;
987 if ((prop = node->property ("waveform-logscaled")) != 0) {
988 if (prop->value() == "yes") {
989 _flags |= WaveformLogScaled;
995 AudioRegionView::set_waveform_shape (WaveformShape shape)
999 /* this slightly odd approach is to leave the door open to
1000 other "shapes" such as spectral displays, etc.
1013 if (yn != (bool) (_flags & WaveformRectified)) {
1014 for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
1015 (*wave)->property_rectified() = yn;
1027 _flags |= WaveformRectified;
1029 _flags &= ~WaveformRectified;
1036 AudioRegionView::set_waveform_scale (WaveformScale scale)
1038 bool yn = (scale == LogWaveform);
1040 if (yn != (bool) (_flags & WaveformLogScaled)) {
1041 for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
1042 (*wave)->property_logscaled() = yn;
1046 _flags |= WaveformLogScaled;
1048 _flags &= ~WaveformLogScaled;
1056 AudioRegionView::add_ghost (AutomationTimeAxisView& atv)
1058 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&trackview);
1061 double unit_position = _region->position () / samples_per_unit;
1062 GhostRegion* ghost = new GhostRegion (atv, unit_position);
1065 nchans = rtv->get_diskstream()->n_channels();
1067 for (uint32_t n = 0; n < nchans; ++n) {
1069 if (n >= audio_region()->n_channels()) {
1073 WaveView *wave = new WaveView(*ghost->group);
1075 wave->property_data_src() = _region.get();
1076 wave->property_cache() = wave_caches[n];
1077 wave->property_cache_updater() = false;
1078 wave->property_channel() = n;
1079 wave->property_length_function() = (gpointer)region_length_from_c;
1080 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
1081 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
1082 wave->property_x() = 0.0;
1083 wave->property_samples_per_unit() = samples_per_unit;
1084 wave->property_amplitude_above_axis() = _amplitude_above_axis;
1085 wave->property_wave_color() = color_map[cGhostTrackWave];
1086 wave->property_clip_color() = color_map[cGhostTrackWaveClip];
1087 wave->property_zero_color() = color_map[cGhostTrackZeroLine];
1088 wave->property_region_start() = _region->start();
1090 ghost->waves.push_back(wave);
1093 ghost->set_height ();
1094 ghost->set_duration (_region->length() / samples_per_unit);
1095 ghosts.push_back (ghost);
1097 ghost->GoingAway.connect (mem_fun(*this, &AudioRegionView::remove_ghost));
1103 AudioRegionView::entered ()
1105 if (gain_line && _flags & EnvelopeVisible) {
1106 gain_line->show_all_control_points ();
1110 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
1113 if (fade_in_handle) {
1114 fade_in_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1115 fade_out_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1120 AudioRegionView::exited ()
1123 gain_line->hide_all_but_selected_control_points ();
1127 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
1130 if (fade_in_handle) {
1131 fade_in_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1132 fade_out_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1137 AudioRegionView::envelope_active_changed ()
1140 gain_line->set_line_color (audio_region()->envelope_active() ? color_map[cGainLine] : color_map[cGainLineInactive]);
1145 AudioRegionView::set_waveview_data_src()
1148 double unit_length= _region->length() / samples_per_unit;
1150 for (uint32_t n = 0; n < waves.size(); ++n) {
1151 // TODO: something else to let it know the channel
1152 waves[n]->property_data_src() = _region.get();
1155 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
1157 (*i)->set_duration (unit_length);
1159 for (vector<WaveView*>::iterator w = (*i)->waves.begin(); w != (*i)->waves.end(); ++w) {
1160 (*w)->property_data_src() = _region.get();
1167 AudioRegionView::color_handler (ColorID id, uint32_t val)
1170 case cMutedWaveForm:
1173 case cGhostTrackWave:
1174 case cGhostTrackWaveClip:
1179 case cGainLineInactive:
1181 envelope_active_changed();