libltc  1.1.3
Linear/Logitudinal Time Code (LTC) Library
ltc.h
Go to the documentation of this file.
1 
36 #ifndef LTC_H
37 #define LTC_H 1
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 #ifdef __BIG_ENDIAN__
44 # define LTC_BIG_ENDIAN
45 #elif defined _BIG_ENDIAN
46 # define LTC_BIG_ENDIAN
47 #else
48 # include <endian.h>
49 # if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
50 # define LTC_BIG_ENDIAN
51 # endif
52 #endif
53 
54 
55 #include <stddef.h> /* size_t */
56 
57 #ifndef DOXYGEN_IGNORE
58 /* libltc version */
59 #define LIBLTC_VERSION "1.1.3"
60 #define LIBLTC_VERSION_MAJOR 1
61 #define LIBLTC_VERSION_MINOR 1
62 #define LIBLTC_VERSION_MICRO 3
63 
64 /* interface revision number
65  * http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
66  */
67 #define LIBLTC_CUR 11
68 #define LIBLTC_REV 2
69 #define LIBLTC_AGE 0
70 #endif /* end DOXYGEN_IGNORE */
71 
75 typedef unsigned char ltcsnd_sample_t;
76 
80 typedef long long int ltc_off_t;
81 
82 #define LTC_FRAME_BIT_COUNT 80
83 
174 #if (defined LTC_BIG_ENDIAN && !defined DOXYGEN_IGNORE)
175 // Big Endian version, bytes are "upside down"
176 struct LTCFrame {
177  unsigned int user1:4;
178  unsigned int frame_units:4;
179 
180  unsigned int user2:4;
181  unsigned int col_frame:1;
182  unsigned int dfbit:1;
183  unsigned int frame_tens:2;
184 
185  unsigned int user3:4;
186  unsigned int secs_units:4;
187 
188  unsigned int user4:4;
189  unsigned int biphase_mark_phase_correction:1;
190  unsigned int secs_tens:3;
191 
192  unsigned int user5:4;
193  unsigned int mins_units:4;
194 
195  unsigned int user6:4;
196  unsigned int binary_group_flag_bit0:1;
197  unsigned int mins_tens:3;
198 
199  unsigned int user7:4;
200  unsigned int hours_units:4;
201 
202  unsigned int user8:4;
203  unsigned int binary_group_flag_bit2:1;
204  unsigned int binary_group_flag_bit1:1;
205  unsigned int hours_tens:2;
206 
207  unsigned int sync_word:16;
208 };
209 #else
210 /* Little Endian version -- and doxygen doc */
211 struct LTCFrame {
212  unsigned int frame_units:4;
213  unsigned int user1:4;
214 
215  unsigned int frame_tens:2;
216  unsigned int dfbit:1;
217  unsigned int col_frame:1;
218  unsigned int user2:4;
219 
220  unsigned int secs_units:4;
221  unsigned int user3:4;
222 
223  unsigned int secs_tens:3;
225  unsigned int user4:4;
226 
227  unsigned int mins_units:4;
228  unsigned int user5:4;
229 
230  unsigned int mins_tens:3;
231  unsigned int binary_group_flag_bit0:1;
232  unsigned int user6:4;
233 
234  unsigned int hours_units:4;
235  unsigned int user7:4;
236 
237  unsigned int hours_tens:2;
238  unsigned int binary_group_flag_bit1:1;
239  unsigned int binary_group_flag_bit2:1;
240  unsigned int user8:4;
241 
242  unsigned int sync_word:16;
243 };
244 #endif
245 
255 };
256 
263 };
264 
268 typedef struct LTCFrame LTCFrame;
269 
286 struct LTCFrameExt {
288  ltc_off_t off_start;
289  ltc_off_t off_end;
290  int reverse;
292  ltcsnd_sample_t sample_min;
293  ltcsnd_sample_t sample_max;
294  double volume;
295 };
296 
300 typedef struct LTCFrameExt LTCFrameExt;
301 
306  char timezone[6];
307  unsigned char years;
308  unsigned char months;
309  unsigned char days;
310 
311  unsigned char hours;
312  unsigned char mins;
313  unsigned char secs;
314  unsigned char frame;
315 };
316 
321 
322 
327 typedef struct LTCDecoder LTCDecoder;
328 
333 typedef struct LTCEncoder LTCEncoder;
334 
344 void ltc_frame_to_time(SMPTETimecode* stime, LTCFrame* frame, int flags);
345 
358 void ltc_time_to_frame(LTCFrame* frame, SMPTETimecode* stime, enum LTC_TV_STANDARD standard, int flags);
359 
366 void ltc_frame_reset(LTCFrame* frame);
367 
382 int ltc_frame_increment(LTCFrame* frame, int fps, enum LTC_TV_STANDARD standard, int flags);
383 
399 int ltc_frame_decrement(LTCFrame* frame, int fps, enum LTC_TV_STANDARD standard, int flags);
400 
409 LTCDecoder * ltc_decoder_create(int apv, int queue_size);
410 
411 
417 
430  ltcsnd_sample_t *buf, size_t size,
431  ltc_off_t posinfo);
432 
442 void ltc_decoder_write_float(LTCDecoder *d, float *buf, size_t size, ltc_off_t posinfo);
443 
453 void ltc_decoder_write_s16(LTCDecoder *d, short *buf, size_t size, ltc_off_t posinfo);
454 
464 void ltc_decoder_write_u16(LTCDecoder *d, unsigned short *buf, size_t size, ltc_off_t posinfo);
465 
474 int ltc_decoder_read(LTCDecoder *d, LTCFrameExt *frame);
475 
481 
488 
489 
490 
501 LTCEncoder* ltc_encoder_create(double sample_rate, double fps, enum LTC_TV_STANDARD standard, int flags);
502 
508 
522 
534 
540 
547 
558 
566 
577 int ltc_encoder_get_buffer(LTCEncoder *e, ltcsnd_sample_t *buf);
578 
579 
588 ltcsnd_sample_t *ltc_encoder_get_bufptr(LTCEncoder *e, int *size, int flush);
589 
595 
608 
635 int ltc_encoder_reinit(LTCEncoder *e, double sample_rate, double fps, enum LTC_TV_STANDARD standard, int flags);
636 
644 
662 int ltc_encoder_set_bufsize(LTCEncoder *e, double sample_rate, double fps);
663 
680 int ltc_encoder_set_volume(LTCEncoder *e, double dBFS);
681 
698 void ltc_encoder_set_filter(LTCEncoder *e, double rise_time);
699 
722 int ltc_encoder_encode_byte(LTCEncoder *e, int byte, double speed);
723 
738 
756 void ltc_frame_set_parity(LTCFrame *frame, enum LTC_TV_STANDARD standard);
757 
768 int parse_bcg_flags(LTCFrame *f, enum LTC_TV_STANDARD standard);
769 
784 ltc_off_t ltc_frame_alignment(double samples_per_frame, enum LTC_TV_STANDARD standard);
785 
786 #ifdef __cplusplus
787 }
788 #endif
789 
790 #endif