2
* Copyright (C) 2010 Mark Hills <mark@pogo.org.uk>
2
* Copyright (C) 2012 Mark Hills <mark@pogo.org.uk>
4
4
* This program is free software; you can redistribute it and/or
5
5
* modify it under the terms of the GNU General Public License
6
6
* version 2, as published by the Free Software Foundation.
8
8
* This program is distributed in the hope that it will be useful, but
9
9
* WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
11
* General Public License version 2 for more details.
13
13
* You should have received a copy of the GNU General Public License
14
14
* version 2 along with this program; if not, write to the Free
15
15
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
44
41
unsigned int length, /* in cycles */
45
42
safe; /* last 'safe' timecode number (for auto disconnect) */
46
43
bool lookup; /* true if lut has been generated */
51
struct timecoder_channel_t {
52
int positive, /* wave is in positive part of cycle */
47
struct timecoder_channel {
48
bool positive, /* wave is in positive part of cycle */
53
49
swapped; /* wave recently swapped polarity */
55
51
unsigned int crossing_ticker; /* samples since we last crossed zero */
60
struct timecode_def_t *def;
55
struct timecode_def *def;
63
58
/* Precomputed values */
60
double dt, zero_alpha;
67
62
/* Pitch information */
70
struct timecoder_channel_t primary, secondary;
65
struct timecoder_channel primary, secondary;
73
68
/* Numerical timecode */
84
79
int mon_size, mon_counter;
82
struct timecode_def* timecoder_find_definition(const char *name);
88
83
void timecoder_free_lookup(void);
90
int timecoder_init(struct timecoder_t *tc, const char *def_name, double speed,
91
unsigned int sample_rate);
92
void timecoder_clear(struct timecoder_t *tc);
94
int timecoder_monitor_init(struct timecoder_t *tc, int size);
95
void timecoder_monitor_clear(struct timecoder_t *tc);
97
void timecoder_submit(struct timecoder_t *tc, const signed short *pcm, size_t npcm);
99
signed int timecoder_get_position(struct timecoder_t *tc, float *when);
102
/* Return the pitch relative to reference playback speed */
104
static inline float timecoder_get_pitch(struct timecoder_t *tc)
85
void timecoder_init(struct timecoder *tc, struct timecode_def *def,
86
double speed, unsigned int sample_rate);
87
void timecoder_clear(struct timecoder *tc);
89
int timecoder_monitor_init(struct timecoder *tc, int size);
90
void timecoder_monitor_clear(struct timecoder *tc);
92
void timecoder_cycle_definition(struct timecoder *tc);
93
void timecoder_submit(struct timecoder *tc, const signed short *pcm, size_t npcm);
94
signed int timecoder_get_position(struct timecoder *tc, double *when);
97
* The timecode definition currently in use by this decoder
100
static inline struct timecode_def* timecoder_get_definition(struct timecoder *tc)
106
* Return the pitch relative to reference playback speed
109
static inline double timecoder_get_pitch(struct timecoder *tc)
106
111
return pitch_current(&tc->pitch) / tc->speed;
110
/* The last 'safe' timecode value on the record. Beyond this value, we
115
* The last 'safe' timecode value on the record. Beyond this value, we
111
116
* probably want to ignore the timecode values, as we will hit the
112
* label of the record. */
117
* label of the record.
114
static inline unsigned int timecoder_get_safe(struct timecoder_t *tc)
120
static inline unsigned int timecoder_get_safe(struct timecoder *tc)
116
return tc->def->safe * 1000 / (tc->def->resolution * tc->speed);
122
return tc->def->safe;
120
/* The resolution of the timecode. This is the number of bits per
121
* second at reference playback speed */
123
static inline double timecoder_get_resolution(struct timecoder_t *tc)
126
* The resolution of the timecode. This is the number of bits per
127
* second at reference playback speed
130
static inline double timecoder_get_resolution(struct timecoder *tc)
125
132
return tc->def->resolution * tc->speed;
129
/* The number of revolutions per second of the timecode vinyl,
130
* used only for visual display */
132
static inline double timecoder_revs_per_sec(struct timecoder_t *tc)
136
* The number of revolutions per second of the timecode vinyl,
137
* used only for visual display
140
static inline double timecoder_revs_per_sec(struct timecoder *tc)
134
142
return (33.0 + 1.0 / 3) * tc->speed / 60;