How to parse audio data into LTC (linear timecode) string representation


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 ( 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,

Hi all,

I would like to ask more specific question regarding this problem:
Does anyone know how cinder audio buffer transforms raw bytes of audio data (e.g. from .wav file) to float representation?


Not sure about your LTC needs (haven’t needed to use that myself), but concerning your question around audio buffer raw bytes → floats (and assuming the audio isn’t stored in your file/source as floats since that doesn’t take any transformation): if the platform you’re on has built-in conversion support (eg iOS and OSX), we use that. Otherwise a ci::audio::dsp::Converter is used, with the most common implementation being with r8brain (here). You can see how that’s done in the audio::Source api, or looking at one of the platform specific implementations of that.

Hope that helps,

1 Like