diff options
author | Robin Gareus <robin@gareus.org> | 2012-11-13 20:29:28 +0000 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2012-11-13 20:29:28 +0000 |
commit | e1581242ca8554660ea68290688e573a9acfca06 (patch) | |
tree | 49099b7fa12f4c0732dcc635fda59e448c1e5ea3 /gtk2_ardour/audio_clock.cc | |
parent | f761de0d70b896c4a3437f99b238effac520519d (diff) |
implement TC offset for slave&generator.
Many related changes that require atomic update, mostly
because ClockOption slots changed:
* change offset config format to std:string (backwards compat - reads 0)
* make Timecode offset independent from fps
* sample_to_timecode() handle negative sample-num
* audio-clock fix entry and edit of negative numbers
* option editor:
- remove old global internal offset
- add slave & generator TC entry
- still needs UI cleanup, tooltops, maybe sep. tab..
* LTC & MTC slave& generator:
- cache offset
- subscribe to parameter changes
git-svn-id: svn://localhost/ardour2/branches/3.0@13485 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/audio_clock.cc')
-rw-r--r-- | gtk2_ardour/audio_clock.cc | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/gtk2_ardour/audio_clock.cc b/gtk2_ardour/audio_clock.cc index 4fa30186a7..9a9fc6d56e 100644 --- a/gtk2_ardour/audio_clock.cc +++ b/gtk2_ardour/audio_clock.cc @@ -915,7 +915,7 @@ AudioClock::end_edit_relative (bool add) } else { framepos_t c = current_time(); - if (c > frames) { + if (c > frames || _negative_allowed) { set (c - frames, true); } else { set (0, true); @@ -932,6 +932,11 @@ AudioClock::end_edit_relative (bool add) void AudioClock::session_configuration_changed (std::string p) { + if (_negative_allowed) { + /* session option editor clock */ + return; + } + if (p == "sync-source" || p == "external-sync") { set (current_time(), true); return; @@ -1897,10 +1902,23 @@ bool AudioClock::timecode_validate_edit (const string&) { Timecode::Time TC; + int hours; char ignored[2]; if (sscanf (_layout->get_text().c_str(), "%" PRId32 ":%" PRId32 ":%" PRId32 "%[:;]%" PRId32, - &TC.hours, &TC.minutes, &TC.seconds, ignored, &TC.frames) != 5) { + &hours, &TC.minutes, &TC.seconds, ignored, &TC.frames) != 5) { + return false; + } + + if (hours < 0) { + TC.hours = hours * -1; + TC.negative = true; + } else { + TC.hours = hours; + TC.negative = false; + } + + if (TC.negative && !_negative_allowed) { return false; } @@ -1947,19 +1965,22 @@ AudioClock::frames_from_timecode_string (const string& str) const Timecode::Time TC; framepos_t sample; char ignored[2]; + int hours; - if (sscanf (str.c_str(), "%d:%d:%d%[:;]%d", &TC.hours, &TC.minutes, &TC.seconds, ignored, &TC.frames) != 5) { + if (sscanf (str.c_str(), "%d:%d:%d%[:;]%d", &hours, &TC.minutes, &TC.seconds, ignored, &TC.frames) != 5) { error << string_compose (_("programming error: %1 %2"), "badly formatted timecode clock string", str) << endmsg; return 0; } - - TC.negative = edit_is_negative; + TC.hours = abs(hours); TC.rate = _session->timecode_frames_per_second(); TC.drop= _session->timecode_drop_frames(); _session->timecode_to_sample (TC, sample, false /* use_offset */, false /* use_subframes */ ); // timecode_tester (); + if (edit_is_negative) { + sample = - sample; + } return sample; } |