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;
161 fade_in_handle->set_data ("regionview", this);
163 fade_out_handle = new ArdourCanvas::SimpleRect (*group);
164 fade_out_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,0);
165 fade_out_handle->property_outline_pixels() = 0;
167 fade_out_handle->set_data ("regionview", this);
170 setup_fade_handle_positions ();
172 string foo = _region->name();
176 gain_line = new AudioRegionGainLine (foo, trackview.session(), *this, *group, audio_region()->envelope());
178 if (!(_flags & EnvelopeVisible)) {
186 set_y_position_and_height (0, trackview.height);
189 region_sync_changed ();
190 region_resized (BoundsChanged);
191 set_waveview_data_src();
193 envelope_active_changed ();
194 fade_in_active_changed ();
195 fade_out_active_changed ();
197 fade_in_shape->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_event), fade_in_shape, this));
198 fade_in_handle->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_in_handle_event), fade_in_handle, this));
199 fade_out_shape->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_event), fade_out_shape, this));
200 fade_out_handle->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_fade_out_handle_event), fade_out_handle, this));
204 /* XXX sync mark drag? */
207 AudioRegionView::~AudioRegionView ()
209 in_destructor = true;
211 RegionViewGoingAway (this); /* EMIT_SIGNAL */
213 for (vector<GnomeCanvasWaveViewCache *>::iterator cache = wave_caches.begin(); cache != wave_caches.end() ; ++cache) {
214 gnome_canvas_waveview_cache_destroy (*cache);
217 /* all waveviews etc will be destroyed when the group is destroyed */
224 boost::shared_ptr<ARDOUR::AudioRegion>
225 AudioRegionView::audio_region() const
227 // "Guaranteed" to succeed...
228 return boost::dynamic_pointer_cast<AudioRegion>(_region);
232 AudioRegionView::region_changed (Change what_changed)
234 ENSURE_GUI_THREAD (bind (mem_fun(*this, &AudioRegionView::region_changed), what_changed));
236 RegionView::region_changed(what_changed);
238 if (what_changed & AudioRegion::ScaleAmplitudeChanged) {
239 region_scale_amplitude_changed ();
241 if (what_changed & AudioRegion::FadeInChanged) {
244 if (what_changed & AudioRegion::FadeOutChanged) {
247 if (what_changed & AudioRegion::FadeInActiveChanged) {
248 fade_in_active_changed ();
250 if (what_changed & AudioRegion::FadeOutActiveChanged) {
251 fade_out_active_changed ();
253 if (what_changed & AudioRegion::EnvelopeActiveChanged) {
254 envelope_active_changed ();
259 AudioRegionView::fade_in_changed ()
261 reset_fade_in_shape ();
265 AudioRegionView::fade_out_changed ()
267 reset_fade_out_shape ();
270 AudioRegionView::fade_in_active_changed ()
274 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
276 if (audio_region()->fade_in_active()) {
277 col = RGBA_TO_UINT(r,g,b,120);
278 fade_in_shape->property_fill_color_rgba() = col;
279 fade_in_shape->property_width_pixels() = 0;
280 fade_in_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,0);
282 col = RGBA_TO_UINT(r,g,b,0);
283 fade_in_shape->property_fill_color_rgba() = col;
284 fade_in_shape->property_width_pixels() = 1;
285 fade_in_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,255);
290 AudioRegionView::fade_out_active_changed ()
294 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
296 if (audio_region()->fade_out_active()) {
297 col = RGBA_TO_UINT(r,g,b,120);
298 fade_out_shape->property_fill_color_rgba() = col;
299 fade_out_shape->property_width_pixels() = 0;
300 fade_out_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,0);
302 col = RGBA_TO_UINT(r,g,b,0);
303 fade_out_shape->property_fill_color_rgba() = col;
304 fade_out_shape->property_width_pixels() = 1;
305 fade_out_shape->property_outline_color_rgba() = RGBA_TO_UINT(r,g,b,255);
311 AudioRegionView::region_scale_amplitude_changed ()
313 ENSURE_GUI_THREAD (mem_fun(*this, &AudioRegionView::region_scale_amplitude_changed));
315 for (uint32_t n = 0; n < waves.size(); ++n) {
316 // force a reload of the cache
317 waves[n]->property_data_src() = _region.get();
322 AudioRegionView::region_renamed ()
324 Glib::ustring str = RegionView::make_name ();
326 if (audio_region()->speed_mismatch (trackview.session().frame_rate())) {
327 str = string ("*") + str;
330 if (_region->muted()) {
331 str = string ("!") + str;
334 set_item_name (str, this);
339 AudioRegionView::region_resized (Change what_changed)
341 RegionView::region_resized(what_changed);
343 if (what_changed & Change (StartChanged|LengthChanged)) {
345 for (uint32_t n = 0; n < waves.size(); ++n) {
346 waves[n]->property_region_start() = _region->start();
349 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
351 for (vector<WaveView*>::iterator w = (*i)->waves.begin(); w != (*i)->waves.end(); ++w) {
352 (*w)->property_region_start() = _region->start();
359 AudioRegionView::reset_width_dependent_items (double pixel_width)
361 RegionView::reset_width_dependent_items(pixel_width);
362 assert(_pixel_width == pixel_width);
365 zero_line->property_x2() = pixel_width - 1.0;
368 if (fade_in_handle) {
369 if (pixel_width <= 6.0) {
370 fade_in_handle->hide();
371 fade_out_handle->hide();
374 fade_in_handle->hide();
375 fade_out_handle->hide();
377 fade_in_handle->show();
378 fade_out_handle->show();
383 reset_fade_shapes ();
387 AudioRegionView::region_muted ()
389 RegionView::region_muted();
391 for (uint32_t n=0; n < waves.size(); ++n) {
392 if (_region->muted()) {
393 waves[n]->property_wave_color() = color_map[cMutedWaveForm];
395 waves[n]->property_wave_color() = color_map[cWaveForm];
401 AudioRegionView::set_y_position_and_height (double y, double h)
403 RegionView::set_y_position_and_height(y, h - 2);
408 uint32_t const wcnt = waves.size();
409 for (uint32_t n = 0; n < wcnt; ++n) {
412 if (h <= NAME_HIGHLIGHT_THRESH) {
413 ht = ((_height - 2 * wcnt) / (double) wcnt);
415 ht = (((_height - 2 * wcnt) - NAME_HIGHLIGHT_SIZE) / (double) wcnt);
418 double const yoff = n * (ht + 1);
420 waves[n]->property_height() = ht;
421 waves[n]->property_y() = _y_position + yoff + 2;
425 if ((_height / wcnt) < NAME_HIGHLIGHT_SIZE) {
428 if (_flags & EnvelopeVisible) {
432 gain_line->set_y_position_and_height ((uint32_t) _y_position, (uint32_t) rint (_height - NAME_HIGHLIGHT_SIZE));
435 setup_fade_handle_positions ();
437 reset_fade_shapes ();
440 name_text->raise_to_top();
445 AudioRegionView::setup_fade_handle_positions()
447 /* position of fade handle offset from the top of the region view */
448 double const handle_pos = 2;
449 /* height of fade handles */
450 double const handle_height = 5;
452 if (fade_in_handle) {
453 fade_in_handle->property_y1() = _y_position + handle_pos;
454 fade_in_handle->property_y2() = _y_position + handle_pos + handle_height;
457 if (fade_out_handle) {
458 fade_out_handle->property_y1() = _y_position + handle_pos;
459 fade_out_handle->property_y2() = _y_position + handle_pos + handle_height;
464 AudioRegionView::manage_zero_line ()
470 if (_height >= 100) {
471 double const wave_midpoint = _y_position + (_height - NAME_HIGHLIGHT_SIZE) / 2.0;
472 zero_line->property_y1() = wave_midpoint;
473 zero_line->property_y2() = wave_midpoint;
481 AudioRegionView::reset_fade_shapes ()
483 reset_fade_in_shape ();
484 reset_fade_out_shape ();
488 AudioRegionView::reset_fade_in_shape ()
490 reset_fade_in_shape_width ((nframes_t) audio_region()->fade_in().back()->when);
494 AudioRegionView::reset_fade_in_shape_width (nframes_t width)
496 if (fade_in_handle == 0) {
500 /* smallest size for a fade is 64 frames */
502 width = std::max ((nframes_t) 64, width);
505 double pwidth = width / samples_per_unit;
506 uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth);
510 fade_in_shape->hide();
511 fade_in_handle->hide();
515 double handle_center;
516 handle_center = pwidth;
518 if (handle_center > 7.0) {
519 handle_center -= 3.0;
524 fade_in_handle->property_x1() = handle_center - 3.0;
525 fade_in_handle->property_x2() = handle_center + 3.0;
528 fade_in_shape->hide();
532 fade_in_shape->show();
534 float curve[npoints];
535 audio_region()->fade_in().get_vector (0, audio_region()->fade_in().back()->when, curve, npoints);
537 points = get_canvas_points ("fade in shape", npoints+3);
539 if (_height > NAME_HIGHLIGHT_THRESH) {
540 h = _height - NAME_HIGHLIGHT_SIZE;
545 /* points *MUST* be in anti-clockwise order */
548 double xdelta = pwidth/npoints;
550 for (pi = 0, pc = 0; pc < npoints; ++pc) {
551 (*points)[pi].set_x(1 + (pc * xdelta));
552 (*points)[pi++].set_y(_y_position + 2 + (h - (curve[pc] * h)));
557 (*points)[pi].set_x(pwidth);
558 (*points)[pi++].set_y(_y_position + 2);
560 (*points)[pi].set_x(1);
561 (*points)[pi++].set_y(_y_position + 2);
563 /* connect the dots ... */
565 (*points)[pi] = (*points)[0];
567 fade_in_shape->property_points() = *points;
572 AudioRegionView::reset_fade_out_shape ()
574 reset_fade_out_shape_width ((nframes_t) audio_region()->fade_out().back()->when);
578 AudioRegionView::reset_fade_out_shape_width (nframes_t width)
580 if (fade_out_handle == 0) {
584 /* smallest size for a fade is 64 frames */
586 width = std::max ((nframes_t) 64, width);
589 double pwidth = width / samples_per_unit;
590 uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth);
594 fade_out_shape->hide();
595 fade_out_handle->hide();
599 double handle_center;
600 handle_center = (_region->length() - width) / samples_per_unit;
602 if (handle_center > 7.0) {
603 handle_center -= 3.0;
608 fade_out_handle->property_x1() = handle_center - 3.0;
609 fade_out_handle->property_x2() = handle_center + 3.0;
611 /* don't show shape if its too small */
614 fade_out_shape->hide();
618 fade_out_shape->show();
620 float curve[npoints];
621 audio_region()->fade_out().get_vector (0, audio_region()->fade_out().back()->when, curve, npoints);
623 if (_height > NAME_HIGHLIGHT_THRESH) {
624 h = _height - NAME_HIGHLIGHT_SIZE;
629 /* points *MUST* be in anti-clockwise order */
631 points = get_canvas_points ("fade out shape", npoints+3);
634 double xdelta = pwidth/npoints;
636 for (pi = 0, pc = 0; pc < npoints; ++pc) {
637 (*points)[pi].set_x(_pixel_width - 1 - pwidth + (pc*xdelta));
638 (*points)[pi++].set_y(_y_position + 2 + (h - (curve[pc] * h)));
643 (*points)[pi].set_x(_pixel_width);
644 (*points)[pi++].set_y(_y_position + h);
646 (*points)[pi].set_x(_pixel_width);
647 (*points)[pi++].set_y(_y_position + 2);
649 /* connect the dots ... */
651 (*points)[pi] = (*points)[0];
653 fade_out_shape->property_points() = *points;
658 AudioRegionView::set_samples_per_unit (gdouble spu)
660 RegionView::set_samples_per_unit (spu);
662 if (_flags & WaveformVisible) {
663 for (uint32_t n=0; n < waves.size(); ++n) {
664 waves[n]->property_samples_per_unit() = spu;
672 reset_fade_shapes ();
676 AudioRegionView::set_amplitude_above_axis (gdouble spp)
678 for (uint32_t n=0; n < waves.size(); ++n) {
679 waves[n]->property_amplitude_above_axis() = spp;
684 AudioRegionView::compute_colors (Gdk::Color& basic_color)
686 RegionView::compute_colors(basic_color);
690 /* gain color computed in envelope_active_changed() */
692 UINT_TO_RGBA (fill_color, &r, &g, &b, &a);
693 fade_color = RGBA_TO_UINT(r,g,b,120);
697 AudioRegionView::set_colors ()
699 RegionView::set_colors();
702 gain_line->set_line_color (audio_region()->envelope_active() ? color_map[cGainLine] : color_map[cGainLineInactive]);
705 for (uint32_t n=0; n < waves.size(); ++n) {
706 if (_region->muted()) {
707 waves[n]->property_wave_color() = color_map[cMutedWaveForm];
709 waves[n]->property_wave_color() = color_map[cWaveForm];
712 waves[n]->property_clip_color() = color_map[cWaveFormClip];
713 waves[n]->property_zero_color() = color_map[cZeroLine];
718 AudioRegionView::show_region_editor ()
721 editor = new AudioRegionEditor (trackview.session(), audio_region(), *this);
722 // GTK2FIX : how to ensure float without realizing
723 // editor->realize ();
724 // trackview.editor.ensure_float (*editor);
732 AudioRegionView::set_waveform_visible (bool yn)
734 if (((_flags & WaveformVisible) != yn)) {
736 for (uint32_t n=0; n < waves.size(); ++n) {
737 /* make sure the zoom level is correct, since we don't update
738 this when waveforms are hidden.
740 waves[n]->property_samples_per_unit() = samples_per_unit;
743 _flags |= WaveformVisible;
745 for (uint32_t n=0; n < waves.size(); ++n) {
748 _flags &= ~WaveformVisible;
755 AudioRegionView::temporarily_hide_envelope ()
763 AudioRegionView::unhide_envelope ()
765 if (gain_line && (_flags & EnvelopeVisible)) {
771 AudioRegionView::set_envelope_visible (bool yn)
773 if (gain_line && ((_flags & EnvelopeVisible) != yn)) {
776 _flags |= EnvelopeVisible;
779 _flags &= ~EnvelopeVisible;
786 AudioRegionView::create_waves ()
788 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
790 if (!atv.get_diskstream()) {
794 uint32_t nchans = atv.get_diskstream()->n_channels().n_audio();
796 /* in tmp_waves, set up null pointers for each channel so the vector is allocated */
797 for (uint32_t n = 0; n < nchans; ++n) {
798 tmp_waves.push_back (0);
801 for (uint32_t n = 0; n < nchans; ++n) {
803 if (n >= audio_region()->n_channels()) {
807 wave_caches.push_back (WaveView::create_cache ());
810 if (audio_region()->audio_source(n)->peaks_ready (bind (mem_fun(*this, &AudioRegionView::peaks_ready_handler), n), data_ready_connection)) {
811 create_one_wave (n, true);
815 create_one_wave (n, true);
821 AudioRegionView::create_one_wave (uint32_t which, bool direct)
823 RouteTimeAxisView& atv (*(dynamic_cast<RouteTimeAxisView*>(&trackview))); // ick
824 uint32_t nchans = atv.get_diskstream()->n_channels().n_audio();
826 uint32_t nwaves = std::min (nchans, audio_region()->n_channels());
829 if (trackview.height < NAME_HIGHLIGHT_SIZE) {
830 ht = ((trackview.height) / (double) nchans);
832 ht = ((trackview.height - NAME_HIGHLIGHT_SIZE) / (double) nchans);
835 gdouble yoff = which * ht;
837 WaveView *wave = new WaveView(*group);
839 wave->property_data_src() = (gpointer) _region.get();
840 wave->property_cache() = wave_caches[which];
841 wave->property_cache_updater() = true;
842 wave->property_channel() = which;
843 wave->property_length_function() = (gpointer) region_length_from_c;
844 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
845 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
846 wave->property_x() = 0.0;
847 wave->property_y() = yoff;
848 wave->property_height() = (double) ht;
849 wave->property_samples_per_unit() = samples_per_unit;
850 wave->property_amplitude_above_axis() = _amplitude_above_axis;
851 wave->property_wave_color() = _region->muted() ? color_map[cMutedWaveForm] : color_map[cWaveForm];
852 wave->property_clip_color() = color_map[cWaveFormClip];
853 wave->property_zero_color() = color_map[cZeroLine];
854 wave->property_region_start() = _region->start();
855 wave->property_rectified() = (bool) (_flags & WaveformRectified);
856 wave->property_logscaled() = (bool) (_flags & WaveformLogScaled);
858 if (!(_flags & WaveformVisible)) {
862 /* note: calling this function is serialized by the lock
863 held in the peak building thread that signals that
864 peaks are ready for use *or* by the fact that it is
865 called one by one from the GUI thread.
868 if (which < nchans) {
869 tmp_waves[which] = wave;
871 /* n-channel track, >n-channel source */
874 /* see if we're all ready */
876 for (n = 0; n < nchans; ++n) {
877 if (tmp_waves[n] == 0) {
882 if (n == nwaves && waves.empty()) {
883 /* all waves are ready */
884 tmp_waves.resize(nwaves);
889 /* all waves created, don't hook into peaks ready anymore */
890 data_ready_connection.disconnect ();
894 zero_line = new ArdourCanvas::SimpleLine (*group);
895 zero_line->property_x1() = (gdouble) 1.0;
896 zero_line->property_x2() = (gdouble) (_region->length() / samples_per_unit) - 1.0;
897 zero_line->property_color_rgba() = (guint) color_map[cZeroLine];
904 AudioRegionView::peaks_ready_handler (uint32_t which)
906 Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun(*this, &AudioRegionView::create_one_wave), which, false));
910 AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
912 if (gain_line == 0) {
918 /* don't create points that can't be seen */
920 set_envelope_visible (true);
927 nframes_t fx = trackview.editor.pixel_to_frame (x);
929 if (fx > _region->length()) {
933 /* compute vertical fractional position */
935 y = 1.0 - ((y - _y_position) / (_height - NAME_HIGHLIGHT_SIZE));
937 /* map using gain line */
939 gain_line->view_to_model_y (y);
941 trackview.session().begin_reversible_command (_("add gain control point"));
942 XMLNode &before = audio_region()->envelope().get_state();
944 if (!audio_region()->envelope_active()) {
945 XMLNode ®ion_before = audio_region()->get_state();
946 audio_region()->set_envelope_active(true);
947 XMLNode ®ion_after = audio_region()->get_state();
948 trackview.session().add_command (new MementoCommand<AudioRegion>(*(audio_region().get()), ®ion_before, ®ion_after));
951 audio_region()->envelope().add (fx, y);
953 XMLNode &after = audio_region()->envelope().get_state();
954 trackview.session().add_command (new MementoCommand<Curve>(audio_region()->envelope(), &before, &after));
955 trackview.session().commit_reversible_command ();
959 AudioRegionView::remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev)
961 ControlPoint *cp = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"));
962 audio_region()->envelope().erase (cp->model);
966 AudioRegionView::store_flags()
968 XMLNode *node = new XMLNode ("GUI");
970 node->add_property ("waveform-visible", (_flags & WaveformVisible) ? "yes" : "no");
971 node->add_property ("envelope-visible", (_flags & EnvelopeVisible) ? "yes" : "no");
972 node->add_property ("waveform-rectified", (_flags & WaveformRectified) ? "yes" : "no");
973 node->add_property ("waveform-logscaled", (_flags & WaveformLogScaled) ? "yes" : "no");
975 _region->add_extra_xml (*node);
979 AudioRegionView::set_flags (XMLNode* node)
983 if ((prop = node->property ("waveform-visible")) != 0) {
984 if (prop->value() == "yes") {
985 _flags |= WaveformVisible;
989 if ((prop = node->property ("envelope-visible")) != 0) {
990 if (prop->value() == "yes") {
991 _flags |= EnvelopeVisible;
995 if ((prop = node->property ("waveform-rectified")) != 0) {
996 if (prop->value() == "yes") {
997 _flags |= WaveformRectified;
1001 if ((prop = node->property ("waveform-logscaled")) != 0) {
1002 if (prop->value() == "yes") {
1003 _flags |= WaveformLogScaled;
1009 AudioRegionView::set_waveform_shape (WaveformShape shape)
1013 /* this slightly odd approach is to leave the door open to
1014 other "shapes" such as spectral displays, etc.
1027 if (yn != (bool) (_flags & WaveformRectified)) {
1028 for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
1029 (*wave)->property_rectified() = yn;
1041 _flags |= WaveformRectified;
1043 _flags &= ~WaveformRectified;
1050 AudioRegionView::set_waveform_scale (WaveformScale scale)
1052 bool yn = (scale == LogWaveform);
1054 if (yn != (bool) (_flags & WaveformLogScaled)) {
1055 for (vector<WaveView *>::iterator wave = waves.begin(); wave != waves.end() ; ++wave) {
1056 (*wave)->property_logscaled() = yn;
1060 _flags |= WaveformLogScaled;
1062 _flags &= ~WaveformLogScaled;
1070 AudioRegionView::add_ghost (AutomationTimeAxisView& atv)
1072 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&trackview);
1075 double unit_position = _region->position () / samples_per_unit;
1076 GhostRegion* ghost = new GhostRegion (atv, unit_position);
1079 nchans = rtv->get_diskstream()->n_channels().n_audio();
1081 for (uint32_t n = 0; n < nchans; ++n) {
1083 if (n >= audio_region()->n_channels()) {
1087 WaveView *wave = new WaveView(*ghost->group);
1089 wave->property_data_src() = _region.get();
1090 wave->property_cache() = wave_caches[n];
1091 wave->property_cache_updater() = false;
1092 wave->property_channel() = n;
1093 wave->property_length_function() = (gpointer)region_length_from_c;
1094 wave->property_sourcefile_length_function() = (gpointer) sourcefile_length_from_c;
1095 wave->property_peak_function() = (gpointer) region_read_peaks_from_c;
1096 wave->property_x() = 0.0;
1097 wave->property_samples_per_unit() = samples_per_unit;
1098 wave->property_amplitude_above_axis() = _amplitude_above_axis;
1099 wave->property_wave_color() = color_map[cGhostTrackWave];
1100 wave->property_clip_color() = color_map[cGhostTrackWaveClip];
1101 wave->property_zero_color() = color_map[cGhostTrackZeroLine];
1102 wave->property_region_start() = _region->start();
1104 ghost->waves.push_back(wave);
1107 ghost->set_height ();
1108 ghost->set_duration (_region->length() / samples_per_unit);
1109 ghosts.push_back (ghost);
1111 ghost->GoingAway.connect (mem_fun(*this, &AudioRegionView::remove_ghost));
1117 AudioRegionView::entered ()
1119 if (gain_line && _flags & EnvelopeVisible) {
1120 gain_line->show_all_control_points ();
1124 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
1127 if (fade_in_handle) {
1128 fade_in_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1129 fade_out_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1134 AudioRegionView::exited ()
1137 gain_line->hide_all_but_selected_control_points ();
1141 UINT_TO_RGBA(fade_color,&r,&g,&b,&a);
1144 if (fade_in_handle) {
1145 fade_in_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1146 fade_out_handle->property_fill_color_rgba() = RGBA_TO_UINT(r,g,b,a);
1151 AudioRegionView::envelope_active_changed ()
1154 gain_line->set_line_color (audio_region()->envelope_active() ? color_map[cGainLine] : color_map[cGainLineInactive]);
1159 AudioRegionView::set_waveview_data_src()
1162 double unit_length= _region->length() / samples_per_unit;
1164 for (uint32_t n = 0; n < waves.size(); ++n) {
1165 // TODO: something else to let it know the channel
1166 waves[n]->property_data_src() = _region.get();
1169 for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
1171 (*i)->set_duration (unit_length);
1173 for (vector<WaveView*>::iterator w = (*i)->waves.begin(); w != (*i)->waves.end(); ++w) {
1174 (*w)->property_data_src() = _region.get();
1181 AudioRegionView::color_handler (ColorID id, uint32_t val)
1184 case cMutedWaveForm:
1191 case cGainLineInactive:
1193 envelope_active_changed();