Track::Track (Session& sess, string name, PresentationInfo::Flag flag, TrackMode mode, DataType default_type)
: Route (sess, name, flag, default_type)
- , _saved_meter_point (_meter_point)
- , _mode (mode)
+ , _saved_meter_point (_meter_point)
+ , _mode (mode)
, _alignment_choice (Automatic)
{
_freeze_record.state = NoFreeze;
- _declickable = true;
+ _declickable = true;
}
int
Track::init ()
{
- if (Route::init ()) {
- return -1;
- }
+ if (Route::init ()) {
+ return -1;
+ }
- DiskIOProcessor::Flag dflags = DiskIOProcessor::Recordable;
+ DiskIOProcessor::Flag dflags = DiskIOProcessor::Recordable;
- if (_mode == Destructive && !Profile->get_trx()) {
- dflags = DiskIOProcessor::Flag (dflags | DiskIOProcessor::Destructive);
- } else if (_mode == NonLayered){
- dflags = DiskIOProcessor::Flag(dflags | DiskIOProcessor::NonLayered);
- }
+ if (_mode == Destructive && !Profile->get_trx()) {
+ dflags = DiskIOProcessor::Flag (dflags | DiskIOProcessor::Destructive);
+ } else if (_mode == NonLayered){
+ dflags = DiskIOProcessor::Flag(dflags | DiskIOProcessor::NonLayered);
+ }
+
+ _disk_reader.reset (new DiskReader (_session, name(), dflags));
+ _disk_reader->set_block_size (_session.get_block_size ());
+ _disk_reader->set_route (boost::dynamic_pointer_cast<Route> (shared_from_this()));
- _disk_reader.reset (new DiskReader (_session, name(), dflags));
- _disk_reader->set_block_size (_session.get_block_size ());
- _disk_reader->set_route (boost::dynamic_pointer_cast<Route> (shared_from_this()));
+ _disk_writer.reset (new DiskWriter (_session, name(), dflags));
+ _disk_writer->set_block_size (_session.get_block_size ());
+ _disk_writer->set_route (boost::dynamic_pointer_cast<Route> (shared_from_this()));
- _disk_writer.reset (new DiskWriter (_session, name(), dflags));
- _disk_writer->set_block_size (_session.get_block_size ());
- _disk_writer->set_route (boost::dynamic_pointer_cast<Route> (shared_from_this()));
+ set_align_choice_from_io ();
- use_new_playlist (data_type());
+ use_new_playlist (data_type());
- boost::shared_ptr<Route> rp (boost::dynamic_pointer_cast<Route> (shared_from_this()));
+ boost::shared_ptr<Route> rp (boost::dynamic_pointer_cast<Route> (shared_from_this()));
boost::shared_ptr<Track> rt = boost::dynamic_pointer_cast<Track> (rp);
_record_enable_control.reset (new RecordEnableControl (_session, EventTypeMap::instance().to_symbol (RecEnableAutomation), *this));
_session.config.ParameterChanged.connect_same_thread (*this, boost::bind (&Track::parameter_changed, this, _1));
- _monitoring_control->Changed.connect_same_thread (*this, boost::bind (&Track::monitoring_changed, this, _1, _2));
- _record_safe_control->Changed.connect_same_thread (*this, boost::bind (&Track::record_safe_changed, this, _1, _2));
- _record_enable_control->Changed.connect_same_thread (*this, boost::bind (&Track::record_enable_changed, this, _1, _2));
+ _monitoring_control->Changed.connect_same_thread (*this, boost::bind (&Track::monitoring_changed, this, _1, _2));
+ _record_safe_control->Changed.connect_same_thread (*this, boost::bind (&Track::record_safe_changed, this, _1, _2));
+ _record_enable_control->Changed.connect_same_thread (*this, boost::bind (&Track::record_enable_changed, this, _1, _2));
- _input->changed.connect_same_thread (*this, boost::bind (&Track::input_changed, this));
+ _input->changed.connect_same_thread (*this, boost::bind (&Track::input_changed, this));
- return 0;
+ return 0;
}
void
return ret;
}
-void
-Track::set_latency_compensation (framecnt_t longest_session_latency)
-{
- Route::set_latency_compensation (longest_session_latency);
- _disk_reader->set_roll_delay (_roll_delay);
-}
-
int
-Track::no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, bool session_state_changing)
+Track::no_roll (pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool session_state_changing)
{
Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
XXX note the absurdity of ::no_roll() being called when we ARE rolling!
*/
- passthru_silence (start_frame, end_frame, nframes, 0);
+ passthru_silence (start_sample, end_sample, nframes, 0);
return 0;
}
/* we're really not rolling, so we're either delivery silence or actually
*/
}
- _disk_writer->check_record_status (start_frame, can_record);
+ _disk_writer->check_record_status (start_sample, can_record);
bool be_silent;
be_silent = false;
}
- _amp->apply_gain_automation (false);
-
/* if have_internal_generator, or .. */
if (be_silent) {
if (no_meter) {
BufferSet& bufs (_session.get_silent_buffers (n_process_buffers()));
- _meter->run (bufs, start_frame, end_frame, 1.0, nframes, true);
- _input->process_input (boost::shared_ptr<Processor>(), start_frame, end_frame, _session.transport_speed(), nframes);
+ _meter->run (bufs, start_sample, end_sample, 1.0, nframes, true);
+ _input->process_input (boost::shared_ptr<Processor>(), start_sample, end_sample, _session.transport_speed(), nframes);
} else {
- _input->process_input (_meter, start_frame, end_frame, _session.transport_speed(), nframes);
+ _input->process_input (_meter, start_sample, end_sample, _session.transport_speed(), nframes);
}
}
- passthru_silence (start_frame, end_frame, nframes, 0);
+ passthru_silence (start_sample, end_sample, nframes, 0);
} else {
fill_buffers_with_input (bufs, _input, nframes);
if (_meter_point == MeterInput) {
- _meter->run (bufs, start_frame, end_frame, _session.transport_speed(), nframes, true);
+ _meter->run (bufs, start_sample, end_sample, _session.transport_speed(), nframes, true);
}
- passthru (bufs, start_frame, end_frame, nframes, false);
+ passthru (bufs, start_sample, end_sample, nframes, false, true);
}
flush_processor_buffers_locked (nframes);
Track::update_latency_information ()
{
Glib::Threads::RWLock::ReaderLock lr (_processor_lock);
- framecnt_t chain_latency = _input->latency ();
+ samplecnt_t chain_latency = _input->latency ();
for (ProcessorList::iterator p = _processors.begin(); p != _processors.end(); ++p) {
(*p)->set_input_latency (chain_latency);
}
int
-Track::seek (framepos_t p, bool complete_refill)
+Track::seek (samplepos_t p, bool complete_refill)
{
if (_disk_reader->seek (p, complete_refill)) {
return -1;
}
int
-Track::can_internal_playback_seek (framecnt_t p)
+Track::can_internal_playback_seek (samplecnt_t p)
{
return _disk_reader->can_internal_playback_seek (p);
}
int
-Track::internal_playback_seek (framecnt_t p)
+Track::internal_playback_seek (samplecnt_t p)
{
return _disk_reader->internal_playback_seek (p);
}
void
-Track::non_realtime_locate (framepos_t p)
+Track::non_realtime_locate (samplepos_t p)
{
Route::non_realtime_locate (p);
return _disk_reader->overwrite_existing_buffers ();
}
-framecnt_t
-Track::get_captured_frames (uint32_t n) const
+samplecnt_t
+Track::get_captured_samples (uint32_t n) const
{
- return _disk_writer->get_captured_frames (n);
+ return _disk_writer->get_captured_samples (n);
}
int
}
void
-Track::transport_looped (framepos_t p)
+Track::transport_looped (samplepos_t p)
{
return _disk_writer->transport_looped (p);
}
}
void
-Track::prepare_to_stop (framepos_t t, framepos_t a)
+Track::prepare_to_stop (samplepos_t t, samplepos_t a)
{
_disk_writer->prepare_to_stop (t, a);
}
return _disk_reader->output_streams();
}
-framepos_t
-Track::get_capture_start_frame (uint32_t n) const
+samplepos_t
+Track::get_capture_start_sample (uint32_t n) const
{
- return _disk_writer->get_capture_start_frame (n);
+ return _disk_writer->get_capture_start_sample (n);
}
AlignStyle
AlignChoice
Track::alignment_choice () const
{
- return _disk_writer->alignment_choice ();
+ return _alignment_choice;
}
-framepos_t
+samplepos_t
Track::current_capture_start () const
{
return _disk_writer->current_capture_start ();
}
-framepos_t
+samplepos_t
Track::current_capture_end () const
{
return _disk_writer->current_capture_end ();
_playlists[dt] = p;
}
+ _session.set_dirty ();
+ PlaylistChanged (); /* EMIT SIGNAL */
+
return ret;
}
void
Track::set_align_choice (AlignChoice ac, bool force)
{
+ _alignment_choice = ac;
switch (ac) {
- case Automatic:
- _alignment_choice = Automatic;
- set_align_choice_from_io ();
- return;
- default:
- break;
+ case Automatic:
+ set_align_choice_from_io ();
+ break;
+ case UseCaptureTime:
+ _disk_writer->set_align_style (CaptureTime, force);
+ break;
+ case UseExistingMaterial:
+ _disk_writer->set_align_style (ExistingMaterial, force);
+ break;
}
-
- _disk_writer->set_align_choice (ac, force);
- _alignment_choice = ac;
}
void
}
}
-#ifdef USE_TRACKS_CODE_FEATURES
-
-/* This is the Tracks version of Track::monitoring_state().
- *
- * Ardour developers: try to flag or fix issues if parts of the libardour API
- * change in ways that invalidate this
- */
-
-MonitorState
-Track::monitoring_state () const
-{
- /* Explicit requests */
-
- if (_monitoring != MonitorInput) {
- return MonitoringInput;
- }
-
- if (_monitoring & MonitorDisk) {
- return MonitoringDisk;
- }
-
- /* This is an implementation of the truth table in doc/monitor_modes.pdf;
- I don't think it's ever going to be too pretty too look at.
- */
-
- // GZ: NOT USED IN TRACKS
- //bool const auto_input = _session.config.get_auto_input ();
- //bool const software_monitor = Config->get_monitoring_model() == SoftwareMonitoring;
- //bool const tape_machine_mode = Config->get_tape_machine_mode ();
-
- bool const roll = _session.transport_rolling ();
- bool const track_rec = _diskstream->record_enabled ();
- bool session_rec = _session.actively_recording ();
-
- if (track_rec) {
-
- if (!session_rec && roll) {
- return MonitoringDisk;
- } else {
- return MonitoringInput;
- }
-
- } else {
-
- if (roll) {
- return MonitoringDisk;
- }
- }
-
- return MonitoringSilence;
-}
-
-#else
-
-/* This is the Ardour/Mixbus version of Track::monitoring_state().
- *
- * Tracks developers: do NOT modify this method under any circumstances.
- */
-
-MonitorState
-Track::monitoring_state () const
-{
- /* Explicit requests */
- MonitorChoice m (_monitoring_control->monitoring_choice());
-
- if (m != MonitorAuto) {
-
- MonitorState ms ((MonitorState) 0);
-
- if (m & MonitorInput) {
- ms = MonitoringInput;
- }
-
- if (m & MonitorDisk) {
- ms = MonitorState (ms | MonitoringDisk);
- }
-
- return ms;
- }
-
- switch (_session.config.get_session_monitoring ()) {
- case MonitorDisk:
- return MonitoringDisk;
- break;
- case MonitorInput:
- return MonitoringInput;
- break;
- default:
- break;
- }
-
- /* This is an implementation of the truth table in doc/monitor_modes.pdf;
- I don't think it's ever going to be too pretty too look at.
- */
-
- bool const roll = _session.transport_rolling ();
- bool const track_rec = _disk_writer->record_enabled ();
- bool const auto_input = _session.config.get_auto_input ();
- bool const software_monitor = Config->get_monitoring_model() == SoftwareMonitoring;
- bool const tape_machine_mode = Config->get_tape_machine_mode ();
- bool session_rec;
-
- /* I suspect that just use actively_recording() is good enough all the
- * time, but just to keep the semantics the same as they were before
- * sept 26th 2012, we differentiate between the cases where punch is
- * enabled and those where it is not.
- *
- * rg: I suspect this is not the case: monitoring may differ
- */
-
- if (_session.config.get_punch_in() || _session.config.get_punch_out() || _session.preroll_record_punch_enabled ()) {
- session_rec = _session.actively_recording ();
- } else {
- session_rec = _session.get_record_enabled();
- }
-
- if (track_rec) {
-
- if (!session_rec && roll && auto_input) {
- return MonitoringDisk;
- } else {
- return software_monitor ? MonitoringInput : MonitoringSilence;
- }
-
- } else {
-
- if (tape_machine_mode) {
-
- return MonitoringDisk;
-
- } else {
-
- if (!roll && auto_input) {
- return software_monitor ? MonitoringInput : MonitoringSilence;
- } else {
- return MonitoringDisk;
- }
-
- }
- }
-
- abort(); /* NOTREACHED */
- return MonitoringSilence;
-}
-
-#endif
void
-Track::maybe_declick (BufferSet& bufs, framecnt_t nframes, int declick)
+Track::maybe_declick (BufferSet& bufs, samplecnt_t nframes, int declick)
{
/* never declick if there is an internal generator - we just want it to
keep generating sound without interruption.
}
}
-framecnt_t
-Track::check_initial_delay (framecnt_t nframes, framepos_t& transport_frame)
-{
- if (_roll_delay > nframes) {
-
- _roll_delay -= nframes;
- silence_unlocked (nframes);
- /* transport frame is not legal for caller to use */
- return 0;
-
- } else if (_roll_delay > 0) {
-
- nframes -= _roll_delay;
- silence_unlocked (_roll_delay);
- transport_frame += _roll_delay;
-
- /* shuffle all the port buffers for things that lead "out" of this Route
- to reflect that we just wrote _roll_delay frames of silence.
- */
-
- Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
- for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
- boost::shared_ptr<IOProcessor> iop = boost::dynamic_pointer_cast<IOProcessor> (*i);
- if (iop) {
- iop->increment_port_buffer_offset (_roll_delay);
- }
- }
- _output->increment_port_buffer_offset (_roll_delay);
-
- _roll_delay = 0;
-
- }
-
- return nframes;
-}
-
void
Track::monitoring_changed (bool, Controllable::GroupControlDisposition)
{
return;
}
- framecnt_t total_capture = 0;
+ samplecnt_t total_capture = 0;
for (total_capture = 0, ci = capture_info.begin(); ci != capture_info.end(); ++ci) {
- total_capture += (*ci)->frames;
+ total_capture += (*ci)->samples;
}
/* we will want to be able to keep (over)writing the source
pl->clear_changes ();
pl->freeze ();
- /* Session frame time of the initial capture in this pass, which is where the source starts */
- framepos_t initial_capture = 0;
+ /* Session sample time of the initial capture in this pass, which is where the source starts */
+ samplepos_t initial_capture = 0;
if (!capture_info.empty()) {
initial_capture = capture_info.front()->start;
}
- BeatsFramesConverter converter (_session.tempo_map(), capture_info.front()->start);
- const framepos_t preroll_off = _session.preroll_record_trim_len ();
+ BeatsSamplesConverter converter (_session.tempo_map(), capture_info.front()->start);
+ const samplepos_t preroll_off = _session.preroll_record_trim_len ();
for (ci = capture_info.begin(); ci != capture_info.end(); ++ci) {
RegionFactory::region_name (region_name, mfs->name(), false);
DEBUG_TRACE (DEBUG::CaptureAlignment, string_compose ("%1 capture start @ %2 length %3 add new region %4\n",
- _name, (*ci)->start, (*ci)->frames, region_name));
+ _name, (*ci)->start, (*ci)->samples, region_name));
- // cerr << _name << ": based on ci of " << (*ci)->start << " for " << (*ci)->frames << " add a region\n";
+ // cerr << _name << ": based on ci of " << (*ci)->start << " for " << (*ci)->samples << " add a region\n";
try {
PropertyList plist;
/* start of this region is the offset between the start of its capture and the start of the whole pass */
plist.add (Properties::start, (*ci)->start - initial_capture);
- plist.add (Properties::length, (*ci)->frames);
- plist.add (Properties::length_beats, converter.from((*ci)->frames).to_double());
+ plist.add (Properties::length, (*ci)->samples);
+ plist.add (Properties::length_beats, converter.from((*ci)->samples).to_double());
plist.add (Properties::name, region_name);
boost::shared_ptr<Region> rx (RegionFactory::create (srcs, plist));
try {
PropertyList plist;
- plist.add (Properties::start, afs->last_capture_start_frame());
+ plist.add (Properties::start, afs->last_capture_start_sample());
plist.add (Properties::length, afs->length(0));
plist.add (Properties::name, whole_file_region_name);
boost::shared_ptr<Region> rx (RegionFactory::create (srcs, plist));
pl->set_capture_insertion_in_progress (true);
pl->freeze ();
- const framepos_t preroll_off = _session.preroll_record_trim_len ();
- framecnt_t buffer_position = afs->last_capture_start_frame ();
+ const samplepos_t preroll_off = _session.preroll_record_trim_len ();
+ samplecnt_t buffer_position = afs->last_capture_start_sample ();
CaptureInfos::const_iterator ci;
for (ci = capture_info.begin(); ci != capture_info.end(); ++ci) {
RegionFactory::region_name (region_name, whole_file_region_name, false);
DEBUG_TRACE (DEBUG::CaptureAlignment, string_compose ("%1 capture bufpos %5 start @ %2 length %3 add new region %4\n",
- _name, (*ci)->start, (*ci)->frames, region_name, buffer_position));
+ _name, (*ci)->start, (*ci)->samples, region_name, buffer_position));
try {
PropertyList plist;
plist.add (Properties::start, buffer_position);
- plist.add (Properties::length, (*ci)->frames);
+ plist.add (Properties::length, (*ci)->samples);
plist.add (Properties::name, region_name);
boost::shared_ptr<Region> rx (RegionFactory::create (srcs, plist));
pl->add_region (region, (*ci)->start + preroll_off, 1, _disk_writer->non_layered());
pl->set_layer (region, DBL_MAX);
- buffer_position += (*ci)->frames;
+ buffer_position += (*ci)->samples;
}
pl->thaw ();