2 * Copyright (C) 2008 Mark Hills <mark@pogo.org.uk>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * version 2, as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License version 2 for more details.
13 * You should have received a copy of the GNU General Public License
14 * version 2 along with this program; if not, write to the Free
15 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
26 #define TIMECODER_CHANNELS DEVICE_CHANNELS
27 #define TIMECODER_RATE DEVICE_RATE
29 GOptionGroup
* get_timecode_option_group();
31 struct timecoder_channel_t
{
32 int positive
; /* wave is in positive part of cycle */
34 int crossing_ticker
; /* samples since we last crossed zero */
43 signed int signal_level
, half_peak
, wave_peak
, ref_level
;
44 struct timecoder_channel_t mono
, channel
[TIMECODER_CHANNELS
];
46 /* Pitch information */
48 int crossings
, /* number of zero crossings */
49 pitch_ticker
, /* number of samples from which crossings counted */
50 crossing_ticker
; /* stored for incrementing pitch_ticker */
52 /* Numerical timecode */
54 unsigned int bitstream
, /* actual bits from the record */
55 timecode
; /* corrected timecode */
56 int valid_counter
, /* number of successful error checks */
57 timecode_ticker
; /* samples since valid timecode was read */
61 unsigned char *mon
; /* x-y array */
62 int mon_size
, mon_counter
, mon_scale
,
63 log_fd
; /* optional file descriptor to log to, or -1 for none */
67 /* Building the lookup table is global. Need a good way to share
68 * lookup tables soon, so we can use a different timecode on
69 * each timecoder, and switch between them. */
71 int timecoder_build_lookup(char *timecode_name
);
72 void timecoder_free_lookup(void);
74 void timecoder_init(struct timecoder_t
*tc
);
75 void timecoder_clear(struct timecoder_t
*tc
);
77 void timecoder_monitor_init(struct timecoder_t
*tc
, int size
, int scale
);
78 void timecoder_monitor_clear(struct timecoder_t
*tc
);
80 int timecoder_submit(struct timecoder_t
*tc
, signed short *aud
, int samples
);
82 int timecoder_get_pitch(struct timecoder_t
*tc
, float *pitch
);
83 signed int timecoder_get_position(struct timecoder_t
*tc
, int *when
);
84 int timecoder_get_alive(struct timecoder_t
*tc
);
85 unsigned int timecoder_get_safe(struct timecoder_t
*tc
);
86 int timecoder_get_resolution(struct timecoder_t
*tc
);