X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Faudio_streamview.cc;h=6ce08aa5ebc6c8978193c0ad5843721993b8582d;hb=ccf58b8de23619db9983a45f696fd97e13a15cce;hp=1e43f1dac13f770bcfa92e1598960810c8d645f1;hpb=60454cc8dc1ca5e1819b853b55916d52497d495c;p=ardour.git diff --git a/gtk2_ardour/audio_streamview.cc b/gtk2_ardour/audio_streamview.cc index 1e43f1dac1..6ce08aa5eb 100644 --- a/gtk2_ardour/audio_streamview.cc +++ b/gtk2_ardour/audio_streamview.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2001, 2006 Paul Davis + Copyright (C) 2001, 2006 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,22 +18,26 @@ #include #include +#include #include #include -#include -#include -#include -#include -#include -#include -#include +#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_regionview.h" -#include "taperegionview.h" +#include "audio_region_view.h" +#include "tape_region_view.h" #include "audio_time_axis.h" #include "canvas-waveview.h" #include "canvas-simplerect.h" @@ -45,8 +49,10 @@ #include "rgb_macros.h" #include "gui_thread.h" #include "utils.h" -#include "color.h" +#include "i18n.h" + +using namespace std; using namespace ARDOUR; using namespace PBD; using namespace Editing; @@ -54,85 +60,33 @@ using namespace Editing; AudioStreamView::AudioStreamView (AudioTimeAxisView& tv) : StreamView (tv) { - region_color = _trackview.color(); crossfades_visible = true; - - if (tv.is_audio_track()) - stream_base_color = color_map[cAudioTrackBase]; - else - stream_base_color = color_map[cAudioBusBase]; - - /* set_position() will position the group */ - - canvas_group = new ArdourCanvas::Group(*_trackview.canvas_display); - - canvas_rect = new ArdourCanvas::SimpleRect (*canvas_group); - canvas_rect->property_x1() = 0.0; - canvas_rect->property_y1() = 0.0; - canvas_rect->property_x2() = 1000000.0; - canvas_rect->property_y2() = (double) tv.height; - canvas_rect->property_outline_color_rgba() = color_map[cAudioTrackOutline]; - canvas_rect->property_outline_what() = (guint32) (0x1|0x2|0x8); // outline ends and bottom - canvas_rect->property_fill_color_rgba() = stream_base_color; - - canvas_rect->signal_event().connect (bind (mem_fun (_trackview.editor, &PublicEditor::canvas_stream_view_event), canvas_rect, &_trackview)); - - _samples_per_unit = _trackview.editor.get_current_zoom(); + color_handler (); _amplitude_above_axis = 1.0; - if (_trackview.is_audio_track()) { - _trackview.audio_track()->DiskstreamChanged.connect (mem_fun (*this, &AudioStreamView::diskstream_changed)); - _trackview.session().TransportStateChange.connect (mem_fun (*this, &AudioStreamView::transport_changed)); - _trackview.get_diskstream()->RecordEnableChanged.connect (mem_fun (*this, &AudioStreamView::rec_enable_changed)); - _trackview.session().RecordStateChanged.connect (mem_fun (*this, &AudioStreamView::sess_rec_enable_changed)); - } - - rec_updating = false; - rec_active = false; - use_rec_regions = tv.editor.show_waveforms_recording (); - last_rec_peak_frame = 0; + use_rec_regions = tv.editor().show_waveforms_recording (); - ColorChanged.connect (mem_fun (*this, &AudioStreamView::color_handler)); + Config->ParameterChanged.connect (sigc::mem_fun (*this, &AudioStreamView::parameter_changed)); } AudioStreamView::~AudioStreamView () { - undisplay_diskstream (); - delete canvas_group; } int -AudioStreamView::set_height (gdouble h) -{ - /* limit the values to something sane-ish */ - if (h < 10.0 || h > 1000.0) { - return -1; - } - - StreamView::set_height(h); - - for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) { - (*i)->set_height (h); - } - - return 0; -} - -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)->set_samples_per_unit (spp); + xi->second->set_samples_per_unit (spp); } return 0; } -int +int AudioStreamView::set_amplitude_above_axis (gdouble app) - { RegionViewList::iterator i; @@ -151,77 +105,127 @@ AudioStreamView::set_amplitude_above_axis (gdouble app) return 0; } -void -AudioStreamView::add_region_view_internal (Region *r, bool wait_for_waves) +RegionView* +AudioStreamView::create_region_view (boost::shared_ptr r, bool wait_for_waves, bool recording) { - ENSURE_GUI_THREAD (bind (mem_fun (*this, &AudioStreamView::add_region_view), r)); - - AudioRegion* region = dynamic_cast (r); + AudioRegionView *region_view = 0; + boost::shared_ptr region = boost::dynamic_pointer_cast (r); if (region == 0) { - return; + return 0; } - AudioRegionView *region_view; - list::iterator i; - - for (i = region_views.begin(); i != region_views.end(); ++i) { - if (&(*i)->region() == r) { - - /* great. we already have a AudioRegionView for this Region. use it again. */ - - (*i)->set_valid (true); - return; - } - } - switch (_trackview.audio_track()->mode()) { + + case NonLayered: case Normal: - region_view = new AudioRegionView (canvas_group, _trackview, *region, - _samples_per_unit, region_color); + if (recording) { + region_view = new AudioRegionView (canvas_group, _trackview, region, + _samples_per_unit, region_color, recording, TimeAxisViewItem::Visibility( + TimeAxisViewItem::ShowFrame | TimeAxisViewItem::HideFrameRight)); + } else { + region_view = new AudioRegionView (canvas_group, _trackview, region, + _samples_per_unit, region_color); + } break; case Destructive: - region_view = new TapeAudioRegionView (canvas_group, _trackview, *region, - _samples_per_unit, region_color); + region_view = new TapeAudioRegionView (canvas_group, _trackview, region, + _samples_per_unit, region_color); break; + default: + fatal << string_compose (_("programming error: %1"), "illegal track mode in ::add_region_view_internal") << endmsg; + /*NOTREACHED*/ + } region_view->init (region_color, wait_for_waves); region_view->set_amplitude_above_axis(_amplitude_above_axis); - region_views.push_front (region_view); - - /* follow global waveform setting */ + region_view->set_height (child_height ()); + + /* if its the special single-sample length that we use for rec-regions, make it + insensitive to events + */ + + if (region->length() == 1) { + 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; +} + +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); +// } - region_view->set_waveform_visible(_trackview.editor.show_waveforms()); +// return NULL; +// } +// } +// } + + 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))); - region->GoingAway.connect (mem_fun (*this, &AudioStreamView::remove_region_view)); - RegionViewAdded (region_view); + + return region_view; } void -AudioStreamView::remove_region_view (Region *r) +AudioStreamView::remove_region_view (boost::weak_ptr weak_r) { - ENSURE_GUI_THREAD (bind (mem_fun (*this, &AudioStreamView::remove_region_view), r)); + ENSURE_GUI_THREAD (bind (mem_fun (*this, &AudioStreamView::remove_region_view), weak_r)); - StreamView::remove_region_view(r); - - for (list::iterator i = crossfade_views.begin(); i != crossfade_views.end();) { - list::iterator tmp; - - tmp = i; - ++tmp; - - AudioRegion* ar = dynamic_cast(r); - if (ar && (*i)->crossfade.involves (*ar)) { - delete *i; - crossfade_views.erase (i); + 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; } - - i = tmp; } + + StreamView::remove_region_view(r); } void @@ -230,60 +234,94 @@ AudioStreamView::undisplay_diskstream () StreamView::undisplay_diskstream(); for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) { - delete *i; + delete i->second; } crossfade_views.clear (); } void -AudioStreamView::playlist_modified () +AudioStreamView::playlist_modified_weak (boost::weak_ptr ds) +{ + boost::shared_ptr sp (ds.lock()); + if (sp) { + playlist_modified (sp); + } +} + +void +AudioStreamView::playlist_modified (boost::shared_ptr ds) { - ENSURE_GUI_THREAD (mem_fun (*this, &AudioStreamView::playlist_modified)); + /* we do not allow shared_ptr to be bound to slots */ + ENSURE_GUI_THREAD (bind (mem_fun (*this, &AudioStreamView::playlist_modified_weak), ds)); - StreamView::playlist_modified(); - - /* if the playlist is modified, make sure xfades are on top and all the regionviews are stacked - correctly. - */ + StreamView::playlist_modified (ds); + + /* make sure xfades are on top and all the regionviews are stacked correctly. */ - for (list::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) { - (*i)->get_canvas_group()->raise_to_top(); + for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) { + i->second->get_canvas_group()->raise_to_top(); } } void -AudioStreamView::playlist_changed (Diskstream *ds) +AudioStreamView::playlist_changed_weak (boost::weak_ptr ds) { - ENSURE_GUI_THREAD (bind (mem_fun (*this, &AudioStreamView::playlist_changed), ds)); + boost::shared_ptr sp (ds.lock()); + if (sp) { + playlist_changed (sp); + } +} + +void +AudioStreamView::playlist_changed (boost::shared_ptr ds) +{ + ENSURE_GUI_THREAD (bind ( + mem_fun (*this, &AudioStreamView::playlist_changed_weak), + boost::weak_ptr (ds))); StreamView::playlist_changed(ds); - AudioPlaylist* apl = dynamic_cast(ds->playlist()); - if (apl) - playlist_connections.push_back (apl->NewCrossfade.connect (mem_fun (*this, &AudioStreamView::add_crossfade))); + 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))); + } +} + +void +AudioStreamView::add_crossfade_weak (boost::weak_ptr crossfade) +{ + boost::shared_ptr sp (crossfade.lock()); + + if (!sp) { + return; + } + + add_crossfade (sp); } void -AudioStreamView::add_crossfade (Crossfade *crossfade) +AudioStreamView::add_crossfade (boost::shared_ptr crossfade) { AudioRegionView* lview = 0; AudioRegionView* rview = 0; - ENSURE_GUI_THREAD (bind (mem_fun (*this, &AudioStreamView::add_crossfade), crossfade)); + /* 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 */ - for (list::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) { - if (&(*i)->crossfade == crossfade) { - if (!crossfades_visible) { - (*i)->hide(); - } else { - (*i)->show (); - } - (*i)->set_valid (true); - return; + 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 */ @@ -291,37 +329,40 @@ AudioStreamView::add_crossfade (Crossfade *crossfade) for (list::iterator i = region_views.begin(); i != region_views.end(); ++i) { AudioRegionView* arv = dynamic_cast(*i); - if (!lview && arv && &(arv->region()) == &crossfade->out()) { + if (!lview && arv && (arv->region() == crossfade->out())) { lview = arv; } - if (!rview && arv && &(arv->region()) == &crossfade->in()) { + if (!rview && arv && (arv->region() == crossfade->in())) { rview = arv; } } - CrossfadeView *cv = new CrossfadeView (_trackview.canvas_display, + CrossfadeView *cv = new CrossfadeView (_trackview.canvas_display (), _trackview, - *crossfade, + crossfade, _samples_per_unit, region_color, *lview, *rview); - + cv->set_valid (true); crossfade->Invalidated.connect (mem_fun (*this, &AudioStreamView::remove_crossfade)); - crossfade_views.push_back (cv); - - if (!crossfades_visible) { + crossfade_views[cv->crossfade] = cv; + if (!_trackview.session().config.get_xfades_visible() || !crossfades_visible) { cv->hide (); } + + update_content_height (cv); } void -AudioStreamView::remove_crossfade (Crossfade *xfade) +AudioStreamView::remove_crossfade (boost::shared_ptr r) { - ENSURE_GUI_THREAD (bind (mem_fun (*this, &AudioStreamView::remove_crossfade), xfade)); + ENSURE_GUI_THREAD (bind (mem_fun (*this, &AudioStreamView::remove_crossfade), r)); - for (list::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) { - if (&(*i)->crossfade == xfade) { - delete *i; + 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; } @@ -331,55 +372,54 @@ AudioStreamView::remove_crossfade (Crossfade *xfade) void AudioStreamView::redisplay_diskstream () { - list::iterator i, tmp; - list::iterator xi, tmpx; + 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) { (*i)->set_valid (false); + (*i)->enable_display (false); } + // Flag crossfade views as invalid for (xi = crossfade_views.begin(); xi != crossfade_views.end(); ++xi) { - (*xi)->set_valid (false); - if ((*xi)->visible()) { - (*xi)->show (); + xi->second->set_valid (false); + if (xi->second->visible()) { + xi->second->show (); } } - if (_trackview.is_audio_track()) { - _trackview.get_diskstream()->playlist()->foreach_region (static_cast(this), &StreamView::add_region_view); - AudioPlaylist* apl = dynamic_cast(_trackview.get_diskstream()->playlist()); - if (apl) - apl->foreach_crossfade (this, &AudioStreamView::add_crossfade); - } + // Add and display region and crossfade views, and flag them as valid - for (i = region_views.begin(); i != region_views.end(); ) { - tmp = i; - tmp++; + if (_trackview.is_audio_track()) { + _trackview.get_diskstream()->playlist()->foreach_region( + sigc::hide_return (sigc::mem_fun (*this, &StreamView::add_region_view)) + ); - if (!(*i)->is_valid()) { - delete *i; - region_views.erase (i); - } + boost::shared_ptr apl = boost::dynamic_pointer_cast( + _trackview.get_diskstream()->playlist() + ); - i = tmp; + 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)->valid()) { - delete *xi; + if (!xi->second->valid()) { + delete xi->second; crossfade_views.erase (xi); } xi = tmpx; } - /* now fix layering */ - - playlist_modified (); + // Stack regions by layer, and remove invalid regions + layer_regions(); } void @@ -387,8 +427,9 @@ 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) + if (arv) { arv->set_waveform_visible (yn); + } } } @@ -400,117 +441,131 @@ AudioStreamView::set_waveform_shape (WaveformShape shape) 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 () { - // cerr << _trackview.name() << " streamview SRB\n"; + //cerr << _trackview.name() << " streamview SRB region_views.size() = " << region_views.size() << endl; if (_trackview.session().transport_rolling()) { // cerr << "\trolling\n"; - if (!rec_active && - _trackview.session().record_status() == Session::Recording && + 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()) { /* add a new region, but don't bother if they set use_rec_regions mid-record */ - AudioRegion::SourceList sources; + SourceList sources; - for (list::iterator prc = peak_ready_connections.begin(); prc != peak_ready_connections.end(); ++prc) { + for (list::iterator prc = rec_data_ready_connections.begin(); + prc != rec_data_ready_connections.end(); ++prc) { (*prc).disconnect(); } - peak_ready_connections.clear(); - - // FIXME - AudioDiskstream* ads = dynamic_cast(_trackview.get_diskstream()); - assert(ads); - - for (uint32_t n=0; n < ads->n_channels(); ++n) { - AudioSource *src = (AudioSource *) ads->write_source (n); + rec_data_ready_connections.clear(); + + boost::shared_ptr ads = _trackview.audio_track()->audio_diskstream(); + + for (uint32_t n=0; n < ads->n_channels().n_audio(); ++n) { + boost::shared_ptr src = ads->write_source (n); if (src) { sources.push_back (src); - peak_ready_connections.push_back (src->PeakRangeReady.connect (bind (mem_fun (*this, &AudioStreamView::rec_peak_range_ready), src))); + + rec_data_ready_connections.push_back (src->PeakRangeReady.connect (bind + (mem_fun (*this, &AudioStreamView::rec_peak_range_ready), + boost::weak_ptr(src)))); } } // handle multi - - jack_nframes_t start = 0; + + nframes_t start = 0; if (rec_regions.size() > 0) { - start = rec_regions.back()->start() + _trackview.get_diskstream()->get_captured_frames(rec_regions.size()-1); + start = rec_regions.back().first->start() + + _trackview.get_diskstream()->get_captured_frames(rec_regions.size()-1); } - - AudioRegion * region = new AudioRegion(sources, start, 1 , "", 0, (Region::Flag)(Region::DefaultFlags | Region::DoNotSaveState), false); - region->set_position (_trackview.session().transport_frame(), this); - rec_regions.push_back (region); - /* catch it if it goes away */ - region->GoingAway.connect (mem_fun (*this, &AudioStreamView::remove_rec_region)); - /* we add the region later */ + boost::shared_ptr region (boost::dynamic_pointer_cast( + RegionFactory::create (sources, start, 1, "", 0, Region::DefaultFlags, false))); + assert(region); + region->block_property_changes (); + region->set_position (_trackview.session().transport_frame(), this); + rec_regions.push_back (make_pair(region, (RegionView*)0)); } - + /* start a new rec box */ - AudioTrack* at; + boost::shared_ptr at; at = _trackview.audio_track(); /* we know what it is already */ - AudioDiskstream& ds = at->audio_diskstream(); - jack_nframes_t frame_pos = ds.current_capture_start (); - gdouble xstart = _trackview.editor.frame_to_pixel (frame_pos); + boost::shared_ptr ds = at->audio_diskstream(); + nframes_t frame_pos = ds->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 = color_map[cRecordingRectFill]; + fill_color = ARDOUR_UI::config()->canvasvar_RecordingRect.get(); break; case Destructive: xend = xstart + 2; - fill_color = color_map[cRecordingRectFill]; + 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() = (double) _trackview.height - 1; - rec_rect->property_outline_color_rgba() = color_map[cRecordingRectOutline]; + rec_rect->property_y2() = child_height (); + 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.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)); + screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect ( + 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())) { - screen_update_connection.disconnect(); rec_active = false; rec_updating = false; - } - + } else { // cerr << "\tNOT rolling, rec_rects = " << rec_rects.size() << " rec_regions = " << rec_regions.size() << endl; @@ -520,42 +575,40 @@ AudioStreamView::setup_rec_box () /* disconnect rapid update */ screen_update_connection.disconnect(); - for (list::iterator prc = peak_ready_connections.begin(); prc != peak_ready_connections.end(); ++prc) { + for (list::iterator prc = rec_data_ready_connections.begin(); + prc != rec_data_ready_connections.end(); ++prc) { (*prc).disconnect(); } - peak_ready_connections.clear(); + rec_data_ready_connections.clear(); rec_updating = false; rec_active = false; - last_rec_peak_frame = 0; - + /* remove temp regions */ - for (list::iterator iter=rec_regions.begin(); iter != rec_regions.end(); ) - { - list::iterator tmp; + + for (list,RegionView*> >::iterator iter = rec_regions.begin(); iter != rec_regions.end(); ) { + list,RegionView*> >::iterator tmp; tmp = iter; ++tmp; - /* this will trigger the remove_region_view */ - delete *iter; + (*iter).first->drop_references (); iter = tmp; } - + rec_regions.clear(); // cerr << "\tclear " << rec_rects.size() << " rec rects\n"; - /* transport stopped, clear boxes */ for (vector::iterator iter=rec_rects.begin(); iter != rec_rects.end(); ++iter) { RecBoxInfo &rect = (*iter); delete rect.rectangle; } - + rec_rects.clear(); - + } } } @@ -563,27 +616,33 @@ AudioStreamView::setup_rec_box () void AudioStreamView::foreach_crossfadeview (void (CrossfadeView::*pmf)(void)) { - for (list::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) { - ((*i)->*pmf) (); + for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) { + (i->second->*pmf) (); } } void -AudioStreamView::rec_peak_range_ready (jack_nframes_t start, jack_nframes_t cnt, Source * src) +AudioStreamView::rec_peak_range_ready (nframes_t start, nframes_t cnt, boost::weak_ptr weak_src) { + ENSURE_GUI_THREAD(bind (mem_fun (*this, &AudioStreamView::rec_peak_range_ready), start, cnt, weak_src)); + + boost::shared_ptr src (weak_src.lock()); + + if (!src) { + return; + } + // this is called from the peak building thread - ENSURE_GUI_THREAD(bind (mem_fun (*this, &AudioStreamView::rec_peak_range_ready), start, cnt, src)); - - if (rec_peak_ready_map.size() == 0 || start+cnt > last_rec_peak_frame) { - last_rec_peak_frame = start + cnt; + if (rec_data_ready_map.size() == 0 || start + cnt > last_rec_data_frame) { + last_rec_data_frame = start + cnt; } - rec_peak_ready_map[src] = true; + rec_data_ready_map[src] = true; - if (rec_peak_ready_map.size() == _trackview.get_diskstream()->n_channels()) { + if (rec_data_ready_map.size() == _trackview.get_diskstream()->n_channels().n_audio()) { this->update_rec_regions (); - rec_peak_ready_map.clear(); + rec_data_ready_map.clear(); } } @@ -591,14 +650,12 @@ void AudioStreamView::update_rec_regions () { if (use_rec_regions) { - uint32_t n = 0; - for (list::iterator iter = rec_regions.begin(); iter != rec_regions.end(); n++) { + for (list,RegionView*> >::iterator iter = rec_regions.begin(); + iter != rec_regions.end(); n++) { - list::iterator tmp; - - tmp = iter; + list,RegionView*> >::iterator tmp = iter; ++tmp; if (!canvas_item_visible (rec_rects[n].rectangle)) { @@ -606,18 +663,20 @@ AudioStreamView::update_rec_regions () iter = tmp; continue; } - - // FIXME - AudioRegion * region = dynamic_cast(*iter); - assert(region); - jack_nframes_t origlen = region->length(); + boost::shared_ptr region = boost::dynamic_pointer_cast(iter->first); + if (!region) { + iter = tmp; + continue; + } + + nframes_t origlen = region->length(); - if (region == rec_regions.back() && rec_active) { + if (region == rec_regions.back().first && rec_active) { - if (last_rec_peak_frame > region->start()) { + if (last_rec_data_frame > region->start()) { - jack_nframes_t nlen = last_rec_peak_frame - region->start(); + nframes_t nlen = last_rec_data_frame - region->start(); if (nlen != region->length()) { @@ -628,34 +687,34 @@ AudioStreamView::update_rec_regions () if (origlen == 1) { /* our special initial length */ - add_region_view_internal (region, false); + add_region_view_internal (region, false, true); } /* also update rect */ ArdourCanvas::SimpleRect * rect = rec_rects[n].rectangle; - gdouble xend = _trackview.editor.frame_to_pixel (region->position() + region->length()); + gdouble xend = _trackview.editor().frame_to_pixel (region->position() + region->length()); rect->property_x2() = xend; } } } else { - jack_nframes_t nlen = _trackview.get_diskstream()->get_captured_frames(n); + nframes_t nlen = _trackview.get_diskstream()->get_captured_frames(n); if (nlen != region->length()) { - if (region->source(0).length() >= region->start() + nlen) { + 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"); - + if (origlen == 1) { /* our special initial length */ - add_region_view_internal (region, false); + add_region_view_internal (region, false, true); } - + /* also hide rect */ ArdourCanvas::Item * rect = rec_rects[n].rectangle; rect->hide(); @@ -669,6 +728,28 @@ AudioStreamView::update_rec_regions () } } +void +AudioStreamView::show_all_fades () +{ + for (list::iterator i = region_views.begin(); i != region_views.end(); ++i) { + AudioRegionView* const arv = dynamic_cast(*i); + if (arv) { + arv->set_fade_visibility (true); + } + } +} + +void +AudioStreamView::hide_all_fades () +{ + for (list::iterator i = region_views.begin(); i != region_views.end(); ++i) { + AudioRegionView* const arv = dynamic_cast(*i); + if (arv) { + arv->set_fade_visibility (false); + } + } +} + void AudioStreamView::show_all_xfades () { @@ -686,9 +767,9 @@ AudioStreamView::hide_all_xfades () void AudioStreamView::hide_xfades_involving (AudioRegionView& rv) { - for (list::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) { - if ((*i)->crossfade.involves (rv.audio_region())) { - (*i)->fake_hide (); + for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) { + if (i->second->crossfade->involves (rv.audio_region())) { + i->second->fake_hide (); } } } @@ -696,32 +777,75 @@ AudioStreamView::hide_xfades_involving (AudioRegionView& rv) void AudioStreamView::reveal_xfades_involving (AudioRegionView& rv) { - for (list::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) { - if ((*i)->crossfade.involves (rv.audio_region()) && (*i)->visible()) { - (*i)->show (); + 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 (); } } } void -AudioStreamView::color_handler (ColorID id, uint32_t val) +AudioStreamView::color_handler () { - switch (id) { - case cAudioTrackBase: - if (_trackview.is_audio_track()) { - canvas_rect->property_fill_color_rgba() = val; - } - break; - case cAudioBusBase: - if (!_trackview.is_audio_track()) { - canvas_rect->property_fill_color_rgba() = val; + //case cAudioTrackBase: + if (_trackview.is_track()) { + canvas_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_AudioTrackBase.get(); + } + + //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(); + } else { + canvas_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_AudioBusBase.get(); } - break; - case cAudioTrackOutline: - canvas_rect->property_outline_color_rgba() = val; - break; + } +} - default: - break; +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) +{ + cv->show (); + + 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 ()); } }