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 _region->StateChanged.connect (mem_fun(*this, &AudioRegionView::region_changed));
201 fade_in_shape->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_event), fade_in_shape, this));
202 fade_in_handle->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_handle_event), fade_in_handle, this));
203 fade_out_shape->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_event), fade_out_shape, this));
204 fade_out_handle->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_handle_event), fade_out_handle, this));
208 /* XXX sync mark drag? */
211 AudioRegionView::~AudioRegionView ()
213 in_destructor = true;
215 RegionViewGoingAway (this); /* EMIT_SIGNAL */
217 for (vector<GnomeCanvasWaveViewCache *>::iterator cache = wave_caches.begin(); cache != wave_caches.end() ; ++cache) {
218 gnome_canvas_waveview_cache_destroy (*cache);
221 /* all waveviews etc will be destroyed when the group is destroyed */
228 boost::shared_ptr<ARDOUR::AudioRegion>
229 AudioRegionView::audio_region() const
231 // "Guaranteed" to succeed...
232 return boost::dynamic_pointer_cast<AudioRegion>(_region);
236 AudioRegionView::region_changed (Change what_changed)
238 ENSURE_GUI_THREAD (bind (mem_fun(*this, &AudioRegionView::region_changed), what_changed));
240 RegionView::region_changed(what_changed);
242 if (what_changed & AudioRegion::ScaleAmplitudeChanged) {
243 region_scale_amplitude_changed ();
245 if (what_changed & AudioRegion::FadeInChanged) {
248 if (what_changed & AudioRegion::FadeOutChanged) {
251 if (what_changed & AudioRegion::FadeInActiveChanged) {
252 fade_in_active_changed ();
254 if (what_changed & AudioRegion::FadeOutActiveChanged) {
255 fade_out_active_changed ();
257 if (what_changed & AudioRegion::EnvelopeActiveChanged) {
258 envelope_active_changed ();
263 AudioRegionView::fade_in_changed ()
265 reset_fade_in_shape ();
269 AudioRegionView::fade_out_changed ()
271 reset_fade_out_shape ();
274 AudioRegionView::fade_in_active_changed ()
278 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
280 if (audio_region()->fade_in_active()) {
281 col = RGBA_TO_UINT(r,g,b,120);
282 fade_in_shape->property_fill_color_rgba() = col;
283 fade_in_shape->property_width_pixels() = 0;
284 fade_in_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,0);
286 col = RGBA_TO_UINT(r,g,b,0);
287 fade_in_shape->property_fill_color_rgba() = col;
288 fade_in_shape->property_width_pixels() = 1;
289 fade_in_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,255);
294 AudioRegionView::fade_out_active_changed ()
298 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
300 if (audio_region()->fade_out_active()) {
301 col = RGBA_TO_UINT(r,g,b,120);
302 fade_out_shape->property_fill_color_rgba() = col;
303 fade_out_shape->property_width_pixels() = 0;
304 fade_out_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,0);
306 col = RGBA_TO_UINT(r,g,b,0);
307 fade_out_shape->property_fill_color_rgba() = col;
308 fade_out_shape->property_width_pixels() = 1;
309 fade_out_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,255);
315 AudioRegionView::region_scale_amplitude_changed ()
317 ENSURE_GUI_THREAD (mem_fun(*this, &AudioRegionView::region_scale_amplitude_changed));
319 for (uint32_t n = 0; n < waves.size(); ++n) {
320 // force a reload of the cache
321 waves[n]->property_data_src() = _region.get();
326 AudioRegionView::region_renamed ()
328 // FIXME: ugly duplication with RegionView...
332 if (_region->locked()) {
334 str += _region->name();
337 str = _region->name();
340 // ... because of this
341 if (audio_region()->speed_mismatch (trackview.session().frame_rate())) {
342 str = string ("*") + str;
345 if (_region->muted()) {
346 str = string ("!") + str;
349 set_item_name (str, this);
354 AudioRegionView::region_resized (Change what_changed)
356 RegionView::region_resized(what_changed);
358 if (what_changed & Change (StartChanged|LengthChanged)) {
360 for (uint32_t n = 0; n < waves.size(); ++n) {
361 waves[n]->property_region_start() = _region->start();
364 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
366 for (vector<WaveView*>::iterator w = (*i)->waves.begin(); w != (*i)->waves.end(); ++w) {
367 (*w)->property_region_start() = _region->start();
374 AudioRegionView::reset_width_dependent_items (double pixel_width)
376 RegionView::reset_width_dependent_items(pixel_width);
377 assert(_pixel_width == pixel_width);
380 zero_line->property_x2() = pixel_width - 1.0;
383 if (fade_in_handle) {
384 if (pixel_width <= 6.0) {
385 fade_in_handle->hide();
386 fade_out_handle->hide();
389 fade_in_handle->hide();
390 fade_out_handle->hide();
392 fade_in_handle->show();
393 fade_out_handle->show();
398 reset_fade_shapes ();
402 AudioRegionView::region_muted ()
404 RegionView::region_muted();
406 for (uint32_t n=0; n < waves.size(); ++n) {
407 if (_region->muted()) {
408 waves[n]->property_wave_color() = color_map[cMutedWaveForm];
410 waves[n]->property_wave_color() = color_map[cWaveForm];
416 AudioRegionView::set_height (gdouble height)
418 RegionView::set_height(height);
420 uint32_t wcnt = waves.size();
422 for (uint32_t n=0; n < wcnt; ++n) {
425 if ((height) <= NAME_HIGHLIGHT_THRESH) {
426 ht = ((height-2*wcnt) / (double) wcnt);
428 ht = (((height-2*wcnt) - NAME_HIGHLIGHT_SIZE) / (double) wcnt);
431 gdouble yoff = n * (ht+1);
433 waves[n]->property_height() = ht;
434 waves[n]->property_y() = yoff + 2;
438 if ((height/wcnt) < NAME_HIGHLIGHT_SIZE) {
441 if (_flags & EnvelopeVisible) {
445 gain_line->set_height ((uint32_t) rint (height - NAME_HIGHLIGHT_SIZE));
449 reset_fade_shapes ();
452 name_text->raise_to_top();
457 AudioRegionView::manage_zero_line ()
463 if (_height >= 100) {
464 gdouble wave_midpoint = (_height - NAME_HIGHLIGHT_SIZE) / 2.0;
465 zero_line->property_y1() = wave_midpoint;
466 zero_line->property_y2() = wave_midpoint;
474 AudioRegionView::reset_fade_shapes ()
476 reset_fade_in_shape ();
477 reset_fade_out_shape ();
481 AudioRegionView::reset_fade_in_shape ()
483 reset_fade_in_shape_width ((nframes_t) audio_region()->fade_in().back()->when);
487 AudioRegionView::reset_fade_in_shape_width (nframes_t width)
489 if (fade_in_handle == 0) {
493 /* smallest size for a fade is 64 frames */
495 width = std::max ((nframes_t) 64, width);
498 double pwidth = width / samples_per_unit;
499 uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth);
503 fade_in_shape->hide();
504 fade_in_handle->hide();
508 double handle_center;
509 handle_center = pwidth;
511 if (handle_center > 7.0) {
512 handle_center -= 3.0;
517 fade_in_handle->property_x1() = handle_center - 3.0;
518 fade_in_handle->property_x2() = handle_center + 3.0;
521 fade_in_shape->hide();
525 fade_in_shape->show();
527 float curve[npoints];
528 audio_region()->fade_in().get_vector (0, audio_region()->fade_in().back()->when, curve, npoints);
530 points = get_canvas_points ("fade in shape", npoints+3);
532 if (_height > NAME_HIGHLIGHT_THRESH) {
533 h = _height - NAME_HIGHLIGHT_SIZE;
538 /* points *MUST* be in anti-clockwise order */
541 double xdelta = pwidth/npoints;
543 for (pi = 0, pc = 0; pc < npoints; ++pc) {
544 (*points)[pi].set_x(1 + (pc * xdelta));
545 (*points)[pi++].set_y(2 + (h - (curve[pc] * h)));
550 (*points)[pi].set_x(pwidth);
551 (*points)[pi++].set_y(2);
553 (*points)[pi].set_x(1);
554 (*points)[pi++].set_y(2);
556 /* connect the dots ... */
558 (*points)[pi] = (*points)[0];
560 fade_in_shape->property_points() = *points;
565 AudioRegionView::reset_fade_out_shape ()
567 reset_fade_out_shape_width ((nframes_t) audio_region()->fade_out().back()->when);
571 AudioRegionView::reset_fade_out_shape_width (nframes_t width)
573 if (fade_out_handle == 0) {
577 /* smallest size for a fade is 64 frames */
579 width = std::max ((nframes_t) 64, width);
582 double pwidth = width / samples_per_unit;
583 uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth);
587 fade_out_shape->hide();
588 fade_out_handle->hide();
592 double handle_center;
593 handle_center = (_region->length() - width) / samples_per_unit;
595 if (handle_center > 7.0) {
596 handle_center -= 3.0;
601 fade_out_handle->property_x1() = handle_center - 3.0;
602 fade_out_handle->property_x2() = handle_center + 3.0;
604 /* don't show shape if its too small */
607 fade_out_shape->hide();
611 fade_out_shape->show();
613 float curve[npoints];
614 audio_region()->fade_out().get_vector (0, audio_region()->fade_out().back()->when, curve, npoints);
616 if (_height > NAME_HIGHLIGHT_THRESH) {
617 h = _height - NAME_HIGHLIGHT_SIZE;
622 /* points *MUST* be in anti-clockwise order */
624 points = get_canvas_points ("fade out shape", npoints+3);
627 double xdelta = pwidth/npoints;
629 for (pi = 0, pc = 0; pc < npoints; ++pc) {
630 (*points)[pi].set_x(_pixel_width - 1 - pwidth + (pc*xdelta));
631 (*points)[pi++].set_y(2 + (h - (curve[pc] * h)));
636 (*points)[pi].set_x(_pixel_width);
637 (*points)[pi++].set_y(h);
639 (*points)[pi].set_x(_pixel_width);
640 (*points)[pi++].set_y(2);
642 /* connect the dots ... */
644 (*points)[pi] = (*points)[0];
646 fade_out_shape->property_points() = *points;
651 AudioRegionView::set_samples_per_unit (gdouble spu)
653 RegionView::set_samples_per_unit (spu);
655 if (_flags & WaveformVisible) {
656 for (uint32_t n=0; n < waves.size(); ++n) {
657 waves[n]->property_samples_per_unit() = spu;
665 reset_fade_shapes ();
669 AudioRegionView::set_amplitude_above_axis (gdouble spp)
671 for (uint32_t n=0; n < waves.size(); ++n) {
672 waves[n]->property_amplitude_above_axis() = spp;
677 AudioRegionView::compute_colors (Gdk::Color& basic_color)
679 RegionView::compute_colors(basic_color);
683 /* gain color computed in envelope_active_changed() */
685 UINT_TO_RGBA (fill_color, &r, &g, &b, &a);
686 fade_color = RGBA_TO_UINT(r,g,b,120);
690 AudioRegionView::set_colors ()
692 RegionView::set_colors();
695 gain_line->set_line_color (audio_region()->envelope_active() ? color_map[cGainLine] : color_map[cGainLineInactive]);
698 for (uint32_t n=0; n < waves.size(); ++n) {
699 if (_region->muted()) {
700 waves[n]->property_wave_color() = color_map[cMutedWaveForm];
702 waves[n]->property_wave_color() = color_map[cWaveForm];
705 waves[n]->property_clip_color() = color_map[cWaveFormClip];
706 waves[n]->property_zero_color() = color_map[cZeroLine];
711 AudioRegionView::show_region_editor ()
714 editor = new AudioRegionEditor (trackview.session(), audio_region(), *this);
715 // GTK2FIX : how to ensure float without realizing
716 // editor->realize ();
717 // trackview.editor.ensure_float (*editor);
725 AudioRegionView::set_waveform_visible (bool yn)
727 if (((_flags & WaveformVisible) != yn)) {
729 for (uint32_t n=0; n < waves.size(); ++n) {
730 /* make sure the zoom level is correct, since we don't update
731 this when waveforms are hidden.
733 waves[n]->property_samples_per_unit() = samples_per_unit;
736 _flags |= WaveformVisible;
738 for (uint32_t n=0; n < waves.size(); ++n) {
741 _flags &= ~WaveformVisible;
748 AudioRegionView::temporarily_hide_envelope ()
756 AudioRegionView::unhide_envelope ()
758 if (gain_line && (_flags & EnvelopeVisible)) {
764 AudioRegionView::set_envelope_visible (bool yn)
766 if (gain_line && ((_flags & EnvelopeVisible) != yn)) {
769 _flags |= EnvelopeVisible;
772 _flags &= ~EnvelopeVisible;
779 AudioRegionView::create_waves ()
781 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
783 if (!atv.get_diskstream()) {
787 uint32_t nchans = atv.get_diskstream()->n_channels().n_audio();
789 /* in tmp_waves, set up null pointers for each channel so the vector is allocated */
790 for (uint32_t n = 0; n < nchans; ++n) {
791 tmp_waves.push_back (0);
794 for (uint32_t n = 0; n < nchans; ++n) {
796 if (n >= audio_region()->n_channels()) {
800 wave_caches.push_back (WaveView::create_cache ());
803 if (audio_region()->audio_source(n)->peaks_ready (bind (mem_fun(*this, &AudioRegionView::peaks_ready_handler), n), data_ready_connection)) {
804 create_one_wave (n, true);
808 create_one_wave (n, true);
814 AudioRegionView::create_one_wave (uint32_t which, bool direct)
816 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
817 uint32_t nchans = atv.get_diskstream()->n_channels().n_audio();
819 uint32_t nwaves = std::min (nchans, audio_region()->n_channels());
822 if (trackview.height < NAME_HIGHLIGHT_SIZE) {
823 ht = ((trackview.height) / (double) nchans);
825 ht = ((trackview.height - NAME_HIGHLIGHT_SIZE) / (double) nchans);
828 gdouble yoff = which * ht;
830 WaveView *wave = new WaveView(*group);
832 wave->property_data_src() = (gpointer) _region.get();
833 wave->property_cache() = wave_caches[which];
834 wave->property_cache_updater() = true;
835 wave->property_channel() = which;
836 wave->property_length_function() = (gpointer) region_length_from_c;
837 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
838 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
839 wave->property_x() = 0.0;
840 wave->property_y() = yoff;
841 wave->property_height() = (double) ht;
842 wave->property_samples_per_unit() = samples_per_unit;
843 wave->property_amplitude_above_axis() = _amplitude_above_axis;
844 wave->property_wave_color() = _region->muted() ? color_map[cMutedWaveForm] : color_map[cWaveForm];
845 wave->property_clip_color() = color_map[cWaveFormClip];
846 wave->property_zero_color() = color_map[cZeroLine];
847 wave->property_region_start() = _region->start();
848 wave->property_rectified() = (bool) (_flags & WaveformRectified);
849 wave->property_logscaled() = (bool) (_flags & WaveformLogScaled);
851 if (!(_flags & WaveformVisible)) {
855 /* note: calling this function is serialized by the lock
856 held in the peak building thread that signals that
857 peaks are ready for use *or* by the fact that it is
858 called one by one from the GUI thread.
861 if (which < nchans) {
862 tmp_waves[which] = wave;
864 /* n-channel track, >n-channel source */
867 /* see if we're all ready */
869 for (n = 0; n < nchans; ++n) {
870 if (tmp_waves[n] == 0) {
875 if (n == nwaves && waves.empty()) {
876 /* all waves are ready */
877 tmp_waves.resize(nwaves);
882 /* all waves created, don't hook into peaks ready anymore */
883 data_ready_connection.disconnect ();
887 zero_line = new ArdourCanvas::SimpleLine (*group);
888 zero_line->property_x1() = (gdouble) 1.0;
889 zero_line->property_x2() = (gdouble) (_region->length() / samples_per_unit) - 1.0;
890 zero_line->property_color_rgba() = (guint) color_map[cZeroLine];
897 AudioRegionView::peaks_ready_handler (uint32_t which)
899 Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun(*this, &AudioRegionView::create_one_wave), which, false));
903 AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
905 if (gain_line == 0) {
911 /* don't create points that can't be seen */
913 set_envelope_visible (true);
920 nframes_t fx = trackview.editor.pixel_to_frame (x);
922 if (fx > _region->length()) {
926 /* compute vertical fractional position */
928 y = 1.0 - (y / (trackview.height - NAME_HIGHLIGHT_SIZE));
930 /* map using gain line */
932 gain_line->view_to_model_y (y);
934 trackview.session().begin_reversible_command (_("add gain control point"));
935 XMLNode &before = audio_region()->envelope().get_state();
937 if (!audio_region()->envelope_active()) {
938 XMLNode ®ion_before = audio_region()->get_state();
939 audio_region()->set_envelope_active(true);
940 XMLNode ®ion_after = audio_region()->get_state();
941 trackview.session().add_command (new MementoCommand<AudioRegion>(*(audio_region().get()), ®ion_before, ®ion_after));
944 audio_region()->envelope().add (fx, y);
946 XMLNode &after = audio_region()->envelope().get_state();
947 trackview.session().add_command (new MementoCommand<Curve>(audio_region()->envelope(), &before, &after));
948 trackview.session().commit_reversible_command ();
952 AudioRegionView::remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
954 ControlPoint *cp = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"));
955 audio_region()->envelope().erase (cp->model);
959 AudioRegionView::store_flags()
961 XMLNode *node = new XMLNode ("GUI");
963 node->add_property ("waveform-visible", (_flags & WaveformVisible) ? "yes" : "no");
964 node->add_property ("envelope-visible", (_flags & EnvelopeVisible) ? "yes" : "no");
965 node->add_property ("waveform-rectified", (_flags & WaveformRectified) ? "yes" : "no");
966 node->add_property ("waveform-logscaled", (_flags & WaveformLogScaled) ? "yes" : "no");
968 _region->add_extra_xml (*node);
972 AudioRegionView::set_flags (XMLNode* node)
976 if ((prop = node->property ("waveform-visible")) != 0) {
977 if (prop->value() == "yes") {
978 _flags |= WaveformVisible;
982 if ((prop = node->property ("envelope-visible")) != 0) {
983 if (prop->value() == "yes") {
984 _flags |= EnvelopeVisible;
988 if ((prop = node->property ("waveform-rectified")) != 0) {
989 if (prop->value() == "yes") {
990 _flags |= WaveformRectified;
994 if ((prop = node->property ("waveform-logscaled")) != 0) {
995 if (prop->value() == "yes") {
996 _flags |= WaveformLogScaled;
1002 AudioRegionView::set_waveform_shape (WaveformShape shape)
1006 /* this slightly odd approach is to leave the door open to
1007 other "shapes" such as spectral displays, etc.
1020 if (yn != (bool) (_flags & WaveformRectified)) {
1021 for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
1022 (*wave)->property_rectified() = yn;
1034 _flags |= WaveformRectified;
1036 _flags &= ~WaveformRectified;
1043 AudioRegionView::set_waveform_scale (WaveformScale scale)
1045 bool yn = (scale == LogWaveform);
1047 if (yn != (bool) (_flags & WaveformLogScaled)) {
1048 for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
1049 (*wave)->property_logscaled() = yn;
1053 _flags |= WaveformLogScaled;
1055 _flags &= ~WaveformLogScaled;
1063 AudioRegionView::add_ghost (AutomationTimeAxisView& atv)
1065 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&trackview);
1068 double unit_position = _region->position () / samples_per_unit;
1069 GhostRegion* ghost = new GhostRegion (atv, unit_position);
1072 nchans = rtv->get_diskstream()->n_channels().n_audio();
1074 for (uint32_t n = 0; n < nchans; ++n) {
1076 if (n >= audio_region()->n_channels()) {
1080 WaveView *wave = new WaveView(*ghost->group);
1082 wave->property_data_src() = _region.get();
1083 wave->property_cache() = wave_caches[n];
1084 wave->property_cache_updater() = false;
1085 wave->property_channel() = n;
1086 wave->property_length_function() = (gpointer)region_length_from_c;
1087 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
1088 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
1089 wave->property_x() = 0.0;
1090 wave->property_samples_per_unit() = samples_per_unit;
1091 wave->property_amplitude_above_axis() = _amplitude_above_axis;
1092 wave->property_wave_color() = color_map[cGhostTrackWave];
1093 wave->property_clip_color() = color_map[cGhostTrackWaveClip];
1094 wave->property_zero_color() = color_map[cGhostTrackZeroLine];
1095 wave->property_region_start() = _region->start();
1097 ghost->waves.push_back(wave);
1100 ghost->set_height ();
1101 ghost->set_duration (_region->length() / samples_per_unit);
1102 ghosts.push_back (ghost);
1104 ghost->GoingAway.connect (mem_fun(*this, &AudioRegionView::remove_ghost));
1110 AudioRegionView::entered ()
1112 if (gain_line && _flags & EnvelopeVisible) {
1113 gain_line->show_all_control_points ();
1117 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
1120 if (fade_in_handle) {
1121 fade_in_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1122 fade_out_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1127 AudioRegionView::exited ()
1130 gain_line->hide_all_but_selected_control_points ();
1134 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
1137 if (fade_in_handle) {
1138 fade_in_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1139 fade_out_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1144 AudioRegionView::envelope_active_changed ()
1147 gain_line->set_line_color (audio_region()->envelope_active() ? color_map[cGainLine] : color_map[cGainLineInactive]);
1152 AudioRegionView::set_waveview_data_src()
1155 double unit_length= _region->length() / samples_per_unit;
1157 for (uint32_t n = 0; n < waves.size(); ++n) {
1158 // TODO: something else to let it know the channel
1159 waves[n]->property_data_src() = _region.get();
1162 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
1164 (*i)->set_duration (unit_length);
1166 for (vector<WaveView*>::iterator w = (*i)->waves.begin(); w != (*i)->waves.end(); ++w) {
1167 (*w)->property_data_src() = _region.get();
1174 AudioRegionView::color_handler (ColorID id, uint32_t val)
1177 case cMutedWaveForm:
1184 case cGainLineInactive:
1186 envelope_active_changed();