X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Faudio_streamview.cc;h=7951848c5959e226715f0e323b842a8bcca96c70;hb=87e95e4bf16226373ecf2d34659df98757787efb;hp=f1dda10516c803627024f5bbf771fa2e732a52f6;hpb=d4d5b30aebb8a54358bfb203c84cfd641bff79f3;p=ardour.git diff --git a/gtk2_ardour/audio_streamview.cc b/gtk2_ardour/audio_streamview.cc index f1dda10516..7951848c59 100644 --- a/gtk2_ardour/audio_streamview.cc +++ b/gtk2_ardour/audio_streamview.cc @@ -26,30 +26,26 @@ #include "pbd/stacktrace.h" -#include "ardour/audioplaylist.h" #include "ardour/audioregion.h" #include "ardour/audiofilesource.h" #include "ardour/audio_track.h" -#include "ardour/source.h" #include "ardour/region_factory.h" #include "ardour/profile.h" #include "ardour/rc_configuration.h" #include "ardour/session.h" +#include "canvas/rectangle.h" + #include "audio_streamview.h" #include "audio_region_view.h" #include "tape_region_view.h" #include "audio_time_axis.h" -#include "canvas-waveview.h" -#include "canvas-simplerect.h" #include "region_selection.h" #include "selection.h" #include "public_editor.h" #include "ardour_ui.h" -#include "crossfade_view.h" #include "rgb_macros.h" #include "gui_thread.h" -#include "utils.h" #include "i18n.h" @@ -61,27 +57,8 @@ using namespace Editing; AudioStreamView::AudioStreamView (AudioTimeAxisView& tv) : StreamView (tv) { - crossfades_visible = tv.session()->config.get_xfades_visible (); color_handler (); _amplitude_above_axis = 1.0; - - Config->ParameterChanged.connect (*this, invalidator (*this), ui_bind (&AudioStreamView::parameter_changed, this, _1), gui_context()); -} - -AudioStreamView::~AudioStreamView () -{ -} - -int -AudioStreamView::set_samples_per_unit (gdouble spp) -{ - StreamView::set_samples_per_unit(spp); - - for (CrossfadeViewList::iterator xi = crossfade_views.begin(); xi != crossfade_views.end(); ++xi) { - xi->second->set_samples_per_unit (spp); - } - - return 0; } int @@ -120,27 +97,27 @@ AudioStreamView::create_region_view (boost::shared_ptr r, bool wait_for_ case Normal: if (recording) { region_view = new AudioRegionView (_canvas_group, _trackview, region, - _samples_per_unit, region_color, recording, TimeAxisViewItem::Visibility( - TimeAxisViewItem::ShowFrame | - TimeAxisViewItem::HideFrameRight | - TimeAxisViewItem::HideFrameLeft | - TimeAxisViewItem::HideFrameTB)); + _samples_per_pixel, region_color, recording, TimeAxisViewItem::Visibility( + TimeAxisViewItem::ShowFrame | + TimeAxisViewItem::HideFrameRight | + TimeAxisViewItem::HideFrameLeft | + TimeAxisViewItem::HideFrameTB)); } else { region_view = new AudioRegionView (_canvas_group, _trackview, region, - _samples_per_unit, region_color); + _samples_per_pixel, region_color); } break; case Destructive: region_view = new TapeAudioRegionView (_canvas_group, _trackview, region, - _samples_per_unit, region_color); + _samples_per_pixel, region_color); break; default: - fatal << string_compose (_("programming error: %1"), "illegal track mode in ::add_region_view_internal") << endmsg; - /*NOTREACHED*/ + fatal << string_compose (_("programming error: %1"), "illegal track mode in ::create_region_view()") << endmsg; + abort(); /*NOTREACHED*/ } - region_view->init (region_color, wait_for_waves); + region_view->init (wait_for_waves); region_view->set_amplitude_above_axis(_amplitude_above_axis); region_view->set_height (child_height ()); @@ -152,10 +129,6 @@ AudioStreamView::create_region_view (boost::shared_ptr r, bool wait_for_ region_view->set_sensitive (false); } - region_view->set_waveform_scale (Config->get_waveform_scale ()); - region_view->set_waveform_shape (Config->get_waveform_shape ()); - region_view->set_waveform_visible (Config->get_show_waveforms ()); - return region_view; } @@ -163,40 +136,13 @@ RegionView* AudioStreamView::add_region_view_internal (boost::shared_ptr r, bool wait_for_waves, bool recording) { RegionView *region_view = create_region_view (r, wait_for_waves, recording); - + if (region_view == 0) { return 0; } -// if(!recording){ -// for (list::iterator i = region_views.begin(); i != region_views.end(); ++i) { -// if ((*i)->region() == r) { -// cerr << "audio_streamview in add_region_view_internal region found" << endl; - /* great. we already have a AudioRegionView for this Region. use it again. */ - -// (*i)->set_valid (true); - - // this might not be necessary -// AudioRegionView* const arv = dynamic_cast(*i); - -// if (arv) { -// arv->set_waveform_scale (_waveform_scale); -// arv->set_waveform_shape (_waveform_shape); -// } - -// return NULL; -// } -// } -// } - region_views.push_front (region_view); - if (_trackview.editor().internal_editing()) { - region_view->hide_rect (); - } else { - region_view->show_rect (); - } - /* catch region going away */ r->DropReferences.connect (*this, invalidator (*this), boost::bind (&AudioStreamView::remove_region_view, this, boost::weak_ptr (r)), gui_context()); @@ -206,163 +152,10 @@ AudioStreamView::add_region_view_internal (boost::shared_ptr r, bool wai return region_view; } -void -AudioStreamView::remove_region_view (boost::weak_ptr weak_r) -{ - ENSURE_GUI_THREAD (*this, &AudioStreamView::remove_region_view, weak_r); - - boost::shared_ptr r (weak_r.lock()); - - if (!r) { - return; - } - - if (!_trackview.session()->deletion_in_progress()) { - - for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end();) { - CrossfadeViewList::iterator tmp; - - tmp = i; - ++tmp; - - boost::shared_ptr ar = boost::dynamic_pointer_cast(r); - if (ar && i->second->crossfade->involves (ar)) { - delete i->second; - crossfade_views.erase (i); - } - - i = tmp; - } - } - - StreamView::remove_region_view(r); -} - -void -AudioStreamView::undisplay_track () -{ - StreamView::undisplay_track (); - - for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) { - delete i->second; - } - - crossfade_views.clear (); -} - -void -AudioStreamView::playlist_layered (boost::weak_ptr wtr) -{ - boost::shared_ptr tr (wtr.lock()); - - if (!tr) { - return; - } - - StreamView::playlist_layered (wtr); - - /* make sure xfades are on top and all the regionviews are stacked correctly. */ - - for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) { - i->second->get_canvas_group()->raise_to_top(); - } -} - -void -AudioStreamView::playlist_switched (boost::weak_ptr wtr) -{ - boost::shared_ptr tr (wtr.lock()); - - if (!tr) { - return; - } - - playlist_connections.drop_connections (); - - StreamView::playlist_switched (tr); - - boost::shared_ptr apl = boost::dynamic_pointer_cast (tr->playlist()); - - if (apl) { - apl->NewCrossfade.connect (playlist_connections, invalidator (*this), ui_bind (&AudioStreamView::add_crossfade, this, _1), gui_context()); - } -} - -void -AudioStreamView::add_crossfade (boost::weak_ptr wc) -{ - boost::shared_ptr crossfade (wc.lock()); - - if (!crossfade) { - return; - } - - AudioRegionView* lview = 0; - AudioRegionView* rview = 0; - - /* first see if we already have a CrossfadeView for this Crossfade */ - - CrossfadeViewList::iterator i = crossfade_views.find (crossfade); - if (i != crossfade_views.end()) { - if (!crossfades_visible) { - i->second->hide(); - } else { - i->second->show (); - } - i->second->set_valid (true); - return; - } - - /* create a new one */ - - for (list::iterator i = region_views.begin(); i != region_views.end(); ++i) { - AudioRegionView* arv = dynamic_cast(*i); - - if (!lview && arv && (arv->region() == crossfade->out())) { - lview = arv; - } - if (!rview && arv && (arv->region() == crossfade->in())) { - rview = arv; - } - } - - CrossfadeView *cv = new CrossfadeView (_trackview.canvas_display (), - _trackview, - crossfade, - _samples_per_unit, - region_color, - *lview, *rview); - cv->set_valid (true); - crossfade->Invalidated.connect (*this, invalidator (*this), ui_bind (&AudioStreamView::remove_crossfade, this, _1), gui_context()); - crossfade_views[cv->crossfade] = cv; - if (!crossfades_visible) { - cv->hide (); - } - - update_content_height (cv); -} - -void -AudioStreamView::remove_crossfade (boost::shared_ptr r) -{ - ENSURE_GUI_THREAD (*this, &AudioStreamView::remove_crossfade, r) - - boost::shared_ptr xfade = boost::dynamic_pointer_cast (r); - - for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) { - if (i->second->crossfade == xfade) { - delete i->second; - crossfade_views.erase (i); - break; - } - } -} - void AudioStreamView::redisplay_track () { list::iterator i; - CrossfadeViewList::iterator xi, tmpx; // Flag region views as invalid and disable drawing for (i = region_views.begin(); i != region_views.end(); ++i) { @@ -370,79 +163,17 @@ AudioStreamView::redisplay_track () (*i)->enable_display (false); } - // Flag crossfade views as invalid - for (xi = crossfade_views.begin(); xi != crossfade_views.end(); ++xi) { - xi->second->set_valid (false); - if (xi->second->visible()) { - xi->second->show (); - } - } - - // Add and display region and crossfade views, and flag them as valid - + // Add and display views, and flag them as valid if (_trackview.is_audio_track()) { _trackview.track()->playlist()->foreach_region( sigc::hide_return (sigc::mem_fun (*this, &StreamView::add_region_view)) ); - - boost::shared_ptr apl = boost::dynamic_pointer_cast( - _trackview.track()->playlist() - ); - - if (apl) { - apl->foreach_crossfade (sigc::mem_fun (*this, &AudioStreamView::add_crossfade)); - } - } - - // Remove invalid crossfade views - for (xi = crossfade_views.begin(); xi != crossfade_views.end();) { - tmpx = xi; - tmpx++; - - if (!xi->second->valid()) { - delete xi->second; - crossfade_views.erase (xi); - } - - xi = tmpx; } // Stack regions by layer, and remove invalid regions layer_regions(); } -void -AudioStreamView::set_show_waveforms (bool yn) -{ - for (list::iterator i = region_views.begin(); i != region_views.end(); ++i) { - AudioRegionView* const arv = dynamic_cast(*i); - if (arv) { - arv->set_waveform_visible (yn); - } - } -} - -void -AudioStreamView::set_waveform_shape (WaveformShape shape) -{ - for (RegionViewList::iterator i = region_views.begin(); i != region_views.end(); ++i) { - AudioRegionView* const arv = dynamic_cast(*i); - if (arv) - arv->set_waveform_shape (shape); - } -} - -void -AudioStreamView::set_waveform_scale (WaveformScale scale) -{ - for (RegionViewList::iterator i = region_views.begin(); i != region_views.end(); ++i) { - AudioRegionView* const arv = dynamic_cast(*i); - if (arv) { - arv->set_waveform_scale (scale); - } - } -} - void AudioStreamView::setup_rec_box () { @@ -455,7 +186,7 @@ AudioStreamView::setup_rec_box () if (!rec_active && _trackview.session()->record_status() == Session::Recording && _trackview.track()->record_enabled()) { - if (_trackview.audio_track()->mode() == Normal && Config->get_show_waveforms_while_recording() && rec_regions.size() == rec_rects.size()) { + if (_trackview.audio_track()->mode() == Normal && ARDOUR_UI::config()->get_show_waveforms_while_recording() && rec_regions.size() == rec_rects.size()) { /* add a new region, but don't bother if they set show-waveforms-while-recording mid-record */ @@ -470,7 +201,7 @@ AudioStreamView::setup_rec_box () sources.push_back (src); src->PeakRangeReady.connect (rec_data_ready_connections, invalidator (*this), - ui_bind (&AudioStreamView::rec_peak_range_ready, this, _1, _2, boost::weak_ptr(src)), + boost::bind (&AudioStreamView::rec_peak_range_ready, this, _1, _2, boost::weak_ptr(src)), gui_context()); } } @@ -483,8 +214,8 @@ AudioStreamView::setup_rec_box () + _trackview.track()->get_captured_frames(rec_regions.size()-1); } - PropertyList plist; - + PropertyList plist; + plist.add (Properties::start, start); plist.add (Properties::length, 1); plist.add (Properties::name, string()); @@ -500,53 +231,11 @@ AudioStreamView::setup_rec_box () /* start a new rec box */ - boost::shared_ptr at; - - at = _trackview.audio_track(); /* we know what it is already */ + boost::shared_ptr at = _trackview.audio_track(); framepos_t const frame_pos = at->current_capture_start (); - gdouble xstart = _trackview.editor().frame_to_pixel (frame_pos); - gdouble xend; - uint32_t fill_color; - - switch (_trackview.audio_track()->mode()) { - case Normal: - case NonLayered: - xend = xstart; - fill_color = ARDOUR_UI::config()->canvasvar_RecordingRect.get(); - break; + double const width = ((at->mode() == Destructive) ? 2 : 0); - case Destructive: - xend = xstart + 2; - fill_color = ARDOUR_UI::config()->canvasvar_RecordingRect.get(); - /* make the recording rect translucent to allow - the user to see the peak data coming in, etc. - */ - fill_color = UINT_RGBA_CHANGE_A (fill_color, 120); - break; - } - - ArdourCanvas::SimpleRect * rec_rect = new Gnome::Canvas::SimpleRect (*_canvas_group); - rec_rect->property_x1() = xstart; - rec_rect->property_y1() = 1.0; - rec_rect->property_x2() = xend; - rec_rect->property_y2() = child_height (); - rec_rect->property_outline_what() = 0x0; - rec_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeAxisFrame.get(); - rec_rect->property_fill_color_rgba() = fill_color; - rec_rect->lower_to_bottom(); - - RecBoxInfo recbox; - recbox.rectangle = rec_rect; - recbox.start = _trackview.session()->transport_frame(); - recbox.length = 0; - - rec_rects.push_back (recbox); - - screen_update_connection.disconnect(); - screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect ( - sigc::mem_fun (*this, &AudioStreamView::update_rec_box)); - rec_updating = true; - rec_active = true; + create_rec_box(frame_pos, width); } else if (rec_active && (_trackview.session()->record_status() != Session::Recording || @@ -597,14 +286,6 @@ AudioStreamView::setup_rec_box () } } -void -AudioStreamView::foreach_crossfadeview (void (CrossfadeView::*pmf)(void)) -{ - for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) { - (i->second->*pmf) (); - } -} - void AudioStreamView::rec_peak_range_ready (framepos_t start, framecnt_t cnt, boost::weak_ptr weak_src) { @@ -633,47 +314,47 @@ AudioStreamView::rec_peak_range_ready (framepos_t start, framecnt_t cnt, boost:: void AudioStreamView::update_rec_regions (framepos_t start, framecnt_t cnt) { - if (!Config->get_show_waveforms_while_recording ()) { + if (!ARDOUR_UI::config()->get_show_waveforms_while_recording ()) { return; } - + uint32_t n = 0; - + for (list,RegionView*> >::iterator iter = rec_regions.begin(); iter != rec_regions.end(); n++) { - + list,RegionView*> >::iterator tmp = iter; ++tmp; assert (n < rec_rects.size()); - - if (!canvas_item_visible (rec_rects[n].rectangle)) { + + if (!rec_rects[n].rectangle->visible()) { /* rect already hidden, this region is done */ iter = tmp; continue; } - + boost::shared_ptr region = boost::dynamic_pointer_cast(iter->first); - + if (!region) { iter = tmp; continue; } - + framecnt_t origlen = region->length(); if (region == rec_regions.back().first && rec_active) { - + if (last_rec_data_frame > region->start()) { - + framecnt_t nlen = last_rec_data_frame - region->start(); - + if (nlen != region->length()) { region->suspend_property_changes (); region->set_position (_trackview.track()->get_capture_start_frame(n)); region->set_length (nlen); region->resume_property_changes (); - + if (origlen == 1) { /* our special initial length */ add_region_view_internal (region, false, true); @@ -681,19 +362,19 @@ AudioStreamView::update_rec_regions (framepos_t start, framecnt_t cnt) } check_record_layers (region, (region->position() - region->start() + start + cnt)); - + /* also update rect */ - ArdourCanvas::SimpleRect * rect = rec_rects[n].rectangle; - gdouble xend = _trackview.editor().frame_to_pixel (region->position() + region->length()); - rect->property_x2() = xend; + ArdourCanvas::Rectangle * rect = rec_rects[n].rectangle; + gdouble xend = _trackview.editor().sample_to_pixel (region->position() + region->length()); + rect->set_x1 (xend); } } else { - + framecnt_t nlen = _trackview.track()->get_captured_frames(n); - + if (nlen != region->length()) { - + if (region->source_length(0) >= region->start() + nlen) { region->suspend_property_changes (); @@ -741,38 +422,36 @@ AudioStreamView::hide_all_fades () } } -void -AudioStreamView::show_all_xfades () -{ - foreach_crossfadeview (&CrossfadeView::show); - crossfades_visible = true; -} - -void -AudioStreamView::hide_all_xfades () -{ - foreach_crossfadeview (&CrossfadeView::hide); - crossfades_visible = false; -} - -void -AudioStreamView::hide_xfades_involving (AudioRegionView& rv) +/** Hide xfades for regions that overlap ar. + * @return Pair of lists; first is the AudioRegionViews that start xfades were hidden for, + * second is the AudioRegionViews that end xfades were hidden for. + */ +pair, list > +AudioStreamView::hide_xfades_with (boost::shared_ptr ar) { - for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) { - if (i->second->crossfade->involves (rv.audio_region())) { - i->second->fake_hide (); + list start_hidden; + list end_hidden; + + for (list::iterator i = region_views.begin(); i != region_views.end(); ++i) { + AudioRegionView* const arv = dynamic_cast(*i); + if (arv) { + switch (arv->region()->coverage (ar->position(), ar->last_frame())) { + case Evoral::OverlapNone: + break; + default: + if (arv->start_xfade_visible ()) { + start_hidden.push_back (arv); + } + if (arv->end_xfade_visible ()) { + end_hidden.push_back (arv); + } + arv->hide_xfades (); + break; + } } } -} -void -AudioStreamView::reveal_xfades_involving (AudioRegionView& rv) -{ - for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) { - if (i->second->crossfade->involves (rv.audio_region()) && i->second->visible()) { - i->second->show (); - } - } + return make_pair (start_hidden, end_hidden); } void @@ -780,72 +459,15 @@ AudioStreamView::color_handler () { //case cAudioTrackBase: if (_trackview.is_track()) { - canvas_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_AudioTrackBase.get(); + canvas_rect->set_fill_color (ARDOUR_UI::config()->color_mod ("audio track base", "audio track base")); } //case cAudioBusBase: if (!_trackview.is_track()) { if (Profile->get_sae() && _trackview.route()->is_master()) { - canvas_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_AudioMasterBusBase.get(); + canvas_rect->set_fill_color (ARDOUR_UI::config()->color ("audio master bus base")); } else { - canvas_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_AudioBusBase.get(); + canvas_rect->set_fill_color (ARDOUR_UI::config()->color_mod ("audio bus base", "audio bus base")); } } } - -void -AudioStreamView::update_contents_height () -{ - StreamView::update_contents_height (); - - for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) { - update_content_height (i->second); - } -} - -void -AudioStreamView::update_content_height (CrossfadeView* cv) -{ - if (_layer_display == Overlaid) { - - cv->set_y (0); - cv->set_height (height); - - } else { - - layer_t const inl = cv->crossfade->in()->layer (); - layer_t const outl = cv->crossfade->out()->layer (); - - layer_t const high = max (inl, outl); - layer_t const low = min (inl, outl); - - const double h = child_height (); - - cv->set_y ((_layers - high - 1) * h); - cv->set_height ((high - low + 1) * h); - - } -} - -void -AudioStreamView::parameter_changed (string const & p) -{ - if (p == "show-waveforms") { - set_show_waveforms (Config->get_show_waveforms ()); - } else if (p == "waveform-scale") { - set_waveform_scale (Config->get_waveform_scale ()); - } else if (p == "waveform-shape") { - set_waveform_shape (Config->get_waveform_shape ()); - } -} - -void -AudioStreamView::horizontal_position_changed () -{ - /* we only `draw' the bit of the curve that is visible, so we need to update here */ - - for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) { - i->second->horizontal_position_changed (); - } -} -