Hi!
Does anyone know how to use properly this library (GitHub - x42/libltc: Linear/Logitudinal Time Code (LTC) Library) for parsing audio data from audio input node and converting it to timecode?
For some reason timecode, in the form of “hours:minutes:seconds:frames”, is printed correct after each 2-3 seconds, while in between wrong values are printed.
I am using mobile app (https://play.google.com/store/apps/details?id=com.AaronBernstein.ltctimecodegeneratorpro&hl=sr__%23Latn&gl=US) for timecode generation and jack input for sending data to my cinder app.
I followed each step in libltc/tests/ltcdecode.c. The only difference is that in the example a binary file is used for reading bytes of audio data, while I am using cinder audio buffer (floats data) for the same purpose.
My implementation is the following:
const float* data = mMonitorNode->getBuffer().getData();
float* nonConstData = const_cast<float*>(data);
ltc_decoder_write_float(ltcDecoder, nonConstData, mMonitorNode->getBuffer().getSize(), total);
while (ltc_decoder_read(ltcDecoder, &frame)) {
SMPTETimecode stime;
ltc_frame_to_time(&stime, &frame.ltc, 1);
timecode.hour = stime.hours;
timecode.min = stime.mins;
timecode.sec = stime.secs;
timecode.frame = stime.frame;
}
gui::LabelText("LTC (H:M:S:F)", "%.2d:%.2d:%.2d:%.2d", timecode.hour, timecode.min, timecode.sec, timecode.frame);
total += mMonitorNode->getBuffer().getSize();
Thanks in advance,
Dusan