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"
49 #include "ardour_ui.h"
53 #define MUTED_ALPHA 0x50
56 using namespace ARDOUR;
58 using namespace Editing;
59 using namespace ArdourCanvas;
61 static const int32_t sync_mark_width = 9;
63 AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, boost::shared_ptr<AudioRegion> r, double spu,
64 Gdk::Color& basic_color)
65 : RegionView (parent, tv, r, spu, basic_color)
73 , _amplitude_above_axis(1.0)
79 AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, boost::shared_ptr<AudioRegion> r, double spu,
80 Gdk::Color& basic_color, TimeAxisViewItem::Visibility visibility)
81 : RegionView (parent, tv, r, spu, basic_color, visibility)
89 , _amplitude_above_axis(1.0)
96 AudioRegionView::AudioRegionView (const AudioRegionView& other)
104 , _amplitude_above_axis(1.0)
112 UINT_TO_RGBA (other.fill_color, &r, &g, &b, &a);
113 c.set_rgb_p (r/255.0, g/255.0, b/255.0);
119 AudioRegionView::init (Gdk::Color& basic_color, bool wfd)
121 // FIXME: Some redundancy here with RegionView::init. Need to figure out
122 // where order is important and where it isn't...
124 RegionView::init(basic_color, false);
128 _amplitude_above_axis = 1.0;
132 if ((node = _region->extra_xml ("GUI")) != 0) {
135 _flags = WaveformVisible;
139 if (trackview.editor.new_regionviews_display_gain()) {
140 _flags |= EnvelopeVisible;
143 compute_colors (basic_color);
147 fade_in_shape = new ArdourCanvas::Polygon (*group);
148 fade_in_shape->property_fill_color_rgba() = fade_color;
149 fade_in_shape->set_data ("regionview", this);
151 fade_out_shape = new ArdourCanvas::Polygon (*group);
152 fade_out_shape->property_fill_color_rgba() = fade_color;
153 fade_out_shape->set_data ("regionview", this);
158 UINT_TO_RGBA(fill_color,&r,&g,&b,&a);
161 fade_in_handle = new ArdourCanvas::SimpleRect (*group);
162 fade_in_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,0);
163 fade_in_handle->property_outline_pixels() = 0;
164 fade_in_handle->property_y1() = 2.0;
165 fade_in_handle->property_y2() = 7.0;
167 fade_in_handle->set_data ("regionview", this);
169 fade_out_handle = new ArdourCanvas::SimpleRect (*group);
170 fade_out_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,0);
171 fade_out_handle->property_outline_pixels() = 0;
172 fade_out_handle->property_y1() = 2.0;
173 fade_out_handle->property_y2() = 7.0;
175 fade_out_handle->set_data ("regionview", this);
178 string foo = _region->name();
182 gain_line = new AudioRegionGainLine (foo, trackview.session(), *this, *group, audio_region()->envelope());
184 if (!(_flags & EnvelopeVisible)) {
192 set_height (trackview.height);
195 region_sync_changed ();
196 region_resized (BoundsChanged);
197 set_waveview_data_src();
199 envelope_active_changed ();
200 fade_in_active_changed ();
201 fade_out_active_changed ();
203 _region->StateChanged.connect (mem_fun(*this, &AudioRegionView::region_changed));
205 fade_in_shape->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_event), fade_in_shape, this));
206 fade_in_handle->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_handle_event), fade_in_handle, this));
207 fade_out_shape->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_event), fade_out_shape, this));
208 fade_out_handle->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_handle_event), fade_out_handle, this));
212 /* XXX sync mark drag? */
215 AudioRegionView::~AudioRegionView ()
217 in_destructor = true;
219 RegionViewGoingAway (this); /* EMIT_SIGNAL */
221 for (vector<GnomeCanvasWaveViewCache *>::iterator cache = wave_caches.begin(); cache != wave_caches.end() ; ++cache) {
222 gnome_canvas_waveview_cache_destroy (*cache);
225 /* all waveviews etc will be destroyed when the group is destroyed */
232 boost::shared_ptr<ARDOUR::AudioRegion>
233 AudioRegionView::audio_region() const
235 // "Guaranteed" to succeed...
236 return boost::dynamic_pointer_cast<AudioRegion>(_region);
240 AudioRegionView::region_changed (Change what_changed)
242 ENSURE_GUI_THREAD (bind (mem_fun(*this, &AudioRegionView::region_changed), what_changed));
244 RegionView::region_changed(what_changed);
246 if (what_changed & AudioRegion::ScaleAmplitudeChanged) {
247 region_scale_amplitude_changed ();
249 if (what_changed & AudioRegion::FadeInChanged) {
252 if (what_changed & AudioRegion::FadeOutChanged) {
255 if (what_changed & AudioRegion::FadeInActiveChanged) {
256 fade_in_active_changed ();
258 if (what_changed & AudioRegion::FadeOutActiveChanged) {
259 fade_out_active_changed ();
261 if (what_changed & AudioRegion::EnvelopeActiveChanged) {
262 envelope_active_changed ();
267 AudioRegionView::fade_in_changed ()
269 reset_fade_in_shape ();
273 AudioRegionView::fade_out_changed ()
275 reset_fade_out_shape ();
278 AudioRegionView::fade_in_active_changed ()
282 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
284 if (audio_region()->fade_in_active()) {
285 col = RGBA_TO_UINT(r,g,b,120);
286 fade_in_shape->property_fill_color_rgba() = col;
287 fade_in_shape->property_width_pixels() = 0;
288 fade_in_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,0);
290 col = RGBA_TO_UINT(r,g,b,0);
291 fade_in_shape->property_fill_color_rgba() = col;
292 fade_in_shape->property_width_pixels() = 1;
293 fade_in_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,255);
298 AudioRegionView::fade_out_active_changed ()
302 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
304 if (audio_region()->fade_out_active()) {
305 col = RGBA_TO_UINT(r,g,b,120);
306 fade_out_shape->property_fill_color_rgba() = col;
307 fade_out_shape->property_width_pixels() = 0;
308 fade_out_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,0);
310 col = RGBA_TO_UINT(r,g,b,0);
311 fade_out_shape->property_fill_color_rgba() = col;
312 fade_out_shape->property_width_pixels() = 1;
313 fade_out_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,255);
319 AudioRegionView::region_scale_amplitude_changed ()
321 ENSURE_GUI_THREAD (mem_fun(*this, &AudioRegionView::region_scale_amplitude_changed));
323 for (uint32_t n = 0; n < waves.size(); ++n) {
324 // force a reload of the cache
325 waves[n]->property_data_src() = _region.get();
330 AudioRegionView::region_resized (Change what_changed)
332 RegionView::region_resized(what_changed);
334 if (what_changed & Change (StartChanged|LengthChanged)) {
336 for (uint32_t n = 0; n < waves.size(); ++n) {
337 waves[n]->property_region_start() = _region->start();
340 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
342 for (vector<WaveView*>::iterator w = (*i)->waves.begin(); w != (*i)->waves.end(); ++w) {
343 (*w)->property_region_start() = _region->start();
350 AudioRegionView::reset_width_dependent_items (double pixel_width)
352 RegionView::reset_width_dependent_items(pixel_width);
353 assert(_pixel_width == pixel_width);
356 zero_line->property_x2() = pixel_width - 1.0;
359 if (fade_in_handle) {
360 if (pixel_width <= 6.0) {
361 fade_in_handle->hide();
362 fade_out_handle->hide();
365 fade_in_handle->hide();
366 fade_out_handle->hide();
368 fade_in_handle->show();
369 fade_out_handle->show();
374 reset_fade_shapes ();
378 AudioRegionView::region_muted ()
380 RegionView::region_muted();
382 for (uint32_t n=0; n < waves.size(); ++n) {
383 if (_region->muted()) {
384 waves[n]->property_wave_color() = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_WaveForm.get(), MUTED_ALPHA);
386 waves[n]->property_wave_color() = ARDOUR_UI::config()->canvasvar_WaveForm.get();
393 AudioRegionView::set_height (gdouble height)
395 uint32_t wcnt = waves.size();
398 TimeAxisViewItem::set_height (height - 2);
402 for (uint32_t n=0; n < wcnt; ++n) {
405 if ((height) <= NAME_HIGHLIGHT_THRESH) {
406 ht = ((height-2*wcnt) / (double) wcnt);
408 ht = (((height-2*wcnt) - NAME_HIGHLIGHT_SIZE) / (double) wcnt);
411 gdouble yoff = n * (ht+1);
413 waves[n]->property_height() = ht;
414 waves[n]->property_y() = yoff + 2;
418 if ((height/wcnt) < NAME_HIGHLIGHT_SIZE) {
421 if (_flags & EnvelopeVisible) {
425 gain_line->set_height ((uint32_t) rint (height - NAME_HIGHLIGHT_SIZE));
429 reset_fade_shapes ();
432 name_text->raise_to_top();
437 AudioRegionView::manage_zero_line ()
443 if (_height >= 100) {
444 gdouble wave_midpoint = (_height - NAME_HIGHLIGHT_SIZE) / 2.0;
445 zero_line->property_y1() = wave_midpoint;
446 zero_line->property_y2() = wave_midpoint;
454 AudioRegionView::reset_fade_shapes ()
456 reset_fade_in_shape ();
457 reset_fade_out_shape ();
461 AudioRegionView::reset_fade_in_shape ()
463 reset_fade_in_shape_width ((nframes_t) audio_region()->fade_in().back()->when);
467 AudioRegionView::reset_fade_in_shape_width (nframes_t width)
469 if (fade_in_handle == 0) {
473 /* smallest size for a fade is 64 frames */
475 width = std::max ((nframes_t) 64, width);
478 double pwidth = width / samples_per_unit;
479 uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth);
483 fade_in_shape->hide();
484 fade_in_handle->hide();
488 double handle_center;
489 handle_center = pwidth;
491 if (handle_center > 7.0) {
492 handle_center -= 3.0;
497 fade_in_handle->property_x1() = handle_center - 3.0;
498 fade_in_handle->property_x2() = handle_center + 3.0;
501 fade_in_shape->hide();
505 fade_in_shape->show();
507 float curve[npoints];
508 audio_region()->fade_in().get_vector (0, audio_region()->fade_in().back()->when, curve, npoints);
510 points = get_canvas_points ("fade in shape", npoints+3);
512 if (_height > NAME_HIGHLIGHT_THRESH) {
513 h = _height - NAME_HIGHLIGHT_SIZE;
518 /* points *MUST* be in anti-clockwise order */
521 double xdelta = pwidth/npoints;
523 for (pi = 0, pc = 0; pc < npoints; ++pc) {
524 (*points)[pi].set_x(1 + (pc * xdelta));
525 (*points)[pi++].set_y(2 + (h - (curve[pc] * h)));
530 (*points)[pi].set_x(pwidth);
531 (*points)[pi++].set_y(2);
533 (*points)[pi].set_x(1);
534 (*points)[pi++].set_y(2);
536 /* connect the dots ... */
538 (*points)[pi] = (*points)[0];
540 fade_in_shape->property_points() = *points;
545 AudioRegionView::reset_fade_out_shape ()
547 reset_fade_out_shape_width ((nframes_t) audio_region()->fade_out().back()->when);
551 AudioRegionView::reset_fade_out_shape_width (nframes_t width)
553 if (fade_out_handle == 0) {
557 /* smallest size for a fade is 64 frames */
559 width = std::max ((nframes_t) 64, width);
562 double pwidth = width / samples_per_unit;
563 uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth);
567 fade_out_shape->hide();
568 fade_out_handle->hide();
572 double handle_center;
573 handle_center = (_region->length() - width) / samples_per_unit;
575 if (handle_center > 7.0) {
576 handle_center -= 3.0;
581 fade_out_handle->property_x1() = handle_center - 3.0;
582 fade_out_handle->property_x2() = handle_center + 3.0;
584 /* don't show shape if its too small */
587 fade_out_shape->hide();
591 fade_out_shape->show();
593 float curve[npoints];
594 audio_region()->fade_out().get_vector (0, audio_region()->fade_out().back()->when, curve, npoints);
596 if (_height > NAME_HIGHLIGHT_THRESH) {
597 h = _height - NAME_HIGHLIGHT_SIZE;
602 /* points *MUST* be in anti-clockwise order */
604 points = get_canvas_points ("fade out shape", npoints+3);
607 double xdelta = pwidth/npoints;
609 for (pi = 0, pc = 0; pc < npoints; ++pc) {
610 (*points)[pi].set_x(_pixel_width - 1 - pwidth + (pc*xdelta));
611 (*points)[pi++].set_y(2 + (h - (curve[pc] * h)));
616 (*points)[pi].set_x(_pixel_width);
617 (*points)[pi++].set_y(h);
619 (*points)[pi].set_x(_pixel_width);
620 (*points)[pi++].set_y(2);
622 /* connect the dots ... */
624 (*points)[pi] = (*points)[0];
626 fade_out_shape->property_points() = *points;
631 AudioRegionView::set_samples_per_unit (gdouble spu)
633 RegionView::set_samples_per_unit (spu);
635 if (_flags & WaveformVisible) {
636 for (uint32_t n=0; n < waves.size(); ++n) {
637 waves[n]->property_samples_per_unit() = spu;
645 reset_fade_shapes ();
649 AudioRegionView::set_amplitude_above_axis (gdouble spp)
651 for (uint32_t n=0; n < waves.size(); ++n) {
652 waves[n]->property_amplitude_above_axis() = spp;
657 AudioRegionView::compute_colors (Gdk::Color& basic_color)
659 RegionView::compute_colors(basic_color);
663 /* gain color computed in envelope_active_changed() */
665 UINT_TO_RGBA (fill_color, &r, &g, &b, &a);
666 fade_color = RGBA_TO_UINT(r,g,b,120);
670 AudioRegionView::set_colors ()
672 RegionView::set_colors();
675 gain_line->set_line_color (audio_region()->envelope_active() ? ARDOUR_UI::config()->canvasvar_GainLine.get() : ARDOUR_UI::config()->canvasvar_GainLineInactive.get());
678 for (uint32_t n=0; n < waves.size(); ++n) {
679 if (_region->muted()) {
680 waves[n]->property_wave_color() = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_WaveForm.get(), MUTED_ALPHA);
682 waves[n]->property_wave_color() = ARDOUR_UI::config()->canvasvar_WaveForm.get();
685 waves[n]->property_clip_color() = ARDOUR_UI::config()->canvasvar_WaveFormClip.get();
686 waves[n]->property_zero_color() = ARDOUR_UI::config()->canvasvar_ZeroLine.get();
691 AudioRegionView::show_region_editor ()
694 editor = new AudioRegionEditor (trackview.session(), audio_region(), *this);
695 // GTK2FIX : how to ensure float without realizing
696 // editor->realize ();
697 // trackview.editor.ensure_float (*editor);
705 AudioRegionView::set_waveform_visible (bool yn)
707 if (((_flags & WaveformVisible) != yn)) {
709 for (uint32_t n=0; n < waves.size(); ++n) {
710 /* make sure the zoom level is correct, since we don't update
711 this when waveforms are hidden.
713 waves[n]->property_samples_per_unit() = samples_per_unit;
716 _flags |= WaveformVisible;
718 for (uint32_t n=0; n < waves.size(); ++n) {
721 _flags &= ~WaveformVisible;
728 AudioRegionView::temporarily_hide_envelope ()
736 AudioRegionView::unhide_envelope ()
738 if (gain_line && (_flags & EnvelopeVisible)) {
744 AudioRegionView::set_envelope_visible (bool yn)
746 if (gain_line && ((_flags & EnvelopeVisible) != yn)) {
749 _flags |= EnvelopeVisible;
752 _flags &= ~EnvelopeVisible;
759 AudioRegionView::create_waves ()
761 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
763 if (!atv.get_diskstream()) {
767 uint32_t nchans = atv.get_diskstream()->n_channels();
769 /* in tmp_waves, set up null pointers for each channel so the vector is allocated */
770 for (uint32_t n = 0; n < nchans; ++n) {
771 tmp_waves.push_back (0);
774 for (uint32_t n = 0; n < nchans; ++n) {
776 if (n >= audio_region()->n_channels()) {
780 wave_caches.push_back (WaveView::create_cache ());
783 if (audio_region()->source(n)->peaks_ready (bind (mem_fun(*this, &AudioRegionView::peaks_ready_handler), n), data_ready_connection)) {
784 create_one_wave (n, true);
788 create_one_wave (n, true);
794 AudioRegionView::create_one_wave (uint32_t which, bool direct)
796 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
797 uint32_t nchans = atv.get_diskstream()->n_channels();
799 uint32_t nwaves = std::min (nchans, audio_region()->n_channels());
802 if (trackview.height < NAME_HIGHLIGHT_SIZE) {
803 ht = ((trackview.height) / (double) nchans);
805 ht = ((trackview.height - NAME_HIGHLIGHT_SIZE) / (double) nchans);
808 gdouble yoff = which * ht;
810 WaveView *wave = new WaveView(*group);
812 wave->property_data_src() = (gpointer) _region.get();
813 wave->property_cache() = wave_caches[which];
814 wave->property_cache_updater() = true;
815 wave->property_channel() = which;
816 wave->property_length_function() = (gpointer) region_length_from_c;
817 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
818 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
819 wave->property_x() = 0.0;
820 wave->property_y() = yoff;
821 wave->property_height() = (double) ht;
822 wave->property_samples_per_unit() = samples_per_unit;
823 wave->property_amplitude_above_axis() = _amplitude_above_axis;
824 wave->property_wave_color() = _region->muted() ? UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_WaveForm.get(), MUTED_ALPHA) : ARDOUR_UI::config()->canvasvar_WaveForm.get();
825 wave->property_clip_color() = ARDOUR_UI::config()->canvasvar_WaveFormClip.get();
826 wave->property_zero_color() = ARDOUR_UI::config()->canvasvar_ZeroLine.get();
827 wave->property_region_start() = _region->start();
828 wave->property_rectified() = (bool) (_flags & WaveformRectified);
829 wave->property_logscaled() = (bool) (_flags & WaveformLogScaled);
831 if (!(_flags & WaveformVisible)) {
835 /* note: calling this function is serialized by the lock
836 held in the peak building thread that signals that
837 peaks are ready for use *or* by the fact that it is
838 called one by one from the GUI thread.
841 if (which < nchans) {
842 tmp_waves[which] = wave;
844 /* n-channel track, >n-channel source */
847 /* see if we're all ready */
849 for (n = 0; n < nchans; ++n) {
850 if (tmp_waves[n] == 0) {
855 if (n == nwaves && waves.empty()) {
856 /* all waves are ready */
857 tmp_waves.resize(nwaves);
862 /* all waves created, don't hook into peaks ready anymore */
863 data_ready_connection.disconnect ();
867 zero_line = new ArdourCanvas::SimpleLine (*group);
868 zero_line->property_x1() = (gdouble) 1.0;
869 zero_line->property_x2() = (gdouble) (_region->length() / samples_per_unit) - 1.0;
870 zero_line->property_color_rgba() = (guint) ARDOUR_UI::config()->canvasvar_ZeroLine.get();
877 AudioRegionView::peaks_ready_handler (uint32_t which)
879 Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun(*this, &AudioRegionView::create_one_wave), which, false));
883 AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
885 if (gain_line == 0) {
891 /* don't create points that can't be seen */
893 set_envelope_visible (true);
900 nframes_t fx = trackview.editor.pixel_to_frame (x);
902 if (fx > _region->length()) {
906 /* compute vertical fractional position */
908 y = 1.0 - (y / (trackview.height - NAME_HIGHLIGHT_SIZE));
910 /* map using gain line */
912 gain_line->view_to_model_y (y);
914 trackview.session().begin_reversible_command (_("add gain control point"));
915 XMLNode &before = audio_region()->envelope().get_state();
917 if (!audio_region()->envelope_active()) {
918 XMLNode ®ion_before = audio_region()->get_state();
919 audio_region()->set_envelope_active(true);
920 XMLNode ®ion_after = audio_region()->get_state();
921 trackview.session().add_command (new MementoCommand<AudioRegion>(*(audio_region().get()), ®ion_before, ®ion_after));
924 audio_region()->envelope().add (fx, y);
926 XMLNode &after = audio_region()->envelope().get_state();
927 trackview.session().add_command (new MementoCommand<Curve>(audio_region()->envelope(), &before, &after));
928 trackview.session().commit_reversible_command ();
932 AudioRegionView::remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
934 ControlPoint *cp = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"));
935 audio_region()->envelope().erase (cp->model);
939 AudioRegionView::store_flags()
941 XMLNode *node = new XMLNode ("GUI");
943 node->add_property ("waveform-visible", (_flags & WaveformVisible) ? "yes" : "no");
944 node->add_property ("envelope-visible", (_flags & EnvelopeVisible) ? "yes" : "no");
945 node->add_property ("waveform-rectified", (_flags & WaveformRectified) ? "yes" : "no");
946 node->add_property ("waveform-logscaled", (_flags & WaveformLogScaled) ? "yes" : "no");
948 _region->add_extra_xml (*node);
952 AudioRegionView::set_flags (XMLNode* node)
956 if ((prop = node->property ("waveform-visible")) != 0) {
957 if (prop->value() == "yes") {
958 _flags |= WaveformVisible;
962 if ((prop = node->property ("envelope-visible")) != 0) {
963 if (prop->value() == "yes") {
964 _flags |= EnvelopeVisible;
968 if ((prop = node->property ("waveform-rectified")) != 0) {
969 if (prop->value() == "yes") {
970 _flags |= WaveformRectified;
974 if ((prop = node->property ("waveform-logscaled")) != 0) {
975 if (prop->value() == "yes") {
976 _flags |= WaveformLogScaled;
982 AudioRegionView::set_waveform_shape (WaveformShape shape)
986 /* this slightly odd approach is to leave the door open to
987 other "shapes" such as spectral displays, etc.
1000 if (yn != (bool) (_flags & WaveformRectified)) {
1001 for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
1002 (*wave)->property_rectified() = yn;
1014 _flags |= WaveformRectified;
1016 _flags &= ~WaveformRectified;
1023 AudioRegionView::set_waveform_scale (WaveformScale scale)
1025 bool yn = (scale == LogWaveform);
1027 if (yn != (bool) (_flags & WaveformLogScaled)) {
1028 for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
1029 (*wave)->property_logscaled() = yn;
1033 _flags |= WaveformLogScaled;
1035 _flags &= ~WaveformLogScaled;
1043 AudioRegionView::add_ghost (AutomationTimeAxisView& atv)
1045 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&trackview);
1048 double unit_position = _region->position () / samples_per_unit;
1049 GhostRegion* ghost = new GhostRegion (atv, unit_position);
1052 nchans = rtv->get_diskstream()->n_channels();
1054 for (uint32_t n = 0; n < nchans; ++n) {
1056 if (n >= audio_region()->n_channels()) {
1060 WaveView *wave = new WaveView(*ghost->group);
1062 wave->property_data_src() = _region.get();
1063 wave->property_cache() = wave_caches[n];
1064 wave->property_cache_updater() = false;
1065 wave->property_channel() = n;
1066 wave->property_length_function() = (gpointer)region_length_from_c;
1067 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
1068 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
1069 wave->property_x() = 0.0;
1070 wave->property_samples_per_unit() = samples_per_unit;
1071 wave->property_amplitude_above_axis() = _amplitude_above_axis;
1072 wave->property_wave_color() = ARDOUR_UI::config()->canvasvar_GhostTrackWave.get();
1073 wave->property_clip_color() = ARDOUR_UI::config()->canvasvar_GhostTrackWaveClip.get();
1074 wave->property_zero_color() = ARDOUR_UI::config()->canvasvar_GhostTrackZeroLine.get();
1075 wave->property_region_start() = _region->start();
1077 ghost->waves.push_back(wave);
1080 ghost->set_height ();
1081 ghost->set_duration (_region->length() / samples_per_unit);
1082 ghosts.push_back (ghost);
1084 ghost->GoingAway.connect (mem_fun(*this, &AudioRegionView::remove_ghost));
1090 AudioRegionView::entered ()
1092 if (gain_line && _flags & EnvelopeVisible) {
1093 gain_line->show_all_control_points ();
1097 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
1100 if (fade_in_handle) {
1101 fade_in_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1102 fade_out_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1107 AudioRegionView::exited ()
1110 gain_line->hide_all_but_selected_control_points ();
1114 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
1117 if (fade_in_handle) {
1118 fade_in_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1119 fade_out_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1124 AudioRegionView::envelope_active_changed ()
1127 gain_line->set_line_color (audio_region()->envelope_active() ? ARDOUR_UI::config()->canvasvar_GainLine.get() : ARDOUR_UI::config()->canvasvar_GainLineInactive.get());
1132 AudioRegionView::set_waveview_data_src()
1135 double unit_length= _region->length() / samples_per_unit;
1137 for (uint32_t n = 0; n < waves.size(); ++n) {
1138 // TODO: something else to let it know the channel
1139 waves[n]->property_data_src() = _region.get();
1142 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
1144 (*i)->set_duration (unit_length);
1146 for (vector<WaveView*>::iterator w = (*i)->waves.begin(); w != (*i)->waves.end(); ++w) {
1147 (*w)->property_data_src() = _region.get();
1154 AudioRegionView::color_handler ()
1157 envelope_active_changed();