22 #include <sys/types.h>
28 #include "ardour/debug.h"
42 #define FLYWHEEL_TIMEOUT ( 1 * session.frame_rate() )
87 Timecode::Time offset_tc;
88 Timecode::parse_timecode_format(
session.
config.get_slave_timecode_offset(), offset_tc);
98 if (p ==
"slave-timecode-offset"
99 || p ==
"timecode-format"
160 unsigned char sound[8192];
161 if (nframes > 8192) {
168 for (i = 0; i < nframes; i++) {
169 const int snd=(int)rint((127.0*in[i])+128.0);
170 sound[i] = (
unsigned char) (snd&0xff);
172 ltc_decoder_write(
decoder, sound, nframes, posinfo);
178 if ( a->frame_units != b->frame_units
179 || a->frame_tens != b->frame_tens
180 || a->dfbit != b->dfbit
181 || a->secs_units != b->secs_units
182 || a->secs_tens != b->secs_tens
183 || a->mins_units != b->mins_units
184 || a->mins_tens != b->mins_tens
185 || a->hours_units != b->hours_units
186 || a->hours_tens != b->hours_tens
195 bool discontinuity_detected =
false;
198 ( frame->reverse &&
prev_frame.ltc.frame_units == 0)
199 ||(!frame->reverse && frame->ltc.frame_units == 0)
201 memcpy(&
prev_frame, frame,
sizeof(LTCFrameExt));
205 if (frame->reverse) {
206 ltc_frame_decrement(&
prev_frame.ltc, fps, LTC_TV_525_60, 0);
208 ltc_frame_increment(&
prev_frame.ltc, fps, LTC_TV_525_60, 0);
211 discontinuity_detected =
true;
214 memcpy(&
prev_frame, frame,
sizeof(LTCFrameExt));
215 return discontinuity_detected;
221 bool fps_changed =
false;
222 double detected_fps = 0;
234 if (
Config->get_timecode_source_2997()) {
235 detected_fps = detected_fps * 999.0 / 1000.0;
237 detected_fps = detected_fps * 1000.0 / 1001.0;
251 if (detected_fps != 0 && (detected_fps !=
timecode.rate || df !=
timecode.drop)) {
262 TimecodeFormat cur_timecode =
session.
config.get_timecode_format();
264 if (
Config->get_timecode_sync_frame_rate()) {
270 if (cur_timecode != tc_format) {
271 if (ceil(Timecode::timecode_to_frames_per_second(cur_timecode)) != ceil(Timecode::timecode_to_frames_per_second(tc_format))) {
273 Timecode::timecode_format_name(cur_timecode),
274 Timecode::timecode_format_name(tc_format))
285 if (ceil(Timecode::timecode_to_frames_per_second(cur_timecode)) != ceil(Timecode::timecode_to_frames_per_second(tc_format))) {
287 Timecode::timecode_format_name(tc_format),
288 Timecode::timecode_format_name(cur_timecode))
304 enum LTC_TV_STANDARD tv_standard = LTC_TV_625_50;
305 while (ltc_decoder_read(
decoder, &frame)) {
308 ltc_frame_to_time(&stime, &frame.ltc, 0);
320 if (!ltc_is_static &&
detect_ltc_fps(stime.frame, (frame.ltc.dfbit)?
true :
false)) {
326 fprintf(stdout,
"LTC %02d:%02d:%02d%c%02d | %8lld %8lld%s\n",
330 (frame.ltc.dfbit) ?
'.' :
':',
334 frame.reverse ?
" R" :
" "
348 tv_standard = LTC_TV_525_60;
350 tv_standard = LTC_TV_1125_60;
354 tv_standard = LTC_TV_625_50;
357 tv_standard = LTC_TV_FILM_24;
361 if (!frame.reverse) {
362 ltc_frame_increment(&frame.ltc, fps_i, tv_standard, 0);
363 ltc_frame_to_time(&stime, &frame.ltc, 0);
368 ltc_frame_decrement(&frame.ltc, fps_i, tv_standard, 0);
369 int off = frame.off_end - frame.off_start;
382 Timecode::timecode_to_sample (
timecode, ltc_frame,
true,
false,
412 b = 1.4142135623730950488 * omega;
428 bool engine_init_called =
false;
451 engine_init_called =
true;
462 if (skip >= 8192) skip = 8192;
463 unsigned char sound[8192];
464 memset(sound, 0,
sizeof(
char) * skip);
465 ltc_decoder_write(
decoder, sound, nframes, now);
466 }
else if (skip != 0) {
526 if (!engine_init_called) {
555 if (fabs(speed - 1.0) <= 0.001) {
559 if (speed != 0 &&
delayedlocked == 0 && fabsf(speed) != 1.0) {
567 Timecode::TimecodeFormat
575 return (
Config->get_timecode_source_2997() ? timecode_2997000 : timecode_2997);
577 return (
Config->get_timecode_source_2997() ? timecode_2997000drop : timecode_2997drop);
579 return timecode_2997drop;
591 return " --:--:--:--";
593 return Timecode::timecode_format_time(
timecode);
601 snprintf(delta,
sizeof(delta),
"\u2012\u2012\u2012\u2012");
603 snprintf(delta,
sizeof(delta),
"%s",
_(
"flywheel"));
605 snprintf(delta,
sizeof(delta),
"\u0394<span foreground=\"%s\" face=\"monospace\" >%s%s%lld</span>sm",
609 return std::string(delta);
double t1
calculated end of the MTC quater frame
bool timecode_negative_offset
double timecode_frames_per_second() const
LIBPBD_API const char * pthread_name()
void process_ltc(framepos_t const)
framecnt_t last_ltc_frame
bool equal_ltc_frame_time(LTCFrame *a, LTCFrame *b)
bool printed_timecode_warning
framecnt_t worst_playback_latency() const
pframes_t samples_per_cycle() const
std::string approximate_current_delta() const
frameoffset_t current_delta
PBD::ScopedConnection config_connection
void get_connected_latency_range(LatencyRange &range, bool playback) const
LIBPBD_API Transmitter warning
virtual void * get_buffer(PortHandle, pframes_t)=0
std::ostream & endmsg(std::ostream &ostr)
SessionConfiguration config
PortEngine::PortHandle port_handle()
static AudioEngine * instance()
framecnt_t frame_rate() const
PortEngine & port_engine()
PBD::Signal0< void > GraphReordered
framepos_t timecode_offset
double frames_per_timecode_frame() const
std::string approximate_current_position() const
bool timecode_drop_frames() const
bool detect_ltc_fps(int, bool)
LIBARDOUR_API RCConfiguration * Config
double c
DLL filter coefficients.
LatencyRange ltc_slave_latency
void parse_ltc(const pframes_t, const Sample *const, const framecnt_t)
boost::shared_ptr< IO > ltc_output_io()
PBD::Signal1< void, framepos_t > Xrun
double t0
time at the beginning of the MTC quater frame
framecnt_t resolution() const
framepos_t transport_frame() const
double e2
second order loop error
bool deletion_in_progress() const
void init_engine_dll(framepos_t, int32_t)
framepos_t sample_time_at_cycle_start()
framecnt_t last_timestamp
#define DEBUG_TRACE(bits, str)
void parse_timecode_offset()
PBD::Signal1< void, std::string > ParameterChanged
Timecode::TimecodeFormat a3e_timecode
bool speed_and_position(double &, framepos_t &)
Timecode::TimecodeFormat apparent_timecode_format() const
Timecode::TimecodeFormat ltc_timecode
void timecode_to_sample(Timecode::Time &timecode, framepos_t &sample, bool use_offset, bool use_subframes) const
void parameter_changed(std::string const &p)
PBD::ScopedConnectionList port_connections
bool detect_discontinuity(LTCFrameExt *, int, bool)
double frames_per_ltc_frame
LIBARDOUR_API uint64_t LTC
Timecode::TimecodeFormat saved_tc_format
std::string string_compose(const std::string &fmt, const T1 &o1)
boost::shared_ptr< Port > ltc_input_port() const