X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=gtk2_ardour%2Faudio_streamview.cc;h=a69f398ef45d0ac96c14196c04d44cb4f0d55967;hb=b426e7d5e4c2b2c0071ded015c193f78f16ead78;hp=1ffb37bb7fcf2d6e945898a1969ed2d6308c761a;hpb=2c59ddede5a4b6c1b9227e2a0288561b38f0763f;p=ardour.git diff --git a/gtk2_ardour/audio_streamview.cc b/gtk2_ardour/audio_streamview.cc index 1ffb37bb7f..a69f398ef4 100644 --- a/gtk2_ardour/audio_streamview.cc +++ b/gtk2_ardour/audio_streamview.cc @@ -24,14 +24,17 @@ #include +#include "pbd/stacktrace.h" + #include "ardour/audioplaylist.h" #include "ardour/audioregion.h" #include "ardour/audiofilesource.h" -#include "ardour/audio_diskstream.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 "audio_streamview.h" #include "audio_region_view.h" @@ -58,17 +61,18 @@ using namespace Editing; AudioStreamView::AudioStreamView (AudioTimeAxisView& tv) : StreamView (tv) { - crossfades_visible = true; + crossfades_visible = tv.session()->config.get_xfades_visible (); color_handler (); _amplitude_above_axis = 1.0; - use_rec_regions = tv.editor().show_waveforms_recording (); - - Config->ParameterChanged.connect (sigc::mem_fun (*this, &AudioStreamView::parameter_changed)); + Config->ParameterChanged.connect (*this, invalidator (*this), ui_bind (&AudioStreamView::parameter_changed, this, _1), gui_context()); } AudioStreamView::~AudioStreamView () { + for (CrossfadeViewList::iterator xi = crossfade_views.begin(); xi != crossfade_views.end(); ++xi) { + delete xi->second; + } } int @@ -118,16 +122,19 @@ AudioStreamView::create_region_view (boost::shared_ptr r, bool wait_for_ case NonLayered: case Normal: if (recording) { - region_view = new AudioRegionView (canvas_group, _trackview, region, + region_view = new AudioRegionView (_canvas_group, _trackview, region, _samples_per_unit, region_color, recording, TimeAxisViewItem::Visibility( - TimeAxisViewItem::ShowFrame | TimeAxisViewItem::HideFrameRight)); + TimeAxisViewItem::ShowFrame | + TimeAxisViewItem::HideFrameRight | + TimeAxisViewItem::HideFrameLeft | + TimeAxisViewItem::HideFrameTB)); } else { - region_view = new AudioRegionView (canvas_group, _trackview, region, + region_view = new AudioRegionView (_canvas_group, _trackview, region, _samples_per_unit, region_color); } break; case Destructive: - region_view = new TapeAudioRegionView (canvas_group, _trackview, region, + region_view = new TapeAudioRegionView (_canvas_group, _trackview, region, _samples_per_unit, region_color); break; default: @@ -159,6 +166,7 @@ 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; } @@ -186,8 +194,15 @@ AudioStreamView::add_region_view_internal (boost::shared_ptr r, bool wai region_views.push_front (region_view); - /* catch regionview going away */ - r->GoingAway.connect (bind (mem_fun (*this, &AudioStreamView::remove_region_view), boost::weak_ptr (r))); + 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()); RegionViewAdded (region_view); @@ -197,7 +212,7 @@ AudioStreamView::add_region_view_internal (boost::shared_ptr r, bool wai void AudioStreamView::remove_region_view (boost::weak_ptr weak_r) { - ENSURE_GUI_THREAD (bind (mem_fun (*this, &AudioStreamView::remove_region_view), weak_r)); + ENSURE_GUI_THREAD (*this, &AudioStreamView::remove_region_view, weak_r); boost::shared_ptr r (weak_r.lock()); @@ -205,7 +220,7 @@ AudioStreamView::remove_region_view (boost::weak_ptr weak_r) return; } - if (!_trackview.session().deletion_in_progress()) { + if (!_trackview.session()->deletion_in_progress()) { for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end();) { CrossfadeViewList::iterator tmp; @@ -227,9 +242,9 @@ AudioStreamView::remove_region_view (boost::weak_ptr weak_r) } void -AudioStreamView::undisplay_diskstream () +AudioStreamView::undisplay_track () { - StreamView::undisplay_diskstream(); + StreamView::undisplay_track (); for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) { delete i->second; @@ -239,21 +254,15 @@ AudioStreamView::undisplay_diskstream () } void -AudioStreamView::playlist_modified_weak (boost::weak_ptr ds) +AudioStreamView::playlist_layered (boost::weak_ptr wtr) { - boost::shared_ptr sp (ds.lock()); - if (sp) { - playlist_modified (sp); - } -} + boost::shared_ptr tr (wtr.lock()); -void -AudioStreamView::playlist_modified (boost::shared_ptr ds) -{ - /* we do not allow shared_ptr to be bound to slots */ - ENSURE_GUI_THREAD (bind (mem_fun (*this, &AudioStreamView::playlist_modified_weak), ds)); + if (!tr) { + return; + } - StreamView::playlist_modified (ds); + StreamView::playlist_layered (wtr); /* make sure xfades are on top and all the regionviews are stacked correctly. */ @@ -263,52 +272,37 @@ AudioStreamView::playlist_modified (boost::shared_ptr ds) } void -AudioStreamView::playlist_changed_weak (boost::weak_ptr ds) +AudioStreamView::playlist_switched (boost::weak_ptr wtr) { - boost::shared_ptr sp (ds.lock()); - if (sp) { - playlist_changed (sp); + boost::shared_ptr tr (wtr.lock()); + + if (!tr) { + return; } -} -void -AudioStreamView::playlist_changed (boost::shared_ptr ds) -{ - ENSURE_GUI_THREAD (bind ( - mem_fun (*this, &AudioStreamView::playlist_changed_weak), - boost::weak_ptr (ds))); + playlist_connections.drop_connections (); + + StreamView::playlist_switched (tr); - StreamView::playlist_changed(ds); + boost::shared_ptr apl = boost::dynamic_pointer_cast (tr->playlist()); - boost::shared_ptr apl = boost::dynamic_pointer_cast(ds->playlist()); if (apl) { - playlist_connections.push_back (apl->NewCrossfade.connect ( - mem_fun (*this, &AudioStreamView::add_crossfade))); + apl->NewCrossfade.connect (playlist_connections, invalidator (*this), ui_bind (&AudioStreamView::add_crossfade, this, _1), gui_context()); } } void -AudioStreamView::add_crossfade_weak (boost::weak_ptr crossfade) +AudioStreamView::add_crossfade (boost::weak_ptr wc) { - boost::shared_ptr sp (crossfade.lock()); + boost::shared_ptr crossfade (wc.lock()); - if (!sp) { + if (!crossfade) { return; } - add_crossfade (sp); -} - -void -AudioStreamView::add_crossfade (boost::shared_ptr crossfade) -{ AudioRegionView* lview = 0; AudioRegionView* rview = 0; - /* we do not allow shared_ptr to be bound to slots */ - - ENSURE_GUI_THREAD (bind (mem_fun (*this, &AudioStreamView::add_crossfade_weak), boost::weak_ptr (crossfade))); - /* first see if we already have a CrossfadeView for this Crossfade */ CrossfadeViewList::iterator i = crossfade_views.find (crossfade); @@ -342,9 +336,9 @@ AudioStreamView::add_crossfade (boost::shared_ptr crossfade) region_color, *lview, *rview); cv->set_valid (true); - crossfade->Invalidated.connect (mem_fun (*this, &AudioStreamView::remove_crossfade)); + crossfade->Invalidated.connect (*this, invalidator (*this), ui_bind (&AudioStreamView::remove_crossfade, this, _1), gui_context()); crossfade_views[cv->crossfade] = cv; - if (!_trackview.session().config.get_xfades_visible() || !crossfades_visible) { + if (!crossfades_visible) { cv->hide (); } @@ -354,7 +348,7 @@ AudioStreamView::add_crossfade (boost::shared_ptr crossfade) void AudioStreamView::remove_crossfade (boost::shared_ptr r) { - ENSURE_GUI_THREAD (bind (mem_fun (*this, &AudioStreamView::remove_crossfade), r)); + ENSURE_GUI_THREAD (*this, &AudioStreamView::remove_crossfade, r) boost::shared_ptr xfade = boost::dynamic_pointer_cast (r); @@ -368,7 +362,7 @@ AudioStreamView::remove_crossfade (boost::shared_ptr r) } void -AudioStreamView::redisplay_diskstream () +AudioStreamView::redisplay_track () { list::iterator i; CrossfadeViewList::iterator xi, tmpx; @@ -390,12 +384,12 @@ AudioStreamView::redisplay_diskstream () // Add and display region and crossfade views, and flag them as valid if (_trackview.is_audio_track()) { - _trackview.get_diskstream()->playlist()->foreach_region( + _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.get_diskstream()->playlist() + _trackview.track()->playlist() ); if (apl) { @@ -457,52 +451,54 @@ AudioStreamView::setup_rec_box () { //cerr << _trackview.name() << " streamview SRB region_views.size() = " << region_views.size() << endl; - if (_trackview.session().transport_rolling()) { + if (_trackview.session()->transport_rolling()) { // cerr << "\trolling\n"; if (!rec_active && - _trackview.session().record_status() == Session::Recording && - _trackview.get_diskstream()->record_enabled()) { - if (_trackview.audio_track()->mode() == Normal && use_rec_regions && rec_regions.size() == rec_rects.size()) { + _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()) { - /* add a new region, but don't bother if they set use_rec_regions mid-record */ + /* add a new region, but don't bother if they set show-waveforms-while-recording mid-record */ SourceList sources; - for (list::iterator prc = rec_data_ready_connections.begin(); - prc != rec_data_ready_connections.end(); ++prc) { - (*prc).disconnect(); - } - rec_data_ready_connections.clear(); - - boost::shared_ptr ads = _trackview.audio_track()->audio_diskstream(); + rec_data_ready_connections.drop_connections (); + boost::shared_ptr tr = _trackview.audio_track(); - for (uint32_t n=0; n < ads->n_channels().n_audio(); ++n) { - boost::shared_ptr src = ads->write_source (n); + for (uint32_t n = 0; n < tr->n_channels().n_audio(); ++n) { + boost::shared_ptr src = tr->write_source (n); if (src) { sources.push_back (src); - - rec_data_ready_connections.push_back (src->PeakRangeReady.connect (bind - (mem_fun (*this, &AudioStreamView::rec_peak_range_ready), - boost::weak_ptr(src)))); + src->PeakRangeReady.connect (rec_data_ready_connections, + invalidator (*this), + ui_bind (&AudioStreamView::rec_peak_range_ready, this, _1, _2, boost::weak_ptr(src)), + gui_context()); } } // handle multi - nframes_t start = 0; + framepos_t start = 0; if (rec_regions.size() > 0) { start = rec_regions.back().first->start() - + _trackview.get_diskstream()->get_captured_frames(rec_regions.size()-1); + + _trackview.track()->get_captured_frames(rec_regions.size()-1); } - boost::shared_ptr region (boost::dynamic_pointer_cast( - RegionFactory::create (sources, start, 1, "", 0, Region::DefaultFlags, false))); + PropertyList plist; + + plist.add (Properties::start, start); + plist.add (Properties::length, 1); + plist.add (Properties::name, string()); + plist.add (Properties::layer, 0); + + boost::shared_ptr region ( + boost::dynamic_pointer_cast(RegionFactory::create (sources, plist, false))); + assert(region); - region->block_property_changes (); - region->set_position (_trackview.session().transport_frame(), this); - rec_regions.push_back (make_pair(region, (RegionView*)0)); + region->set_position (_trackview.session()->transport_frame()); + rec_regions.push_back (make_pair(region, (RegionView*) 0)); } /* start a new rec box */ @@ -510,8 +506,7 @@ AudioStreamView::setup_rec_box () boost::shared_ptr at; at = _trackview.audio_track(); /* we know what it is already */ - boost::shared_ptr ds = at->audio_diskstream(); - nframes_t frame_pos = ds->current_capture_start (); + framepos_t const frame_pos = at->current_capture_start (); gdouble xstart = _trackview.editor().frame_to_pixel (frame_pos); gdouble xend; uint32_t fill_color; @@ -533,32 +528,32 @@ AudioStreamView::setup_rec_box () break; } - ArdourCanvas::SimpleRect * rec_rect = new Gnome::Canvas::SimpleRect (*canvas_group); + 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_outline_what() = 0x1 | 0x2 | 0x4 | 0x8; 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.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 ( - mem_fun (*this, &AudioStreamView::update_rec_box)); + sigc::mem_fun (*this, &AudioStreamView::update_rec_box)); rec_updating = true; rec_active = true; } else if (rec_active && - (_trackview.session().record_status() != Session::Recording || - !_trackview.get_diskstream()->record_enabled())) { + (_trackview.session()->record_status() != Session::Recording || + !_trackview.track()->record_enabled())) { screen_update_connection.disconnect(); rec_active = false; rec_updating = false; @@ -572,13 +567,7 @@ AudioStreamView::setup_rec_box () /* disconnect rapid update */ screen_update_connection.disconnect(); - - for (list::iterator prc = rec_data_ready_connections.begin(); - prc != rec_data_ready_connections.end(); ++prc) { - (*prc).disconnect(); - } - rec_data_ready_connections.clear(); - + rec_data_ready_connections.drop_connections (); rec_updating = false; rec_active = false; @@ -620,9 +609,9 @@ AudioStreamView::foreach_crossfadeview (void (CrossfadeView::*pmf)(void)) } void -AudioStreamView::rec_peak_range_ready (nframes_t start, nframes_t cnt, boost::weak_ptr weak_src) +AudioStreamView::rec_peak_range_ready (framepos_t start, framecnt_t cnt, boost::weak_ptr weak_src) { - ENSURE_GUI_THREAD(bind (mem_fun (*this, &AudioStreamView::rec_peak_range_ready), start, cnt, weak_src)); + ENSURE_GUI_THREAD (*this, &AudioStreamView::rec_peak_range_ready, start, cnt, weak_src) boost::shared_ptr src (weak_src.lock()); @@ -638,75 +627,82 @@ AudioStreamView::rec_peak_range_ready (nframes_t start, nframes_t cnt, boost::we rec_data_ready_map[src] = true; - if (rec_data_ready_map.size() == _trackview.get_diskstream()->n_channels().n_audio()) { - this->update_rec_regions (); + if (rec_data_ready_map.size() == _trackview.track()->n_channels().n_audio()) { + update_rec_regions (start, cnt); rec_data_ready_map.clear(); } } void -AudioStreamView::update_rec_regions () +AudioStreamView::update_rec_regions (framepos_t start, framecnt_t cnt) { - if (use_rec_regions) { - uint32_t n = 0; + if (!Config->get_show_waveforms_while_recording ()) { + return; + } - for (list,RegionView*> >::iterator iter = rec_regions.begin(); - iter != rec_regions.end(); n++) { + uint32_t n = 0; - list,RegionView*> >::iterator tmp = iter; - ++tmp; + for (list,RegionView*> >::iterator iter = rec_regions.begin(); iter != rec_regions.end(); n++) { - if (!canvas_item_visible (rec_rects[n].rectangle)) { - /* rect already hidden, this region is done */ - iter = tmp; - continue; - } + list,RegionView*> >::iterator tmp = iter; + ++tmp; - boost::shared_ptr region = boost::dynamic_pointer_cast(iter->first); - if (!region) { - iter = tmp; - continue; - } + assert (n < rec_rects.size()); - nframes_t origlen = region->length(); + if (!canvas_item_visible (rec_rects[n].rectangle)) { + /* rect already hidden, this region is done */ + iter = tmp; + continue; + } - if (region == rec_regions.back().first && rec_active) { + boost::shared_ptr region = boost::dynamic_pointer_cast(iter->first); - if (last_rec_data_frame > region->start()) { + if (!region) { + iter = tmp; + continue; + } - nframes_t nlen = last_rec_data_frame - region->start(); + framecnt_t origlen = region->length(); - if (nlen != region->length()) { + if (region == rec_regions.back().first && rec_active) { - region->freeze (); - region->set_position (_trackview.get_diskstream()->get_capture_start_frame(n), this); - region->set_length (nlen, this); - region->thaw ("updated"); + if (last_rec_data_frame > region->start()) { - if (origlen == 1) { - /* our special initial length */ - add_region_view_internal (region, false, true); - } + framecnt_t nlen = last_rec_data_frame - region->start(); - /* 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; + 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); + setup_new_rec_layer_time (region); } + + 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; } } else { - nframes_t nlen = _trackview.get_diskstream()->get_captured_frames(n); + framecnt_t nlen = _trackview.track()->get_captured_frames(n); if (nlen != region->length()) { if (region->source_length(0) >= region->start() + nlen) { - region->freeze (); - region->set_position (_trackview.get_diskstream()->get_capture_start_frame(n), this); - region->set_length (nlen, this); - region->thaw ("updated"); + 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 */ @@ -720,9 +716,9 @@ AudioStreamView::update_rec_regions () } } } - - iter = tmp; } + + iter = tmp; } } @@ -813,8 +809,6 @@ AudioStreamView::update_contents_height () void AudioStreamView::update_content_height (CrossfadeView* cv) { - cv->show (); - if (_layer_display == Overlaid) { cv->set_y (0); @@ -847,3 +841,14 @@ AudioStreamView::parameter_changed (string const & p) 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 (); + } +} +