diff options
author | Carl Hetherington <carl@carlh.net> | 2010-12-01 17:51:17 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2010-12-01 17:51:17 +0000 |
commit | bce9a0aee7dcb27f17f1b938109eda9b96228217 (patch) | |
tree | 64ad2de2afa5247071ca8c5eaa3226a7e27e6d53 /libs/ardour | |
parent | f500846fd46d6eab97e5e02fd795b9a938464773 (diff) |
Revert previous incorrect patch.
git-svn-id: svn://localhost/ardour2/branches/3.0@8144 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/diskstream.h | 4 | ||||
-rw-r--r-- | libs/ardour/ardour/session.h | 12 | ||||
-rw-r--r-- | libs/ardour/audio_region_importer.cc | 4 | ||||
-rw-r--r-- | libs/ardour/diskstream.cc | 6 | ||||
-rw-r--r-- | libs/ardour/location_importer.cc | 4 | ||||
-rw-r--r-- | libs/ardour/mtc_slave.cc | 4 | ||||
-rw-r--r-- | libs/ardour/session.cc | 1 | ||||
-rw-r--r-- | libs/ardour/session_midi.cc | 5 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 2 | ||||
-rw-r--r-- | libs/ardour/session_time.cc | 81 |
10 files changed, 104 insertions, 19 deletions
diff --git a/libs/ardour/ardour/diskstream.h b/libs/ardour/ardour/diskstream.h index 162d2e4285..4eabe29d85 100644 --- a/libs/ardour/ardour/diskstream.h +++ b/libs/ardour/ardour/diskstream.h @@ -299,6 +299,10 @@ class Diskstream : public SessionObject, public PublicDiskstream Glib::Mutex state_lock; + framepos_t scrub_start; + nframes_t scrub_buffer_size; + nframes_t scrub_offset; + PBD::ScopedConnectionList playlist_connections; PBD::ScopedConnection ic_connection; diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 670144a8c1..acdeee8cd4 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -450,8 +450,8 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi void sync_time_vars(); void bbt_time (nframes_t when, BBT_Time&); - void timecode_to_sample (Timecode::Time& timecode, framepos_t& sample, bool use_subframes) const; - void sample_to_timecode (framepos_t sample, Timecode::Time& timecode, bool use_subframes) const; + void timecode_to_sample(Timecode::Time& timecode, framepos_t& sample, bool use_offset, bool use_subframes) const; + void sample_to_timecode(framepos_t sample, Timecode::Time& timecode, bool use_offset, bool use_subframes) const; void timecode_time (Timecode::Time &); void timecode_time (nframes_t when, Timecode::Time&); void timecode_time_subframes (nframes_t when, Timecode::Time&); @@ -459,10 +459,16 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi void timecode_duration (framecnt_t, Timecode::Time&) const; void timecode_duration_string (char *, framecnt_t) const; + void set_timecode_offset (nframes_t); + nframes_t timecode_offset () const { return _timecode_offset; } + void set_timecode_offset_negative (bool); + bool timecode_offset_negative () const { return _timecode_offset_negative; } + nframes_t convert_to_frames_at (nframes_t position, AnyTime const &); static PBD::Signal1<void, framepos_t> StartTimeChanged; static PBD::Signal1<void, framepos_t> EndTimeChanged; + static PBD::Signal0<void> TimecodeOffsetChanged; std::vector<SyncSource> get_available_sync_options() const; void request_sync_source (Slave*); @@ -1136,6 +1142,8 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi double _frames_per_timecode_frame; /* has to be floating point because of drop frame */ nframes_t _frames_per_hour; nframes_t _timecode_frames_per_hour; + nframes_t _timecode_offset; + bool _timecode_offset_negative; /* cache the most-recently requested time conversions. This helps when we * have multiple clocks showing the same time (e.g. the transport frame) */ diff --git a/libs/ardour/audio_region_importer.cc b/libs/ardour/audio_region_importer.cc index adfe907667..2cade745f2 100644 --- a/libs/ardour/audio_region_importer.cc +++ b/libs/ardour/audio_region_importer.cc @@ -137,8 +137,8 @@ AudioRegionImporter::get_info () const iss_position >> position; // Convert to timecode - session.sample_to_timecode(length, length_time, false); - session.sample_to_timecode(position, position_time, false); + session.sample_to_timecode(length, length_time, true, false); + session.sample_to_timecode(position, position_time, true, false); // return info oss << _("Length: ") << diff --git a/libs/ardour/diskstream.cc b/libs/ardour/diskstream.cc index d566584d9f..5b3fe34870 100644 --- a/libs/ardour/diskstream.cc +++ b/libs/ardour/diskstream.cc @@ -110,6 +110,9 @@ Diskstream::Diskstream (Session &sess, const string &name, Flag flag) , in_set_state (false) , _persistent_alignment_style (ExistingMaterial) , first_input_change (true) + , scrub_start (0) + , scrub_buffer_size (0) + , scrub_offset (0) , _flags (flag) { @@ -154,6 +157,9 @@ Diskstream::Diskstream (Session& sess, const XMLNode& /*node*/) , in_set_state (false) , _persistent_alignment_style (ExistingMaterial) , first_input_change (true) + , scrub_start (0) + , scrub_buffer_size (0) + , scrub_offset (0) , _flags (Recordable) { } diff --git a/libs/ardour/location_importer.cc b/libs/ardour/location_importer.cc index eda636ef71..1674616096 100644 --- a/libs/ardour/location_importer.cc +++ b/libs/ardour/location_importer.cc @@ -114,8 +114,8 @@ LocationImporter::get_info () const iss_end >> end; // Convert to timecode - session.sample_to_timecode (start, start_time, false); - session.sample_to_timecode (end, end_time, false); + session.sample_to_timecode (start, start_time, true, false); + session.sample_to_timecode (end, end_time, true, false); // return info std::ostringstream oss; diff --git a/libs/ardour/mtc_slave.cc b/libs/ardour/mtc_slave.cc index 3ba56bd7e8..953b79083b 100644 --- a/libs/ardour/mtc_slave.cc +++ b/libs/ardour/mtc_slave.cc @@ -185,7 +185,7 @@ MTC_Slave::update_mtc_time (const byte *msg, bool was_full, nframes_t now) if (was_full || outside_window (mtc_frame)) { - session.timecode_to_sample (timecode, mtc_frame, false); + session.timecode_to_sample (timecode, mtc_frame, true, false); session.request_locate (mtc_frame, false); session.request_transport_speed (0); update_mtc_status (MIDI::MTC_Stopped); @@ -204,7 +204,7 @@ MTC_Slave::update_mtc_time (const byte *msg, bool was_full, nframes_t now) consideration. */ - session.timecode_to_sample (timecode, mtc_frame, false); + session.timecode_to_sample (timecode, mtc_frame, true, false); /* We received the last quarter frame 7 quarter frames (1.75 mtc frames) after the instance when the contents of the mtc quarter diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 5abaaf3508..325820b601 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -119,6 +119,7 @@ PBD::Signal2<int,nframes_t,nframes_t> Session::AskAboutSampleRateMismatch; PBD::Signal0<void> Session::SendFeedback; PBD::Signal3<int,Session*,std::string,DataType> Session::MissingFile; +PBD::Signal0<void> Session::TimecodeOffsetChanged; PBD::Signal1<void, framepos_t> Session::StartTimeChanged; PBD::Signal1<void, framepos_t> Session::EndTimeChanged; PBD::Signal0<void> Session::AutoBindingOn; diff --git a/libs/ardour/session_midi.cc b/libs/ardour/session_midi.cc index 5239d7c3f0..6914b9db94 100644 --- a/libs/ardour/session_midi.cc +++ b/libs/ardour/session_midi.cc @@ -280,7 +280,8 @@ Session::mmc_locate (MIDI::MachineControl &/*mmc*/, const MIDI::byte* mmc_tc) timecode.rate = timecode_frames_per_second(); timecode.drop = timecode_drop_frames(); - timecode_to_sample (timecode, target_frame, false /* use_subframes */); + // Also takes timecode offset into account: + timecode_to_sample( timecode, target_frame, true /* use_offset */, false /* use_subframes */ ); if (target_frame > max_framepos) { target_frame = max_framepos; @@ -363,7 +364,7 @@ Session::send_full_time_code (framepos_t const t) } // Get timecode time for the given time - sample_to_timecode (t, timecode, false /* no subframes */); + sample_to_timecode (t, timecode, true /* use_offset */, false /* no subframes */); transmitting_timecode_time = timecode; outbound_mtc_timecode_frame = t; diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 1c6beb790f..f810e3fa12 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -249,6 +249,8 @@ Session::first_stage_init (string fullpath, string snapshot_name) } last_timecode_when = 0; + _timecode_offset = 0; + _timecode_offset_negative = true; last_timecode_valid = false; sync_time_vars (); diff --git a/libs/ardour/session_time.cc b/libs/ardour/session_time.cc index d71bba6ba2..b39c9399b3 100644 --- a/libs/ardour/session_time.cc +++ b/libs/ardour/session_time.cc @@ -187,8 +187,27 @@ Session::sync_time_vars () } void -Session::timecode_to_sample (Timecode::Time& timecode, framepos_t& sample, bool use_subframes) const +Session::set_timecode_offset (nframes_t off) { + _timecode_offset = off; + last_timecode_valid = false; + + TimecodeOffsetChanged (); /* EMIT SIGNAL */ +} + +void +Session::set_timecode_offset_negative (bool neg) +{ + _timecode_offset_negative = neg; + last_timecode_valid = false; + + TimecodeOffsetChanged (); /* EMIT SIGNAL */ +} + +void +Session::timecode_to_sample( Timecode::Time& timecode, framepos_t& sample, bool use_offset, bool use_subframes ) const +{ + if (timecode.drop) { // The drop frame format was created to better approximate the 30000/1001 = 29.97002997002997.... // framerate of NTSC color TV. The used frame rate of drop frame is 29.97, which drifts by about @@ -252,16 +271,53 @@ Session::timecode_to_sample (Timecode::Time& timecode, framepos_t& sample, bool if (use_subframes) { sample += (int32_t) (((double)timecode.subframes * _frames_per_timecode_frame) / config.get_subframes_per_frame()); } + + if (use_offset) { + if (timecode_offset_negative()) { + if (sample >= timecode_offset()) { + sample -= timecode_offset(); + } else { + /* Prevent song-time from becoming negative */ + sample = 0; + } + } else { + if (timecode.negative) { + if (sample <= timecode_offset()) { + sample = timecode_offset() - sample; + } else { + sample = 0; + } + } else { + sample += timecode_offset(); + } + } + } + } void -Session::sample_to_timecode (framepos_t sample, Timecode::Time& timecode, bool use_subframes) const +Session::sample_to_timecode (framepos_t sample, Timecode::Time& timecode, bool use_offset, bool use_subframes ) const { framepos_t offset_sample; - offset_sample = sample; - timecode.negative = false; + if (!use_offset) { + offset_sample = sample; + timecode.negative = false; + } else { + if (_timecode_offset_negative) { + offset_sample = sample + _timecode_offset; + timecode.negative = false; + } else { + if (sample < _timecode_offset) { + offset_sample = (_timecode_offset - sample); + timecode.negative = true; + } else { + offset_sample = sample - _timecode_offset; + timecode.negative = false; + } + } + } double timecode_frames_left_exact; double timecode_frames_fraction; @@ -345,7 +401,7 @@ Session::timecode_time (nframes_t when, Timecode::Time& timecode) return; } - sample_to_timecode (when, timecode, false /* use_subframes */); + sample_to_timecode( when, timecode, true /* use_offset */, false /* use_subframes */ ); last_timecode_when = when; last_timecode = timecode; @@ -360,7 +416,7 @@ Session::timecode_time_subframes (nframes_t when, Timecode::Time& timecode) return; } - sample_to_timecode (when, timecode, true /* use_subframes */); + sample_to_timecode( when, timecode, true /* use_offset */, true /* use_subframes */ ); last_timecode_when = when; last_timecode = timecode; @@ -370,7 +426,7 @@ Session::timecode_time_subframes (nframes_t when, Timecode::Time& timecode) void Session::timecode_duration (framecnt_t when, Timecode::Time& timecode) const { - sample_to_timecode (when, timecode, true /* use_subframes */); + sample_to_timecode( when, timecode, false /* use_offset */, true /* use_subframes */ ); } void @@ -471,7 +527,7 @@ Session::jack_timebase_callback (jack_transport_state_t /*state*/, #if 0 /* Timecode info */ - pos->timecode_offset = 0; + pos->timecode_offset = _timecode_offset; t.timecode_frame_rate = timecode_frames_per_second(); pos->valid = jack_position_bits_t (pos->valid | JackPositionTimecode; @@ -524,7 +580,14 @@ Session::convert_to_frames_at (nframes_t /*position*/, AnyTime const & any) secs += any.timecode.minutes * 60; secs += any.timecode.seconds; secs += any.timecode.frames / timecode_frames_per_second(); - return (nframes_t) floor (secs * frame_rate()); + if (_timecode_offset_negative) + { + return (nframes_t) floor (secs * frame_rate()) - _timecode_offset; + } + else + { + return (nframes_t) floor (secs * frame_rate()) + _timecode_offset; + } break; case AnyTime::Seconds: |