X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=libs%2Fardour%2Fsession_time.cc;h=64641e302beb4d9c78a9d18811c5ba03ef5c3ace;hb=fb430a7738d4d6d38de8ac3fba491c3572bed386;hp=088712f62539db0b5dda29d9fcfd7dc266432e28;hpb=616f2a0370a10dcc7372a95f6bca9f5a45698980;p=ardour.git diff --git a/libs/ardour/session_time.cc b/libs/ardour/session_time.cc index 088712f625..64641e302b 100644 --- a/libs/ardour/session_time.cc +++ b/libs/ardour/session_time.cc @@ -35,7 +35,7 @@ #include "ardour/session.h" #include "ardour/tempo.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; using namespace ARDOUR; @@ -46,7 +46,7 @@ using namespace PBD; void Session::bbt_time (framepos_t when, Timecode::BBT_Time& bbt) { - _tempo_map->bbt_time (when, bbt); + bbt = _tempo_map->bbt_at_frame (when); } /* Timecode TIME */ @@ -66,12 +66,12 @@ Session::timecode_drop_frames() const void Session::sync_time_vars () { - _current_frame_rate = (framecnt_t) round (_base_frame_rate * (1.0 + (config.get_video_pullup()/100.0))); - _frames_per_timecode_frame = (double) _current_frame_rate / (double) timecode_frames_per_second(); + _current_frame_rate = (framecnt_t) round (_nominal_frame_rate * (1.0 + (config.get_video_pullup()/100.0))); + _samples_per_timecode_frame = (double) _current_frame_rate / (double) timecode_frames_per_second(); if (timecode_drop_frames()) { - _frames_per_hour = (int32_t)(107892 * _frames_per_timecode_frame); + _frames_per_hour = (int32_t)(107892 * _samples_per_timecode_frame); } else { - _frames_per_hour = (int32_t)(3600 * rint(timecode_frames_per_second()) * _frames_per_timecode_frame); + _frames_per_hour = (int32_t)(3600 * rint(timecode_frames_per_second()) * _samples_per_timecode_frame); } _timecode_frames_per_hour = rint(timecode_frames_per_second() * 3600.0); @@ -164,12 +164,12 @@ Session::timecode_duration (framecnt_t when, Timecode::Time& timecode) const } void -Session::timecode_duration_string (char* buf, framepos_t when) const +Session::timecode_duration_string (char* buf, size_t len, framepos_t when) const { Timecode::Time timecode; timecode_duration (when, timecode); - snprintf (buf, sizeof (buf), "%02" PRIu32 ":%02" PRIu32 ":%02" PRIu32 ":%02" PRIu32, timecode.hours, timecode.minutes, timecode.seconds, timecode.frames); + snprintf (buf, len, "%02" PRIu32 ":%02" PRIu32 ":%02" PRIu32 ":%02" PRIu32, timecode.hours, timecode.minutes, timecode.seconds, timecode.frames); } void @@ -180,22 +180,29 @@ Session::timecode_time (Timecode::Time &t) } int -Session::jack_sync_callback (TransportState state, framepos_t pos) +Session::backend_sync_callback (TransportState state, framepos_t pos) { - bool slave = synced_to_jack(); + bool slave = synced_to_engine(); + // cerr << "Session::backend_sync_callback() _transport_frame: " << _transport_frame << " pos: " << pos << " audible_frame: " << audible_frame() << endl; + + if (slave) { + // cerr << "Session::backend_sync_callback() emitting Located()" << endl; + Located (); /* EMIT SIGNAL */ + } switch (state) { case TransportStopped: if (slave && _transport_frame != pos && post_transport_work() == 0) { request_locate (pos, false); - // cerr << "SYNC: stopped, locate to " << pos->frame << " from " << _transport_frame << endl; + // cerr << "SYNC: stopped, locate to " << pos << " from " << _transport_frame << endl; return false; } else { + // cerr << "SYNC: stopped, nothing to do" << endl; return true; } case TransportStarting: - // cerr << "SYNC: starting @ " << pos->frame << " a@ " << _transport_frame << " our work = " << post_transport_work() << " pos matches ? " << (_transport_frame == pos->frame) << endl; + // cerr << "SYNC: starting @ " << pos << " a@ " << _transport_frame << " our work = " << post_transport_work() << " pos matches ? " << (_transport_frame == pos) << endl; if (slave) { return _transport_frame == pos && post_transport_work() == 0; } else { @@ -218,91 +225,6 @@ Session::jack_sync_callback (TransportState state, framepos_t pos) return true; } -/* XXX REQUIRES SOMEWAY TO EFFICIENTLY ACCESS jack_position_t WITHOUT BRIDGING - * THE ENTIRE DATA STRUCTURE - */ -#if 0 -void -Session::jack_timebase_callback (TransportState /*state*/, - pframes_t /*nframes*/, - framepos_t pos, - int /*new_position*/) -{ - Timecode::BBT_Time bbt; - - /* BBT info */ - - if (_tempo_map) { - - TempoMetric metric (_tempo_map->metric_at (_transport_frame)); - - try { - _tempo_map->bbt_time_rt (_transport_frame, bbt); - - pos->bar = bbt.bars; - pos->beat = bbt.beats; - pos->tick = bbt.ticks; - - // XXX still need to set bar_start_tick - - pos->beats_per_bar = metric.meter().divisions_per_bar(); - pos->beat_type = metric.meter().note_divisor(); - pos->ticks_per_beat = Timecode::BBT_Time::ticks_per_beat; - pos->beats_per_minute = metric.tempo().beats_per_minute(); - - pos->valid = jack_position_bits_t (pos->valid | JackPositionBBT); - - } catch (...) { - /* no message */ - } - } - -#ifdef HAVE_JACK_VIDEO_SUPPORT - //poke audio video ratio so Ardour can track Video Sync - pos->audio_frames_per_video_frame = frame_rate() / timecode_frames_per_second(); - pos->valid = jack_position_bits_t (pos->valid | JackAudioVideoRatio); -#endif - -#if 0 - /* Timecode info */ - - pos->timecode_offset = config.get_timecode_offset(); - t.timecode_frame_rate = timecode_frames_per_second(); - pos->valid = jack_position_bits_t (pos->valid | JackPositionTimecode; - - if (_transport_speed) { - - if (play_loop) { - - Location* location = _locations.auto_loop_location(); - - if (location) { - - t.transport_state = JackTransportLooping; - t.loop_start = location->start(); - t.loop_end = location->end(); - t.valid = jack_transport_bits_t (t.valid | JackTransportLoop); - - } else { - - t.loop_start = 0; - t.loop_end = 0; - t.transport_state = JackTransportRolling; - - } - - } else { - - t.loop_start = 0; - t.loop_end = 0; - t.transport_state = JackTransportRolling; - - } - - } -#endif -} -#endif /* jack data structure issues */ ARDOUR::framecnt_t Session::convert_to_frames (AnyTime const & position) @@ -311,7 +233,7 @@ Session::convert_to_frames (AnyTime const & position) switch (position.type) { case AnyTime::BBT: - return _tempo_map->frame_time (position.bbt); + return _tempo_map->frame_at_bbt (position.bbt); break; case AnyTime::Timecode: