Re-expose timecode offset in the session option editor.

git-svn-id: svn://localhost/ardour2/branches/3.0@8146 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2010-12-01 20:49:22 +00:00
parent 044a2cca8f
commit a5ea47ff0d
12 changed files with 107 additions and 70 deletions

View file

@ -459,16 +459,10 @@ 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*);
@ -1142,8 +1136,6 @@ 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) */

View file

@ -51,3 +51,5 @@ CONFIG_VARIABLE (bool, show_group_tabs, "show-group-tabs", true)
CONFIG_VARIABLE (bool, external_sync, "external-sync", false)
CONFIG_VARIABLE (SyncSource, sync_source, "sync-source", JACK)
CONFIG_VARIABLE (InsertMergePolicy, insert_merge_policy, "insert-merge-policy", InsertMergeReject)
CONFIG_VARIABLE (framecnt_t, timecode_offset, "timecode-offset", 0)
CONFIG_VARIABLE (bool, timecode_offset_negative, "timecode-offset-negative", true)

View file

@ -119,7 +119,6 @@ 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;

View file

@ -249,8 +249,6 @@ 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 ();
@ -3402,9 +3400,10 @@ Session::config_changed (std::string p, bool ours)
listen_position_changed ();
} else if (p == "solo-control-is-listen-control") {
solo_control_mode_changed ();
} else if (p == "timecode-offset" || p == "timecode-offset-negative") {
last_timecode_valid = false;
}
set_dirty ();
}

View file

@ -186,24 +186,6 @@ Session::sync_time_vars ()
};
}
void
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
{
@ -273,22 +255,22 @@ Session::timecode_to_sample( Timecode::Time& timecode, framepos_t& sample, bool
}
if (use_offset) {
if (timecode_offset_negative()) {
if (sample >= timecode_offset()) {
sample -= timecode_offset();
if (config.get_timecode_offset_negative()) {
if (sample >= config.get_timecode_offset()) {
sample -= config.get_timecode_offset();
} else {
/* Prevent song-time from becoming negative */
sample = 0;
}
} else {
if (timecode.negative) {
if (sample <= timecode_offset()) {
sample = timecode_offset() - sample;
if (sample <= config.get_timecode_offset()) {
sample = config.get_timecode_offset() - sample;
} else {
sample = 0;
}
} else {
sample += timecode_offset();
sample += config.get_timecode_offset();
}
}
}
@ -305,15 +287,15 @@ Session::sample_to_timecode (framepos_t sample, Timecode::Time& timecode, bool u
offset_sample = sample;
timecode.negative = false;
} else {
if (_timecode_offset_negative) {
offset_sample = sample + _timecode_offset;
if (config.get_timecode_offset_negative()) {
offset_sample = sample + config.get_timecode_offset ();
timecode.negative = false;
} else {
if (sample < _timecode_offset) {
offset_sample = (_timecode_offset - sample);
if (sample < config.get_timecode_offset()) {
offset_sample = (config.get_timecode_offset() - sample);
timecode.negative = true;
} else {
offset_sample = sample - _timecode_offset;
offset_sample = sample - config.get_timecode_offset();
timecode.negative = false;
}
}
@ -527,7 +509,7 @@ Session::jack_timebase_callback (jack_transport_state_t /*state*/,
#if 0
/* Timecode info */
pos->timecode_offset = _timecode_offset;
pos->timecode_offset = config.get_timecode_offset();
t.timecode_frame_rate = timecode_frames_per_second();
pos->valid = jack_position_bits_t (pos->valid | JackPositionTimecode;
@ -580,13 +562,10 @@ 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();
if (_timecode_offset_negative)
{
return (nframes_t) floor (secs * frame_rate()) - _timecode_offset;
}
else
{
return (nframes_t) floor (secs * frame_rate()) + _timecode_offset;
if (config.get_timecode_offset_negative()) {
return (nframes_t) floor (secs * frame_rate()) - config.get_timecode_offset();
} else {
return (nframes_t) floor (secs * frame_rate()) + config.get_timecode_offset();
}
break;