2006-07-23 08:03:19 -04:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 2001, 2006 Paul Davis
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
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
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
#include <cassert>
|
2007-05-31 17:37:20 -04:00
|
|
|
#include <utility>
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
#include <gtkmm.h>
|
|
|
|
|
|
|
|
#include <gtkmm2ext/gtk_ui.h>
|
|
|
|
|
2010-01-25 15:34:09 -05:00
|
|
|
#include "pbd/stacktrace.h"
|
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/audioregion.h"
|
|
|
|
#include "ardour/audiofilesource.h"
|
|
|
|
#include "ardour/audio_track.h"
|
|
|
|
#include "ardour/region_factory.h"
|
|
|
|
#include "ardour/profile.h"
|
2009-10-30 11:30:22 -04:00
|
|
|
#include "ardour/rc_configuration.h"
|
|
|
|
#include "ardour/session.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
#include "canvas/rectangle.h"
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
#include "audio_streamview.h"
|
2006-08-01 13:19:38 -04:00
|
|
|
#include "audio_region_view.h"
|
|
|
|
#include "tape_region_view.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
#include "audio_time_axis.h"
|
|
|
|
#include "region_selection.h"
|
|
|
|
#include "selection.h"
|
|
|
|
#include "public_editor.h"
|
|
|
|
#include "ardour_ui.h"
|
|
|
|
#include "rgb_macros.h"
|
|
|
|
#include "gui_thread.h"
|
|
|
|
#include "utils.h"
|
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
#include "i18n.h"
|
|
|
|
|
2007-05-31 17:37:20 -04:00
|
|
|
using namespace std;
|
2006-07-23 08:03:19 -04:00
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace PBD;
|
|
|
|
using namespace Editing;
|
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
AudioStreamView::AudioStreamView (AudioTimeAxisView& tv)
|
2006-07-23 08:03:19 -04:00
|
|
|
: StreamView (tv)
|
|
|
|
{
|
2008-09-29 16:35:44 -04:00
|
|
|
color_handler ();
|
2006-07-23 08:03:19 -04:00
|
|
|
_amplitude_above_axis = 1.0;
|
|
|
|
}
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
int
|
2006-07-23 08:03:19 -04:00
|
|
|
AudioStreamView::set_amplitude_above_axis (gdouble app)
|
|
|
|
{
|
|
|
|
RegionViewList::iterator i;
|
|
|
|
|
|
|
|
if (app < 1.0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
_amplitude_above_axis = app;
|
|
|
|
|
|
|
|
for (i = region_views.begin(); i != region_views.end(); ++i) {
|
|
|
|
AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*i);
|
|
|
|
if (arv)
|
|
|
|
arv->set_amplitude_above_axis (app);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-05-31 17:37:20 -04:00
|
|
|
RegionView*
|
2009-06-08 15:28:51 -04:00
|
|
|
AudioStreamView::create_region_view (boost::shared_ptr<Region> r, bool wait_for_waves, bool recording)
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2007-01-28 12:44:13 -05:00
|
|
|
AudioRegionView *region_view = 0;
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<AudioRegion> region = boost::dynamic_pointer_cast<AudioRegion> (r);
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
if (region == 0) {
|
2009-06-08 15:28:51 -04:00
|
|
|
return 0;
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
switch (_trackview.audio_track()->mode()) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-04-20 17:02:46 -04:00
|
|
|
case NonLayered:
|
2006-07-23 08:03:19 -04:00
|
|
|
case Normal:
|
2008-09-10 11:03:30 -04:00
|
|
|
if (recording) {
|
2010-05-22 22:42:37 -04:00
|
|
|
region_view = new AudioRegionView (_canvas_group, _trackview, region,
|
2013-04-12 11:31:50 -04:00
|
|
|
_samples_per_pixel, region_color, recording, TimeAxisViewItem::Visibility(
|
2013-04-04 18:45:27 -04:00
|
|
|
TimeAxisViewItem::ShowFrame |
|
|
|
|
TimeAxisViewItem::HideFrameRight |
|
|
|
|
TimeAxisViewItem::HideFrameLeft |
|
|
|
|
TimeAxisViewItem::HideFrameTB));
|
2008-09-10 11:03:30 -04:00
|
|
|
} else {
|
2010-05-22 22:42:37 -04:00
|
|
|
region_view = new AudioRegionView (_canvas_group, _trackview, region,
|
2013-04-12 11:31:50 -04:00
|
|
|
_samples_per_pixel, region_color);
|
2008-09-10 11:03:30 -04:00
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
break;
|
|
|
|
case Destructive:
|
2010-05-22 22:42:37 -04:00
|
|
|
region_view = new TapeAudioRegionView (_canvas_group, _trackview, region,
|
2013-04-12 11:31:50 -04:00
|
|
|
_samples_per_pixel, region_color);
|
2006-07-23 08:03:19 -04:00
|
|
|
break;
|
2007-01-28 12:44:13 -05:00
|
|
|
default:
|
|
|
|
fatal << string_compose (_("programming error: %1"), "illegal track mode in ::add_region_view_internal") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
region_view->init (region_color, wait_for_waves);
|
|
|
|
region_view->set_amplitude_above_axis(_amplitude_above_axis);
|
2009-01-01 12:45:09 -05:00
|
|
|
region_view->set_height (child_height ());
|
2007-01-09 18:24:54 -05:00
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
/* if its the special single-sample length that we use for rec-regions, make it
|
|
|
|
insensitive to events
|
2007-04-12 19:20:37 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
if (region->length() == 1) {
|
|
|
|
region_view->set_sensitive (false);
|
|
|
|
}
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
return region_view;
|
2009-06-08 15:28:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
RegionView*
|
|
|
|
AudioStreamView::add_region_view_internal (boost::shared_ptr<Region> r, bool wait_for_waves, bool recording)
|
|
|
|
{
|
|
|
|
RegionView *region_view = create_region_view (r, wait_for_waves, recording);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-06-08 15:28:51 -04:00
|
|
|
if (region_view == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if(!recording){
|
|
|
|
// for (list<RegionView *>::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. */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-08 15:28:51 -04:00
|
|
|
// (*i)->set_valid (true);
|
|
|
|
|
|
|
|
// this might not be necessary
|
|
|
|
// AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*i);
|
|
|
|
|
|
|
|
// if (arv) {
|
|
|
|
// arv->set_waveform_scale (_waveform_scale);
|
|
|
|
// arv->set_waveform_shape (_waveform_shape);
|
|
|
|
// }
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-08 15:28:51 -04:00
|
|
|
// return NULL;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
region_views.push_front (region_view);
|
|
|
|
|
2011-03-07 20:49:13 -05:00
|
|
|
if (_trackview.editor().internal_editing()) {
|
|
|
|
region_view->hide_rect ();
|
|
|
|
} else {
|
|
|
|
region_view->show_rect ();
|
|
|
|
}
|
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
/* catch region going away */
|
|
|
|
|
2010-03-30 11:18:43 -04:00
|
|
|
r->DropReferences.connect (*this, invalidator (*this), boost::bind (&AudioStreamView::remove_region_view, this, boost::weak_ptr<Region> (r)), gui_context());
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
RegionViewAdded (region_view);
|
2007-05-31 17:37:20 -04:00
|
|
|
|
|
|
|
return region_view;
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-04-21 16:42:22 -04:00
|
|
|
AudioStreamView::redisplay_track ()
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2009-02-15 15:31:05 -05:00
|
|
|
list<RegionView *>::iterator i;
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2009-02-15 15:31:05 -05:00
|
|
|
// Flag region views as invalid and disable drawing
|
2006-07-23 08:03:19 -04:00
|
|
|
for (i = region_views.begin(); i != region_views.end(); ++i) {
|
|
|
|
(*i)->set_valid (false);
|
2009-02-15 15:31:05 -05:00
|
|
|
(*i)->enable_display (false);
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
2012-04-16 12:32:22 -04:00
|
|
|
// Add and display views, and flag them as valid
|
2009-07-09 13:58:13 -04:00
|
|
|
if (_trackview.is_audio_track()) {
|
2010-04-21 16:42:22 -04:00
|
|
|
_trackview.track()->playlist()->foreach_region(
|
2009-06-08 15:28:51 -04:00
|
|
|
sigc::hide_return (sigc::mem_fun (*this, &StreamView::add_region_view))
|
2009-06-02 20:23:34 -04:00
|
|
|
);
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
2009-02-15 15:31:05 -05:00
|
|
|
|
|
|
|
// Stack regions by layer, and remove invalid regions
|
|
|
|
layer_regions();
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioStreamView::setup_rec_box ()
|
|
|
|
{
|
2009-07-09 13:58:13 -04:00
|
|
|
//cerr << _trackview.name() << " streamview SRB region_views.size() = " << region_views.size() << endl;
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if (_trackview.session()->transport_rolling()) {
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
// cerr << "\trolling\n";
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
if (!rec_active &&
|
2009-12-17 13:24:23 -05:00
|
|
|
_trackview.session()->record_status() == Session::Recording &&
|
2010-04-21 16:42:22 -04:00
|
|
|
_trackview.track()->record_enabled()) {
|
2010-04-18 21:40:42 -04:00
|
|
|
if (_trackview.audio_track()->mode() == Normal && Config->get_show_waveforms_while_recording() && rec_regions.size() == rec_rects.size()) {
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2010-04-18 21:40:42 -04:00
|
|
|
/* add a new region, but don't bother if they set show-waveforms-while-recording mid-record */
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
SourceList sources;
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
rec_data_ready_connections.drop_connections ();
|
2010-04-21 16:42:22 -04:00
|
|
|
boost::shared_ptr<AudioTrack> tr = _trackview.audio_track();
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2010-04-21 16:42:22 -04:00
|
|
|
for (uint32_t n = 0; n < tr->n_channels().n_audio(); ++n) {
|
|
|
|
boost::shared_ptr<AudioFileSource> src = tr->write_source (n);
|
2006-07-23 08:03:19 -04:00
|
|
|
if (src) {
|
|
|
|
sources.push_back (src);
|
2009-12-21 13:23:07 -05:00
|
|
|
src->PeakRangeReady.connect (rec_data_ready_connections,
|
2010-11-25 15:37:39 -05:00
|
|
|
invalidator (*this),
|
2012-04-25 08:58:19 -04:00
|
|
|
boost::bind (&AudioStreamView::rec_peak_range_ready, this, _1, _2, boost::weak_ptr<Source>(src)),
|
2010-11-25 15:37:39 -05:00
|
|
|
gui_context());
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// handle multi
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-12-03 17:26:29 -05:00
|
|
|
framepos_t start = 0;
|
2006-07-23 08:03:19 -04:00
|
|
|
if (rec_regions.size() > 0) {
|
2009-10-21 12:26:18 -04:00
|
|
|
start = rec_regions.back().first->start()
|
2010-04-21 16:42:22 -04:00
|
|
|
+ _trackview.track()->get_captured_frames(rec_regions.size()-1);
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2011-06-01 13:00:29 -04:00
|
|
|
PropertyList plist;
|
|
|
|
|
2010-02-18 08:59:49 -05:00
|
|
|
plist.add (Properties::start, start);
|
|
|
|
plist.add (Properties::length, 1);
|
|
|
|
plist.add (Properties::name, string());
|
|
|
|
plist.add (Properties::layer, 0);
|
|
|
|
|
|
|
|
boost::shared_ptr<AudioRegion> region (
|
|
|
|
boost::dynamic_pointer_cast<AudioRegion>(RegionFactory::create (sources, plist, false)));
|
|
|
|
|
2006-09-18 23:29:16 -04:00
|
|
|
assert(region);
|
2011-05-30 09:54:44 -04:00
|
|
|
region->set_position (_trackview.session()->transport_frame());
|
2010-07-16 16:03:16 -04:00
|
|
|
rec_regions.push_back (make_pair(region, (RegionView*) 0));
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
/* start a new rec box */
|
|
|
|
|
2007-06-15 18:05:07 -04:00
|
|
|
boost::shared_ptr<AudioTrack> at;
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
at = _trackview.audio_track(); /* we know what it is already */
|
2010-10-08 10:54:16 -04:00
|
|
|
framepos_t const frame_pos = at->current_capture_start ();
|
2013-04-12 11:15:45 -04:00
|
|
|
gdouble xstart = _trackview.editor().sample_to_pixel (frame_pos);
|
2013-11-04 21:32:41 -05:00
|
|
|
gdouble xend = xstart; /* keeps gcc optimized happy, really set in switch() below */
|
2006-07-23 08:03:19 -04:00
|
|
|
uint32_t fill_color;
|
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
switch (_trackview.audio_track()->mode()) {
|
2006-07-23 08:03:19 -04:00
|
|
|
case Normal:
|
2009-04-20 17:02:46 -04:00
|
|
|
case NonLayered:
|
2006-07-23 08:03:19 -04:00
|
|
|
xend = xstart;
|
2013-04-16 23:46:22 -04:00
|
|
|
fill_color = ARDOUR_UI::config()->get_canvasvar_RecordingRect();
|
2006-07-23 08:03:19 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Destructive:
|
|
|
|
xend = xstart + 2;
|
2013-04-16 23:46:22 -04:00
|
|
|
fill_color = ARDOUR_UI::config()->get_canvasvar_RecordingRect();
|
2006-07-23 08:03:19 -04:00
|
|
|
/* 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;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
ArdourCanvas::Rectangle * rec_rect = new ArdourCanvas::Rectangle (_canvas_group);
|
|
|
|
rec_rect->set_x0 (xstart);
|
|
|
|
rec_rect->set_y0 (1);
|
|
|
|
rec_rect->set_x1 (xend);
|
|
|
|
rec_rect->set_y1 (child_height ());
|
2014-03-11 07:39:25 -04:00
|
|
|
rec_rect->set_outline_what (ArdourCanvas::Rectangle::What (0));
|
2013-04-16 23:46:22 -04:00
|
|
|
rec_rect->set_outline_color (ARDOUR_UI::config()->get_canvasvar_TimeAxisFrame());
|
2013-04-04 00:32:52 -04:00
|
|
|
rec_rect->set_fill_color (fill_color);
|
2007-05-31 17:37:20 -04:00
|
|
|
rec_rect->lower_to_bottom();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
RecBoxInfo recbox;
|
|
|
|
recbox.rectangle = rec_rect;
|
2009-12-17 13:24:23 -05:00
|
|
|
recbox.start = _trackview.session()->transport_frame();
|
2006-07-23 08:03:19 -04:00
|
|
|
recbox.length = 0;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
rec_rects.push_back (recbox);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
screen_update_connection.disconnect();
|
2009-10-21 12:26:18 -04:00
|
|
|
screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (
|
2009-12-11 18:29:48 -05:00
|
|
|
sigc::mem_fun (*this, &AudioStreamView::update_rec_box));
|
2006-07-23 08:03:19 -04:00
|
|
|
rec_updating = true;
|
|
|
|
rec_active = true;
|
|
|
|
|
|
|
|
} else if (rec_active &&
|
2009-12-17 13:24:23 -05:00
|
|
|
(_trackview.session()->record_status() != Session::Recording ||
|
2010-04-21 16:42:22 -04:00
|
|
|
!_trackview.track()->record_enabled())) {
|
2006-07-23 08:03:19 -04:00
|
|
|
screen_update_connection.disconnect();
|
|
|
|
rec_active = false;
|
|
|
|
rec_updating = false;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
} else {
|
|
|
|
|
|
|
|
// cerr << "\tNOT rolling, rec_rects = " << rec_rects.size() << " rec_regions = " << rec_regions.size() << endl;
|
|
|
|
|
|
|
|
if (!rec_rects.empty() || !rec_regions.empty()) {
|
|
|
|
|
|
|
|
/* disconnect rapid update */
|
|
|
|
screen_update_connection.disconnect();
|
2009-12-17 13:24:23 -05:00
|
|
|
rec_data_ready_connections.drop_connections ();
|
2006-07-23 08:03:19 -04:00
|
|
|
rec_updating = false;
|
|
|
|
rec_active = false;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
/* remove temp regions */
|
2006-10-21 15:01:50 -04:00
|
|
|
|
2007-05-31 17:37:20 -04:00
|
|
|
for (list<pair<boost::shared_ptr<Region>,RegionView*> >::iterator iter = rec_regions.begin(); iter != rec_regions.end(); ) {
|
|
|
|
list<pair<boost::shared_ptr<Region>,RegionView*> >::iterator tmp;
|
2006-10-21 15:01:50 -04:00
|
|
|
|
2006-09-18 23:29:16 -04:00
|
|
|
tmp = iter;
|
|
|
|
++tmp;
|
2006-10-21 15:01:50 -04:00
|
|
|
|
2007-05-31 17:37:20 -04:00
|
|
|
(*iter).first->drop_references ();
|
2006-10-21 15:01:50 -04:00
|
|
|
|
2006-09-18 23:29:16 -04:00
|
|
|
iter = tmp;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
rec_regions.clear();
|
|
|
|
|
|
|
|
// cerr << "\tclear " << rec_rects.size() << " rec rects\n";
|
|
|
|
|
|
|
|
/* transport stopped, clear boxes */
|
|
|
|
for (vector<RecBoxInfo>::iterator iter=rec_rects.begin(); iter != rec_rects.end(); ++iter) {
|
|
|
|
RecBoxInfo &rect = (*iter);
|
|
|
|
delete rect.rectangle;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
rec_rects.clear();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-12-03 17:26:29 -05:00
|
|
|
AudioStreamView::rec_peak_range_ready (framepos_t start, framecnt_t cnt, boost::weak_ptr<Source> weak_src)
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2009-12-11 18:29:48 -05:00
|
|
|
ENSURE_GUI_THREAD (*this, &AudioStreamView::rec_peak_range_ready, start, cnt, weak_src)
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
boost::shared_ptr<Source> src (weak_src.lock());
|
|
|
|
|
|
|
|
if (!src) {
|
2009-10-14 12:10:01 -04:00
|
|
|
return;
|
2006-10-21 15:01:50 -04:00
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
// this is called from the peak building thread
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-10-21 12:26:18 -04:00
|
|
|
if (rec_data_ready_map.size() == 0 || start + cnt > last_rec_data_frame) {
|
2006-08-14 04:44:14 -04:00
|
|
|
last_rec_data_frame = start + cnt;
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
rec_data_ready_map[src] = true;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-04-21 16:42:22 -04:00
|
|
|
if (rec_data_ready_map.size() == _trackview.track()->n_channels().n_audio()) {
|
2010-11-14 10:01:53 -05:00
|
|
|
update_rec_regions (start, cnt);
|
2006-08-14 04:44:14 -04:00
|
|
|
rec_data_ready_map.clear();
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-11-14 10:01:53 -05:00
|
|
|
AudioStreamView::update_rec_regions (framepos_t start, framecnt_t cnt)
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2010-11-14 10:01:53 -05:00
|
|
|
if (!Config->get_show_waveforms_while_recording ()) {
|
|
|
|
return;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-14 10:01:53 -05:00
|
|
|
uint32_t n = 0;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-14 10:01:53 -05:00
|
|
|
for (list<pair<boost::shared_ptr<Region>,RegionView*> >::iterator iter = rec_regions.begin(); iter != rec_regions.end(); n++) {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-14 10:01:53 -05:00
|
|
|
list<pair<boost::shared_ptr<Region>,RegionView*> >::iterator tmp = iter;
|
|
|
|
++tmp;
|
2010-11-14 20:07:40 -05:00
|
|
|
|
|
|
|
assert (n < rec_rects.size());
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
if (!rec_rects[n].rectangle->visible()) {
|
2010-11-14 10:01:53 -05:00
|
|
|
/* rect already hidden, this region is done */
|
|
|
|
iter = tmp;
|
|
|
|
continue;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-14 10:01:53 -05:00
|
|
|
boost::shared_ptr<AudioRegion> region = boost::dynamic_pointer_cast<AudioRegion>(iter->first);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-14 10:01:53 -05:00
|
|
|
if (!region) {
|
|
|
|
iter = tmp;
|
|
|
|
continue;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-12-03 17:26:29 -05:00
|
|
|
framecnt_t origlen = region->length();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-11-14 10:01:53 -05:00
|
|
|
if (region == rec_regions.back().first && rec_active) {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-14 10:01:53 -05:00
|
|
|
if (last_rec_data_frame > region->start()) {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-12-03 17:26:29 -05:00
|
|
|
framecnt_t nlen = last_rec_data_frame - region->start();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-14 10:01:53 -05:00
|
|
|
if (nlen != region->length()) {
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2010-11-14 10:01:53 -05:00
|
|
|
region->suspend_property_changes ();
|
2011-05-30 09:54:44 -04:00
|
|
|
region->set_position (_trackview.track()->get_capture_start_frame(n));
|
|
|
|
region->set_length (nlen);
|
2010-11-14 10:01:53 -05:00
|
|
|
region->resume_property_changes ();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-14 10:01:53 -05:00
|
|
|
if (origlen == 1) {
|
|
|
|
/* our special initial length */
|
|
|
|
add_region_view_internal (region, false, true);
|
|
|
|
setup_new_rec_layer_time (region);
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
2010-11-14 10:01:53 -05:00
|
|
|
|
|
|
|
check_record_layers (region, (region->position() - region->start() + start + cnt));
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-14 10:01:53 -05:00
|
|
|
/* also update rect */
|
2013-04-04 00:32:52 -04:00
|
|
|
ArdourCanvas::Rectangle * rect = rec_rects[n].rectangle;
|
2013-04-12 11:15:45 -04:00
|
|
|
gdouble xend = _trackview.editor().sample_to_pixel (region->position() + region->length());
|
2013-04-04 00:32:52 -04:00
|
|
|
rect->set_x1 (xend);
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-12-03 17:26:29 -05:00
|
|
|
framecnt_t nlen = _trackview.track()->get_captured_frames(n);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (nlen != region->length()) {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-02-19 19:30:42 -05:00
|
|
|
if (region->source_length(0) >= region->start() + nlen) {
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2010-03-02 13:05:26 -05:00
|
|
|
region->suspend_property_changes ();
|
2011-05-30 09:54:44 -04:00
|
|
|
region->set_position (_trackview.track()->get_capture_start_frame(n));
|
|
|
|
region->set_length (nlen);
|
2010-03-02 13:05:26 -05:00
|
|
|
region->resume_property_changes ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (origlen == 1) {
|
|
|
|
/* our special initial length */
|
2008-09-10 11:03:30 -04:00
|
|
|
add_region_view_internal (region, false, true);
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
/* also hide rect */
|
|
|
|
ArdourCanvas::Item * rect = rec_rects[n].rectangle;
|
|
|
|
rect->hide();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-11-14 20:07:40 -05:00
|
|
|
|
|
|
|
iter = tmp;
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-09 17:55:05 -04:00
|
|
|
void
|
|
|
|
AudioStreamView::show_all_fades ()
|
|
|
|
{
|
|
|
|
for (list<RegionView*>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
|
|
|
|
AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*i);
|
|
|
|
if (arv) {
|
|
|
|
arv->set_fade_visibility (true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioStreamView::hide_all_fades ()
|
|
|
|
{
|
|
|
|
for (list<RegionView*>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
|
|
|
|
AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*i);
|
|
|
|
if (arv) {
|
|
|
|
arv->set_fade_visibility (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-15 11:01:35 -04:00
|
|
|
/** Hide xfades for regions that overlap ar.
|
2012-07-04 17:09:32 -04:00
|
|
|
* @return Pair of lists; first is the AudioRegionViews that start xfades were hidden for,
|
|
|
|
* second is the AudioRegionViews that end xfades were hidden for.
|
2012-06-15 11:01:35 -04:00
|
|
|
*/
|
2012-07-04 17:09:32 -04:00
|
|
|
pair<list<AudioRegionView*>, list<AudioRegionView*> >
|
2012-05-10 09:48:23 -04:00
|
|
|
AudioStreamView::hide_xfades_with (boost::shared_ptr<AudioRegion> ar)
|
|
|
|
{
|
2012-07-04 17:09:32 -04:00
|
|
|
list<AudioRegionView*> start_hidden;
|
|
|
|
list<AudioRegionView*> end_hidden;
|
2012-06-15 11:01:35 -04:00
|
|
|
|
2012-05-10 09:48:23 -04:00
|
|
|
for (list<RegionView*>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
|
|
|
|
AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*i);
|
|
|
|
if (arv) {
|
|
|
|
switch (arv->region()->coverage (ar->position(), ar->last_frame())) {
|
|
|
|
case Evoral::OverlapNone:
|
|
|
|
break;
|
|
|
|
default:
|
2012-07-04 17:09:32 -04:00
|
|
|
if (arv->start_xfade_visible ()) {
|
|
|
|
start_hidden.push_back (arv);
|
|
|
|
}
|
|
|
|
if (arv->end_xfade_visible ()) {
|
|
|
|
end_hidden.push_back (arv);
|
|
|
|
}
|
2012-05-10 09:48:23 -04:00
|
|
|
arv->hide_xfades ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-06-15 11:01:35 -04:00
|
|
|
|
2012-07-04 17:09:32 -04:00
|
|
|
return make_pair (start_hidden, end_hidden);
|
2012-05-10 09:48:23 -04:00
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
void
|
2007-06-15 18:08:27 -04:00
|
|
|
AudioStreamView::color_handler ()
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2007-06-15 18:08:27 -04:00
|
|
|
//case cAudioTrackBase:
|
2009-07-09 13:58:13 -04:00
|
|
|
if (_trackview.is_track()) {
|
2013-04-16 23:46:22 -04:00
|
|
|
canvas_rect->set_fill_color (ARDOUR_UI::config()->get_canvasvar_AudioTrackBase());
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2007-06-15 18:08:27 -04:00
|
|
|
//case cAudioBusBase:
|
2009-07-09 13:58:13 -04:00
|
|
|
if (!_trackview.is_track()) {
|
|
|
|
if (Profile->get_sae() && _trackview.route()->is_master()) {
|
2013-04-16 23:46:22 -04:00
|
|
|
canvas_rect->set_fill_color (ARDOUR_UI::config()->get_canvasvar_AudioMasterBusBase());
|
2008-12-12 09:43:24 -05:00
|
|
|
} else {
|
2013-04-16 23:46:22 -04:00
|
|
|
canvas_rect->set_fill_color (ARDOUR_UI::config()->get_canvasvar_AudioBusBase());
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
}
|