I am playing around with libLTC to generate timecode. I have a rough working example below:
#include <curses.h>
#include <time.h>
#include <ltc.h>
int main() {
initscr();
nodelay(stdscr, TRUE);
LTCFrame frame;
LTCFrameExt Frame;
SMPTETimecode stime;
do {
clear();
ltc_frame_increment(&frame, 25, LTC_TV_625_50, LTC_USE_DATE);
ltc_frame_to_time(&stime, &frame, LTC_USE_DATE);
printw("%02d:%02d:%02d%c%02d | %8lld %8lld%s\n",
stime.hours,
stime.mins,
stime.secs,
(Frame.ltc.dfbit) ? '.' : ':',
stime.frame,
Frame.off_start,
Frame.off_end,
Frame.reverse ? " R" : ""
);
refresh();
} while (getch() != 'q');
endwin();
return 0;
}
The issue I have currently is that the loop runs too fast and as a result so does the TC, I wondered what the correct way to slow this down so that it runs at the correct rate? There is the sleep() function but would need to change for each frame rate?