Initial commit
[fillmore] / src / marina / marina / TimeSystem.c
1 /* TimeSystem.c generated by valac, the Vala compiler
2  * generated from TimeSystem.vala, do not modify */
3
4 /* Copyright 2009-2010 Yorba Foundation
5  *
6  * This software is licensed under the GNU Lesser General Public License
7  * (version 2.1 or later).  See the COPYING file in this distribution. 
8  */
9
10 #include <glib.h>
11 #include <glib-object.h>
12 #include <float.h>
13 #include <math.h>
14 #include <stdlib.h>
15 #include <string.h>
16 #include <gst/gst.h>
17
18
19 #define MODEL_TYPE_TIME_SYSTEM (model_time_system_get_type ())
20 #define MODEL_TIME_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_TIME_SYSTEM, ModelTimeSystem))
21 #define MODEL_IS_TIME_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_TIME_SYSTEM))
22 #define MODEL_TIME_SYSTEM_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MODEL_TYPE_TIME_SYSTEM, ModelTimeSystemIface))
23
24 typedef struct _ModelTimeSystem ModelTimeSystem;
25 typedef struct _ModelTimeSystemIface ModelTimeSystemIface;
26
27 #define MODEL_TYPE_TIME_SYSTEM_BASE (model_time_system_base_get_type ())
28 #define MODEL_TIME_SYSTEM_BASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_TIME_SYSTEM_BASE, ModelTimeSystemBase))
29 #define MODEL_TIME_SYSTEM_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MODEL_TYPE_TIME_SYSTEM_BASE, ModelTimeSystemBaseClass))
30 #define MODEL_IS_TIME_SYSTEM_BASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_TIME_SYSTEM_BASE))
31 #define MODEL_IS_TIME_SYSTEM_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MODEL_TYPE_TIME_SYSTEM_BASE))
32 #define MODEL_TIME_SYSTEM_BASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MODEL_TYPE_TIME_SYSTEM_BASE, ModelTimeSystemBaseClass))
33
34 typedef struct _ModelTimeSystemBase ModelTimeSystemBase;
35 typedef struct _ModelTimeSystemBaseClass ModelTimeSystemBaseClass;
36 typedef struct _ModelTimeSystemBasePrivate ModelTimeSystemBasePrivate;
37
38 #define MODEL_TYPE_TIMECODE_TIME_SYSTEM (model_timecode_time_system_get_type ())
39 #define MODEL_TIMECODE_TIME_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_TIMECODE_TIME_SYSTEM, ModelTimecodeTimeSystem))
40 #define MODEL_TIMECODE_TIME_SYSTEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MODEL_TYPE_TIMECODE_TIME_SYSTEM, ModelTimecodeTimeSystemClass))
41 #define MODEL_IS_TIMECODE_TIME_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_TIMECODE_TIME_SYSTEM))
42 #define MODEL_IS_TIMECODE_TIME_SYSTEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MODEL_TYPE_TIMECODE_TIME_SYSTEM))
43 #define MODEL_TIMECODE_TIME_SYSTEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MODEL_TYPE_TIMECODE_TIME_SYSTEM, ModelTimecodeTimeSystemClass))
44
45 typedef struct _ModelTimecodeTimeSystem ModelTimecodeTimeSystem;
46 typedef struct _ModelTimecodeTimeSystemClass ModelTimecodeTimeSystemClass;
47 typedef struct _ModelTimecodeTimeSystemPrivate ModelTimecodeTimeSystemPrivate;
48
49 #define TYPE_FRACTION (fraction_get_type ())
50 typedef struct _Fraction Fraction;
51 #define _g_free0(var) (var = (g_free (var), NULL))
52
53 #define TYPE_TIME_CODE (time_code_get_type ())
54 typedef struct _TimeCode TimeCode;
55
56 #define MODEL_TYPE_TEMPO_INFORMATION (model_tempo_information_get_type ())
57 #define MODEL_TEMPO_INFORMATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_TEMPO_INFORMATION, ModelTempoInformation))
58 #define MODEL_IS_TEMPO_INFORMATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_TEMPO_INFORMATION))
59 #define MODEL_TEMPO_INFORMATION_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MODEL_TYPE_TEMPO_INFORMATION, ModelTempoInformationIface))
60
61 typedef struct _ModelTempoInformation ModelTempoInformation;
62 typedef struct _ModelTempoInformationIface ModelTempoInformationIface;
63
64 #define MODEL_TYPE_BAR_BEAT_TIME_SYSTEM (model_bar_beat_time_system_get_type ())
65 #define MODEL_BAR_BEAT_TIME_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_BAR_BEAT_TIME_SYSTEM, ModelBarBeatTimeSystem))
66 #define MODEL_BAR_BEAT_TIME_SYSTEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MODEL_TYPE_BAR_BEAT_TIME_SYSTEM, ModelBarBeatTimeSystemClass))
67 #define MODEL_IS_BAR_BEAT_TIME_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_BAR_BEAT_TIME_SYSTEM))
68 #define MODEL_IS_BAR_BEAT_TIME_SYSTEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MODEL_TYPE_BAR_BEAT_TIME_SYSTEM))
69 #define MODEL_BAR_BEAT_TIME_SYSTEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MODEL_TYPE_BAR_BEAT_TIME_SYSTEM, ModelBarBeatTimeSystemClass))
70
71 typedef struct _ModelBarBeatTimeSystem ModelBarBeatTimeSystem;
72 typedef struct _ModelBarBeatTimeSystemClass ModelBarBeatTimeSystemClass;
73 typedef struct _ModelBarBeatTimeSystemPrivate ModelBarBeatTimeSystemPrivate;
74
75 #define LOGGING_TYPE_FACILITY (logging_facility_get_type ())
76
77 #define LOGGING_TYPE_LEVEL (logging_level_get_type ())
78
79 struct _ModelTimeSystemIface {
80         GTypeInterface parent_iface;
81         void (*calculate_pixel_step) (ModelTimeSystem* self, float inc, float pixel_min, float pixel_div);
82         gint64 (*xpos_to_time) (ModelTimeSystem* self, gint x);
83         gint64 (*xsize_to_time) (ModelTimeSystem* self, gint x);
84         gint (*time_to_xpos) (ModelTimeSystem* self, gint64 time);
85         gint64 (*get_pixel_snap_time) (ModelTimeSystem* self);
86         gint (*time_to_xsize) (ModelTimeSystem* self, gint64 time);
87         float (*get_pixel_percentage) (ModelTimeSystem* self);
88         gint (*get_start_token) (ModelTimeSystem* self, gint xsize);
89         gint (*get_next_position) (ModelTimeSystem* self, gint token);
90         gint (*get_pixel_height) (ModelTimeSystem* self, gint token);
91         char* (*get_display_string) (ModelTimeSystem* self, gint token);
92         gint (*frame_to_xsize) (ModelTimeSystem* self, gint frame);
93         gint (*xsize_to_frame) (ModelTimeSystem* self, gint xsize);
94         char* (*get_time_string) (ModelTimeSystem* self, gint64 time);
95         char* (*get_time_duration) (ModelTimeSystem* self, gint64 time);
96 };
97
98 struct _ModelTimeSystemBase {
99         GObject parent_instance;
100         ModelTimeSystemBasePrivate * priv;
101         float pixel_percentage;
102         float pixels_per_second;
103         gint64 pixel_snap_time;
104 };
105
106 struct _ModelTimeSystemBaseClass {
107         GObjectClass parent_class;
108         gint* (*get_timeline_seconds) (ModelTimeSystemBase* self, int* result_length1);
109         gint (*correct_sub_second_value) (ModelTimeSystemBase* self, float seconds, gint div, gint fps);
110 };
111
112 struct _Fraction {
113         gint numerator;
114         gint denominator;
115 };
116
117 struct _ModelTimecodeTimeSystem {
118         ModelTimeSystemBase parent_instance;
119         ModelTimecodeTimeSystemPrivate * priv;
120         Fraction frame_rate_fraction;
121 };
122
123 struct _ModelTimecodeTimeSystemClass {
124         ModelTimeSystemBaseClass parent_class;
125 };
126
127 struct _ModelTimecodeTimeSystemPrivate {
128         float pixels_per_frame;
129         gint small_pixel_frames;
130         gint medium_pixel_frames;
131         gint large_pixel_frames;
132 };
133
134 struct _TimeCode {
135         gint hour;
136         gint minute;
137         gint second;
138         gint frame;
139         gboolean drop_code;
140 };
141
142 struct _ModelTempoInformationIface {
143         GTypeInterface parent_iface;
144         void (*get_time_signature) (ModelTempoInformation* self, Fraction* result);
145         gint (*get_bpm) (ModelTempoInformation* self);
146 };
147
148 struct _ModelBarBeatTimeSystem {
149         ModelTimeSystemBase parent_instance;
150         ModelBarBeatTimeSystemPrivate * priv;
151 };
152
153 struct _ModelBarBeatTimeSystemClass {
154         ModelTimeSystemBaseClass parent_class;
155 };
156
157 struct _ModelBarBeatTimeSystemPrivate {
158         float pixels_per_sixteenth;
159         gint small_pixel_sixteenth;
160         gint medium_pixel_sixteenth;
161         gint large_pixel_sixteenth;
162         gint* timeline_bars;
163         gint timeline_bars_length1;
164         gint _timeline_bars_size_;
165         gint bpm;
166         Fraction time_signature;
167         float bars_per_minute;
168         float bars_per_second;
169         gint sixteenths_per_bar;
170         gint sixteenths_per_beat;
171 };
172
173 typedef enum  {
174         LOGGING_FACILITY_SIGNAL_HANDLERS,
175         LOGGING_FACILITY_DEVELOPER_WARNINGS,
176         LOGGING_FACILITY_GRAPH,
177         LOGGING_FACILITY_LOADING,
178         LOGGING_FACILITY_IMPORT,
179         LOGGING_FACILITY_SINGLEDECODEBIN
180 } LoggingFacility;
181
182 typedef enum  {
183         LOGGING_LEVEL_CRITICAL,
184         LOGGING_LEVEL_HIGH,
185         LOGGING_LEVEL_MEDIUM,
186         LOGGING_LEVEL_LOW,
187         LOGGING_LEVEL_INFO,
188         LOGGING_LEVEL_VERBOSE
189 } LoggingLevel;
190
191
192 static gpointer model_time_system_base_parent_class = NULL;
193 static gpointer model_timecode_time_system_parent_class = NULL;
194 static ModelTimeSystemIface* model_timecode_time_system_model_time_system_parent_iface = NULL;
195 static gpointer model_bar_beat_time_system_parent_class = NULL;
196 static ModelTimeSystemIface* model_bar_beat_time_system_model_time_system_parent_iface = NULL;
197
198 GType model_time_system_get_type (void);
199 void model_time_system_calculate_pixel_step (ModelTimeSystem* self, float inc, float pixel_min, float pixel_div);
200 gint64 model_time_system_xpos_to_time (ModelTimeSystem* self, gint x);
201 gint64 model_time_system_xsize_to_time (ModelTimeSystem* self, gint x);
202 gint model_time_system_time_to_xpos (ModelTimeSystem* self, gint64 time);
203 gint64 model_time_system_get_pixel_snap_time (ModelTimeSystem* self);
204 gint model_time_system_time_to_xsize (ModelTimeSystem* self, gint64 time);
205 float model_time_system_get_pixel_percentage (ModelTimeSystem* self);
206 gint model_time_system_get_start_token (ModelTimeSystem* self, gint xsize);
207 gint model_time_system_get_next_position (ModelTimeSystem* self, gint token);
208 gint model_time_system_get_pixel_height (ModelTimeSystem* self, gint token);
209 char* model_time_system_get_display_string (ModelTimeSystem* self, gint token);
210 gint model_time_system_frame_to_xsize (ModelTimeSystem* self, gint frame);
211 gint model_time_system_xsize_to_frame (ModelTimeSystem* self, gint xsize);
212 char* model_time_system_get_time_string (ModelTimeSystem* self, gint64 time);
213 char* model_time_system_get_time_duration (ModelTimeSystem* self, gint64 time);
214 GType model_time_system_base_get_type (void);
215 enum  {
216         MODEL_TIME_SYSTEM_BASE_DUMMY_PROPERTY
217 };
218 #define MODEL_TIME_SYSTEM_BASE_PIXEL_SNAP_INTERVAL 10
219 #define MODEL_TIME_SYSTEM_BASE_BORDER 4
220 static gint* model_time_system_base_get_timeline_seconds (ModelTimeSystemBase* self, int* result_length1);
221 static gint* model_time_system_base_real_get_timeline_seconds (ModelTimeSystemBase* self, int* result_length1);
222 static gint model_time_system_base_correct_sub_second_value (ModelTimeSystemBase* self, float seconds, gint div, gint fps);
223 static gint model_time_system_base_real_correct_sub_second_value (ModelTimeSystemBase* self, float seconds, gint div, gint fps);
224 gint model_time_system_base_correct_seconds_value (ModelTimeSystemBase* self, float seconds, gint div, gint fps);
225 gint64 model_time_system_base_get_pixel_snap_time (ModelTimeSystemBase* self);
226 float model_time_system_base_get_pixel_percentage (ModelTimeSystemBase* self);
227 gint64 model_time_system_base_xsize_to_time (ModelTimeSystemBase* self, gint size);
228 gint64 model_time_system_base_xpos_to_time (ModelTimeSystemBase* self, gint x);
229 gint model_time_system_base_time_to_xsize (ModelTimeSystemBase* self, gint64 time);
230 gint model_time_system_base_time_to_xpos (ModelTimeSystemBase* self, gint64 time);
231 ModelTimeSystemBase* model_time_system_base_construct (GType object_type);
232 static void model_time_system_base_finalize (GObject* obj);
233 GType model_timecode_time_system_get_type (void);
234 GType fraction_get_type (void);
235 Fraction* fraction_dup (const Fraction* self);
236 void fraction_free (Fraction* self);
237 #define MODEL_TIMECODE_TIME_SYSTEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MODEL_TYPE_TIMECODE_TIME_SYSTEM, ModelTimecodeTimeSystemPrivate))
238 enum  {
239         MODEL_TIMECODE_TIME_SYSTEM_DUMMY_PROPERTY
240 };
241 void fraction_init (Fraction *self, gint numerator, gint denominator);
242 static gint model_timecode_time_system_real_correct_sub_second_value (ModelTimeSystemBase* base, float seconds, gint div, gint fps);
243 gint time_to_frame_with_rate (gint64 time, Fraction* rate);
244 char* frame_to_string (gint frame, Fraction* rate);
245 static char* model_timecode_time_system_real_get_time_string (ModelTimeSystem* base, gint64 the_time);
246 static char* model_timecode_time_system_real_get_time_duration (ModelTimeSystem* base, gint64 the_time);
247 gint fraction_nearest_int (Fraction *self);
248 static void model_timecode_time_system_real_calculate_pixel_step (ModelTimeSystem* base, float inc, float pixel_min, float pixel_div);
249 static gint model_timecode_time_system_real_frame_to_xsize (ModelTimeSystem* base, gint frame);
250 static gint model_timecode_time_system_real_xsize_to_frame (ModelTimeSystem* base, gint xsize);
251 static gint model_timecode_time_system_real_get_start_token (ModelTimeSystem* base, gint xsize);
252 static gint model_timecode_time_system_real_get_next_position (ModelTimeSystem* base, gint token);
253 GType time_code_get_type (void);
254 TimeCode* time_code_dup (const TimeCode* self);
255 void time_code_free (TimeCode* self);
256 void frame_to_time (gint frame, Fraction* rate, TimeCode* result);
257 char* time_code_to_string (TimeCode *self);
258 static char* model_timecode_time_system_real_get_display_string (ModelTimeSystem* base, gint frame);
259 static gint model_timecode_time_system_real_get_pixel_height (ModelTimeSystem* base, gint frame);
260 static gint* model_timecode_time_system_real_get_timeline_seconds (ModelTimeSystemBase* base, int* result_length1);
261 ModelTimecodeTimeSystem* model_timecode_time_system_new (void);
262 ModelTimecodeTimeSystem* model_timecode_time_system_construct (GType object_type);
263 static void model_timecode_time_system_finalize (GObject* obj);
264 GType model_tempo_information_get_type (void);
265 void model_tempo_information_get_time_signature (ModelTempoInformation* self, Fraction* result);
266 gint model_tempo_information_get_bpm (ModelTempoInformation* self);
267 GType model_bar_beat_time_system_get_type (void);
268 #define MODEL_BAR_BEAT_TIME_SYSTEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MODEL_TYPE_BAR_BEAT_TIME_SYSTEM, ModelBarBeatTimeSystemPrivate))
269 enum  {
270         MODEL_BAR_BEAT_TIME_SYSTEM_DUMMY_PROPERTY
271 };
272 static void model_bar_beat_time_system_on_bpm_changed (ModelBarBeatTimeSystem* self, gint bpm);
273 static void _model_bar_beat_time_system_on_bpm_changed_model_tempo_information_bpm_changed (ModelTempoInformation* _sender, gint bpm, gpointer self);
274 static void model_bar_beat_time_system_on_time_signature_changed (ModelBarBeatTimeSystem* self, Fraction* time_signature);
275 static void _model_bar_beat_time_system_on_time_signature_changed_model_tempo_information_time_signature_changed (ModelTempoInformation* _sender, Fraction* time_signature, gpointer self);
276 static void model_bar_beat_time_system_set_constants (ModelBarBeatTimeSystem* self);
277 ModelBarBeatTimeSystem* model_bar_beat_time_system_new (ModelTempoInformation* tempo_information);
278 ModelBarBeatTimeSystem* model_bar_beat_time_system_construct (GType object_type, ModelTempoInformation* tempo_information);
279 GType logging_facility_get_type (void);
280 GType logging_level_get_type (void);
281 void logging_emit (GObject* object, LoggingFacility facility, LoggingLevel level, const char* message);
282 static gint model_bar_beat_time_system_real_correct_sub_second_value (ModelTimeSystemBase* base, float bars, gint div, gint unused);
283 static char* model_bar_beat_time_system_beats_to_string (ModelBarBeatTimeSystem* self, gint total_sixteenths, gboolean maximum_resolution, gboolean zero_based);
284 static char* model_bar_beat_time_system_real_get_time_string (ModelTimeSystem* base, gint64 the_time);
285 static char* model_bar_beat_time_system_real_get_time_duration (ModelTimeSystem* base, gint64 the_time);
286 static void model_bar_beat_time_system_real_calculate_pixel_step (ModelTimeSystem* base, float inc, float pixel_min, float pixel_div);
287 static gint model_bar_beat_time_system_real_frame_to_xsize (ModelTimeSystem* base, gint frame);
288 static gint model_bar_beat_time_system_real_xsize_to_frame (ModelTimeSystem* base, gint xsize);
289 static gint model_bar_beat_time_system_real_get_start_token (ModelTimeSystem* base, gint xsize);
290 static gint model_bar_beat_time_system_real_get_next_position (ModelTimeSystem* base, gint token);
291 static char* model_bar_beat_time_system_real_get_display_string (ModelTimeSystem* base, gint frame);
292 static gint model_bar_beat_time_system_real_get_pixel_height (ModelTimeSystem* base, gint frame);
293 static gint* _vala_array_dup1 (gint* self, int length);
294 static gint* model_bar_beat_time_system_real_get_timeline_seconds (ModelTimeSystemBase* base, int* result_length1);
295 static void model_bar_beat_time_system_finalize (GObject* obj);
296
297
298 static void g_cclosure_user_marshal_VOID__BOXED (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
299
300 #line 12 "TimeSystem.vala"
301 void model_time_system_calculate_pixel_step (ModelTimeSystem* self, float inc, float pixel_min, float pixel_div) {
302 #line 12 "TimeSystem.vala"
303         MODEL_TIME_SYSTEM_GET_INTERFACE (self)->calculate_pixel_step (self, inc, pixel_min, pixel_div);
304 #line 305 "TimeSystem.c"
305 }
306
307
308 #line 13 "TimeSystem.vala"
309 gint64 model_time_system_xpos_to_time (ModelTimeSystem* self, gint x) {
310 #line 13 "TimeSystem.vala"
311         return MODEL_TIME_SYSTEM_GET_INTERFACE (self)->xpos_to_time (self, x);
312 #line 313 "TimeSystem.c"
313 }
314
315
316 #line 14 "TimeSystem.vala"
317 gint64 model_time_system_xsize_to_time (ModelTimeSystem* self, gint x) {
318 #line 14 "TimeSystem.vala"
319         return MODEL_TIME_SYSTEM_GET_INTERFACE (self)->xsize_to_time (self, x);
320 #line 321 "TimeSystem.c"
321 }
322
323
324 #line 15 "TimeSystem.vala"
325 gint model_time_system_time_to_xpos (ModelTimeSystem* self, gint64 time) {
326 #line 15 "TimeSystem.vala"
327         return MODEL_TIME_SYSTEM_GET_INTERFACE (self)->time_to_xpos (self, time);
328 #line 329 "TimeSystem.c"
329 }
330
331
332 #line 16 "TimeSystem.vala"
333 gint64 model_time_system_get_pixel_snap_time (ModelTimeSystem* self) {
334 #line 16 "TimeSystem.vala"
335         return MODEL_TIME_SYSTEM_GET_INTERFACE (self)->get_pixel_snap_time (self);
336 #line 337 "TimeSystem.c"
337 }
338
339
340 #line 17 "TimeSystem.vala"
341 gint model_time_system_time_to_xsize (ModelTimeSystem* self, gint64 time) {
342 #line 17 "TimeSystem.vala"
343         return MODEL_TIME_SYSTEM_GET_INTERFACE (self)->time_to_xsize (self, time);
344 #line 345 "TimeSystem.c"
345 }
346
347
348 #line 18 "TimeSystem.vala"
349 float model_time_system_get_pixel_percentage (ModelTimeSystem* self) {
350 #line 18 "TimeSystem.vala"
351         return MODEL_TIME_SYSTEM_GET_INTERFACE (self)->get_pixel_percentage (self);
352 #line 353 "TimeSystem.c"
353 }
354
355
356 #line 19 "TimeSystem.vala"
357 gint model_time_system_get_start_token (ModelTimeSystem* self, gint xsize) {
358 #line 19 "TimeSystem.vala"
359         return MODEL_TIME_SYSTEM_GET_INTERFACE (self)->get_start_token (self, xsize);
360 #line 361 "TimeSystem.c"
361 }
362
363
364 #line 20 "TimeSystem.vala"
365 gint model_time_system_get_next_position (ModelTimeSystem* self, gint token) {
366 #line 20 "TimeSystem.vala"
367         return MODEL_TIME_SYSTEM_GET_INTERFACE (self)->get_next_position (self, token);
368 #line 369 "TimeSystem.c"
369 }
370
371
372 #line 21 "TimeSystem.vala"
373 gint model_time_system_get_pixel_height (ModelTimeSystem* self, gint token) {
374 #line 21 "TimeSystem.vala"
375         return MODEL_TIME_SYSTEM_GET_INTERFACE (self)->get_pixel_height (self, token);
376 #line 377 "TimeSystem.c"
377 }
378
379
380 #line 22 "TimeSystem.vala"
381 char* model_time_system_get_display_string (ModelTimeSystem* self, gint token) {
382 #line 22 "TimeSystem.vala"
383         return MODEL_TIME_SYSTEM_GET_INTERFACE (self)->get_display_string (self, token);
384 #line 385 "TimeSystem.c"
385 }
386
387
388 #line 23 "TimeSystem.vala"
389 gint model_time_system_frame_to_xsize (ModelTimeSystem* self, gint frame) {
390 #line 23 "TimeSystem.vala"
391         return MODEL_TIME_SYSTEM_GET_INTERFACE (self)->frame_to_xsize (self, frame);
392 #line 393 "TimeSystem.c"
393 }
394
395
396 #line 24 "TimeSystem.vala"
397 gint model_time_system_xsize_to_frame (ModelTimeSystem* self, gint xsize) {
398 #line 24 "TimeSystem.vala"
399         return MODEL_TIME_SYSTEM_GET_INTERFACE (self)->xsize_to_frame (self, xsize);
400 #line 401 "TimeSystem.c"
401 }
402
403
404 #line 25 "TimeSystem.vala"
405 char* model_time_system_get_time_string (ModelTimeSystem* self, gint64 time) {
406 #line 25 "TimeSystem.vala"
407         return MODEL_TIME_SYSTEM_GET_INTERFACE (self)->get_time_string (self, time);
408 #line 409 "TimeSystem.c"
409 }
410
411
412 #line 26 "TimeSystem.vala"
413 char* model_time_system_get_time_duration (ModelTimeSystem* self, gint64 time) {
414 #line 26 "TimeSystem.vala"
415         return MODEL_TIME_SYSTEM_GET_INTERFACE (self)->get_time_duration (self, time);
416 #line 417 "TimeSystem.c"
417 }
418
419
420 static void model_time_system_base_init (ModelTimeSystemIface * iface) {
421         static gboolean initialized = FALSE;
422         if (!initialized) {
423                 initialized = TRUE;
424                 g_signal_new ("geometry_changed", MODEL_TYPE_TIME_SYSTEM, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
425         }
426 }
427
428
429 GType model_time_system_get_type (void) {
430         static volatile gsize model_time_system_type_id__volatile = 0;
431         if (g_once_init_enter (&model_time_system_type_id__volatile)) {
432                 static const GTypeInfo g_define_type_info = { sizeof (ModelTimeSystemIface), (GBaseInitFunc) model_time_system_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
433                 GType model_time_system_type_id;
434                 model_time_system_type_id = g_type_register_static (G_TYPE_INTERFACE, "ModelTimeSystem", &g_define_type_info, 0);
435                 g_type_interface_add_prerequisite (model_time_system_type_id, G_TYPE_OBJECT);
436                 g_once_init_leave (&model_time_system_type_id__volatile, model_time_system_type_id);
437         }
438         return model_time_system_type_id__volatile;
439 }
440
441
442 #line 39 "TimeSystem.vala"
443 static gint* model_time_system_base_real_get_timeline_seconds (ModelTimeSystemBase* self, int* result_length1) {
444 #line 445 "TimeSystem.c"
445         g_return_val_if_fail (MODEL_IS_TIME_SYSTEM_BASE (self), NULL);
446         g_critical ("Type `%s' does not implement abstract method `model_time_system_base_get_timeline_seconds'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
447         return NULL;
448 }
449
450
451 #line 39 "TimeSystem.vala"
452 gint* model_time_system_base_get_timeline_seconds (ModelTimeSystemBase* self, int* result_length1) {
453 #line 39 "TimeSystem.vala"
454         return MODEL_TIME_SYSTEM_BASE_GET_CLASS (self)->get_timeline_seconds (self, result_length1);
455 #line 456 "TimeSystem.c"
456 }
457
458
459 #line 40 "TimeSystem.vala"
460 static gint model_time_system_base_real_correct_sub_second_value (ModelTimeSystemBase* self, float seconds, gint div, gint fps) {
461 #line 462 "TimeSystem.c"
462         g_return_val_if_fail (MODEL_IS_TIME_SYSTEM_BASE (self), 0);
463         g_critical ("Type `%s' does not implement abstract method `model_time_system_base_correct_sub_second_value'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
464         return 0;
465 }
466
467
468 #line 40 "TimeSystem.vala"
469 gint model_time_system_base_correct_sub_second_value (ModelTimeSystemBase* self, float seconds, gint div, gint fps) {
470 #line 40 "TimeSystem.vala"
471         return MODEL_TIME_SYSTEM_BASE_GET_CLASS (self)->correct_sub_second_value (self, seconds, div, fps);
472 #line 473 "TimeSystem.c"
473 }
474
475
476 #line 42 "TimeSystem.vala"
477 gint model_time_system_base_correct_seconds_value (ModelTimeSystemBase* self, float seconds, gint div, gint fps) {
478 #line 479 "TimeSystem.c"
479         gint result = 0;
480         gint i = 0;
481         gint secs;
482         gint* _tmp1_;
483         gint _timeline_seconds_size_;
484         gint timeline_seconds_length1;
485         gint _tmp0_;
486         gint* timeline_seconds;
487 #line 42 "TimeSystem.vala"
488         g_return_val_if_fail (MODEL_IS_TIME_SYSTEM_BASE (self), 0);
489 #line 43 "TimeSystem.vala"
490         if (seconds < 1.0f) {
491 #line 492 "TimeSystem.c"
492                 result = model_time_system_base_correct_sub_second_value (self, seconds, div, fps);
493 #line 44 "TimeSystem.vala"
494                 return result;
495 #line 496 "TimeSystem.c"
496         }
497 #line 48 "TimeSystem.vala"
498         secs = (gint) seconds;
499 #line 500 "TimeSystem.c"
500         timeline_seconds = (_tmp1_ = model_time_system_base_get_timeline_seconds (self, &_tmp0_), timeline_seconds_length1 = _tmp0_, _timeline_seconds_size_ = timeline_seconds_length1, _tmp1_);
501         {
502                 gboolean _tmp2_;
503 #line 50 "TimeSystem.vala"
504                 i = timeline_seconds_length1 - 1;
505 #line 50 "TimeSystem.vala"
506                 _tmp2_ = TRUE;
507 #line 50 "TimeSystem.vala"
508                 while (TRUE) {
509 #line 510 "TimeSystem.c"
510                         gboolean _tmp3_ = FALSE;
511 #line 50 "TimeSystem.vala"
512                         if (!_tmp2_) {
513 #line 50 "TimeSystem.vala"
514                                 i--;
515 #line 516 "TimeSystem.c"
516                         }
517 #line 50 "TimeSystem.vala"
518                         _tmp2_ = FALSE;
519 #line 50 "TimeSystem.vala"
520                         if (!(i > 0)) {
521 #line 50 "TimeSystem.vala"
522                                 break;
523 #line 524 "TimeSystem.c"
524                         }
525 #line 51 "TimeSystem.vala"
526                         if (secs <= timeline_seconds[i]) {
527 #line 52 "TimeSystem.vala"
528                                 _tmp3_ = secs >= timeline_seconds[i - 1];
529 #line 530 "TimeSystem.c"
530                         } else {
531 #line 51 "TimeSystem.vala"
532                                 _tmp3_ = FALSE;
533 #line 534 "TimeSystem.c"
534                         }
535 #line 51 "TimeSystem.vala"
536                         if (_tmp3_) {
537 #line 53 "TimeSystem.vala"
538                                 if ((div % (timeline_seconds[i] * fps)) == 0) {
539 #line 54 "TimeSystem.vala"
540                                         break;
541 #line 542 "TimeSystem.c"
542                                 }
543 #line 56 "TimeSystem.vala"
544                                 if ((div % (timeline_seconds[i - 1] * fps)) == 0) {
545 #line 57 "TimeSystem.vala"
546                                         i--;
547 #line 58 "TimeSystem.vala"
548                                         break;
549 #line 550 "TimeSystem.c"
550                                 }
551                         }
552                 }
553         }
554         result = timeline_seconds[i] * fps;
555         timeline_seconds = (g_free (timeline_seconds), NULL);
556 #line 62 "TimeSystem.vala"
557         return result;
558 #line 559 "TimeSystem.c"
559 }
560
561
562 #line 65 "TimeSystem.vala"
563 gint64 model_time_system_base_get_pixel_snap_time (ModelTimeSystemBase* self) {
564 #line 565 "TimeSystem.c"
565         gint64 result = 0LL;
566 #line 65 "TimeSystem.vala"
567         g_return_val_if_fail (MODEL_IS_TIME_SYSTEM_BASE (self), 0LL);
568 #line 569 "TimeSystem.c"
569         result = self->pixel_snap_time;
570 #line 66 "TimeSystem.vala"
571         return result;
572 #line 573 "TimeSystem.c"
573 }
574
575
576 #line 69 "TimeSystem.vala"
577 float model_time_system_base_get_pixel_percentage (ModelTimeSystemBase* self) {
578 #line 579 "TimeSystem.c"
579         float result = 0.0F;
580 #line 69 "TimeSystem.vala"
581         g_return_val_if_fail (MODEL_IS_TIME_SYSTEM_BASE (self), 0.0F);
582 #line 583 "TimeSystem.c"
583         result = self->pixel_percentage;
584 #line 70 "TimeSystem.vala"
585         return result;
586 #line 587 "TimeSystem.c"
587 }
588
589
590 #line 73 "TimeSystem.vala"
591 gint64 model_time_system_base_xpos_to_time (ModelTimeSystemBase* self, gint x) {
592 #line 593 "TimeSystem.c"
593         gint64 result = 0LL;
594 #line 73 "TimeSystem.vala"
595         g_return_val_if_fail (MODEL_IS_TIME_SYSTEM_BASE (self), 0LL);
596 #line 597 "TimeSystem.c"
597         result = model_time_system_base_xsize_to_time (self, x - MODEL_TIME_SYSTEM_BASE_BORDER);
598 #line 74 "TimeSystem.vala"
599         return result;
600 #line 601 "TimeSystem.c"
601 }
602
603
604 #line 77 "TimeSystem.vala"
605 gint64 model_time_system_base_xsize_to_time (ModelTimeSystemBase* self, gint size) {
606 #line 607 "TimeSystem.c"
607         gint64 result = 0LL;
608 #line 77 "TimeSystem.vala"
609         g_return_val_if_fail (MODEL_IS_TIME_SYSTEM_BASE (self), 0LL);
610 #line 611 "TimeSystem.c"
611         result = (gint64) (((float) (size * GST_SECOND)) / self->pixels_per_second);
612 #line 78 "TimeSystem.vala"
613         return result;
614 #line 615 "TimeSystem.c"
615 }
616
617
618 #line 81 "TimeSystem.vala"
619 gint model_time_system_base_time_to_xsize (ModelTimeSystemBase* self, gint64 time) {
620 #line 621 "TimeSystem.c"
621         gint result = 0;
622 #line 81 "TimeSystem.vala"
623         g_return_val_if_fail (MODEL_IS_TIME_SYSTEM_BASE (self), 0);
624 #line 625 "TimeSystem.c"
625         result = (gint) ((time * self->pixels_per_second) / GST_SECOND);
626 #line 82 "TimeSystem.vala"
627         return result;
628 #line 629 "TimeSystem.c"
629 }
630
631
632 #line 85 "TimeSystem.vala"
633 gint model_time_system_base_time_to_xpos (ModelTimeSystemBase* self, gint64 time) {
634 #line 635 "TimeSystem.c"
635         gint result = 0;
636         gint pos;
637 #line 85 "TimeSystem.vala"
638         g_return_val_if_fail (MODEL_IS_TIME_SYSTEM_BASE (self), 0);
639 #line 86 "TimeSystem.vala"
640         pos = model_time_system_base_time_to_xsize (self, time) + MODEL_TIME_SYSTEM_BASE_BORDER;
641 #line 88 "TimeSystem.vala"
642         if (model_time_system_base_xpos_to_time (self, pos) != time) {
643 #line 89 "TimeSystem.vala"
644                 pos++;
645 #line 646 "TimeSystem.c"
646         }
647         result = pos;
648 #line 90 "TimeSystem.vala"
649         return result;
650 #line 651 "TimeSystem.c"
651 }
652
653
654 #line 29 "TimeSystem.vala"
655 ModelTimeSystemBase* model_time_system_base_construct (GType object_type) {
656 #line 657 "TimeSystem.c"
657         ModelTimeSystemBase * self;
658 #line 29 "TimeSystem.vala"
659         self = (ModelTimeSystemBase*) g_object_new (object_type, NULL);
660 #line 661 "TimeSystem.c"
661         return self;
662 }
663
664
665 static void model_time_system_base_class_init (ModelTimeSystemBaseClass * klass) {
666         model_time_system_base_parent_class = g_type_class_peek_parent (klass);
667         MODEL_TIME_SYSTEM_BASE_CLASS (klass)->get_timeline_seconds = model_time_system_base_real_get_timeline_seconds;
668         MODEL_TIME_SYSTEM_BASE_CLASS (klass)->correct_sub_second_value = model_time_system_base_real_correct_sub_second_value;
669         G_OBJECT_CLASS (klass)->finalize = model_time_system_base_finalize;
670 }
671
672
673 static void model_time_system_base_instance_init (ModelTimeSystemBase * self) {
674         self->pixel_percentage = 0.0f;
675 }
676
677
678 static void model_time_system_base_finalize (GObject* obj) {
679         ModelTimeSystemBase * self;
680         self = MODEL_TIME_SYSTEM_BASE (obj);
681         G_OBJECT_CLASS (model_time_system_base_parent_class)->finalize (obj);
682 }
683
684
685 GType model_time_system_base_get_type (void) {
686         static volatile gsize model_time_system_base_type_id__volatile = 0;
687         if (g_once_init_enter (&model_time_system_base_type_id__volatile)) {
688                 static const GTypeInfo g_define_type_info = { sizeof (ModelTimeSystemBaseClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) model_time_system_base_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ModelTimeSystemBase), 0, (GInstanceInitFunc) model_time_system_base_instance_init, NULL };
689                 GType model_time_system_base_type_id;
690                 model_time_system_base_type_id = g_type_register_static (G_TYPE_OBJECT, "ModelTimeSystemBase", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
691                 g_once_init_leave (&model_time_system_base_type_id__volatile, model_time_system_base_type_id);
692         }
693         return model_time_system_base_type_id__volatile;
694 }
695
696
697 #line 103 "TimeSystem.vala"
698 static gint model_timecode_time_system_real_correct_sub_second_value (ModelTimeSystemBase* base, float seconds, gint div, gint fps) {
699 #line 700 "TimeSystem.c"
700         ModelTimecodeTimeSystem * self;
701         gint result = 0;
702         gint frames;
703         gint mod;
704         self = MODEL_TIMECODE_TIME_SYSTEM (base);
705 #line 104 "TimeSystem.vala"
706         frames = (gint) (fps * seconds);
707 #line 105 "TimeSystem.vala"
708         if (frames == 0) {
709 #line 710 "TimeSystem.c"
710                 result = 1;
711 #line 106 "TimeSystem.vala"
712                 return result;
713 #line 714 "TimeSystem.c"
714         }
715 #line 109 "TimeSystem.vala"
716         if (div == 0) {
717 #line 110 "TimeSystem.vala"
718                 div = fps;
719 #line 720 "TimeSystem.c"
720         }
721 #line 113 "TimeSystem.vala"
722         mod = div % frames;
723 #line 114 "TimeSystem.vala"
724         while (TRUE) {
725 #line 114 "TimeSystem.vala"
726                 if (!(mod != 0)) {
727 #line 114 "TimeSystem.vala"
728                         break;
729 #line 730 "TimeSystem.c"
730                 }
731 #line 115 "TimeSystem.vala"
732                 mod = div % (frames = frames + 1);
733 #line 734 "TimeSystem.c"
734         }
735         result = frames;
736 #line 117 "TimeSystem.vala"
737         return result;
738 #line 739 "TimeSystem.c"
739 }
740
741
742 #line 120 "TimeSystem.vala"
743 static char* model_timecode_time_system_real_get_time_string (ModelTimeSystem* base, gint64 the_time) {
744 #line 745 "TimeSystem.c"
745         ModelTimecodeTimeSystem * self;
746         char* result = NULL;
747         char* time;
748         gint frame;
749         char* _tmp0_;
750         self = MODEL_TIMECODE_TIME_SYSTEM (base);
751         time = NULL;
752 #line 123 "TimeSystem.vala"
753         frame = time_to_frame_with_rate (the_time, &self->frame_rate_fraction);
754 #line 124 "TimeSystem.vala"
755         time = (_tmp0_ = frame_to_string (frame, &self->frame_rate_fraction), _g_free0 (time), _tmp0_);
756 #line 757 "TimeSystem.c"
757         result = time;
758 #line 126 "TimeSystem.vala"
759         return result;
760 #line 761 "TimeSystem.c"
761 }
762
763
764 #line 129 "TimeSystem.vala"
765 static char* model_timecode_time_system_real_get_time_duration (ModelTimeSystem* base, gint64 the_time) {
766 #line 767 "TimeSystem.c"
767         ModelTimecodeTimeSystem * self;
768         char* result = NULL;
769         self = MODEL_TIMECODE_TIME_SYSTEM (base);
770         result = model_time_system_get_time_string (MODEL_TIME_SYSTEM (self), the_time);
771 #line 131 "TimeSystem.vala"
772         return result;
773 #line 774 "TimeSystem.c"
774 }
775
776
777 #line 133 "TimeSystem.vala"
778 static void model_timecode_time_system_real_calculate_pixel_step (ModelTimeSystem* base, float inc, float pixel_min, float pixel_div) {
779 #line 780 "TimeSystem.c"
780         ModelTimecodeTimeSystem * self;
781         gint pixels_per_large;
782         gint pixels_per_medium;
783         gint pixels_per_small;
784         gint fps;
785         self = MODEL_TIMECODE_TIME_SYSTEM (base);
786 #line 134 "TimeSystem.vala"
787         pixels_per_large = 300;
788 #line 135 "TimeSystem.vala"
789         pixels_per_medium = 50;
790 #line 136 "TimeSystem.vala"
791         pixels_per_small = 20;
792 #line 138 "TimeSystem.vala"
793         MODEL_TIME_SYSTEM_BASE (self)->pixel_percentage = MODEL_TIME_SYSTEM_BASE (self)->pixel_percentage + inc;
794 #line 139 "TimeSystem.vala"
795         if (MODEL_TIME_SYSTEM_BASE (self)->pixel_percentage < 0.0f) {
796 #line 140 "TimeSystem.vala"
797                 MODEL_TIME_SYSTEM_BASE (self)->pixel_percentage = 0.0f;
798 #line 799 "TimeSystem.c"
799         } else {
800 #line 141 "TimeSystem.vala"
801                 if (MODEL_TIME_SYSTEM_BASE (self)->pixel_percentage > 1.0f) {
802 #line 142 "TimeSystem.vala"
803                         MODEL_TIME_SYSTEM_BASE (self)->pixel_percentage = 1.0f;
804 #line 805 "TimeSystem.c"
805                 }
806         }
807 #line 144 "TimeSystem.vala"
808         MODEL_TIME_SYSTEM_BASE (self)->pixels_per_second = pixel_min * powf (pixel_div, MODEL_TIME_SYSTEM_BASE (self)->pixel_percentage);
809 #line 145 "TimeSystem.vala"
810         fps = fraction_nearest_int (&self->frame_rate_fraction);
811 #line 146 "TimeSystem.vala"
812         self->priv->large_pixel_frames = model_time_system_base_correct_seconds_value (MODEL_TIME_SYSTEM_BASE (self), pixels_per_large / MODEL_TIME_SYSTEM_BASE (self)->pixels_per_second, 0, fps);
813 #line 147 "TimeSystem.vala"
814         self->priv->medium_pixel_frames = model_time_system_base_correct_seconds_value (MODEL_TIME_SYSTEM_BASE (self), pixels_per_medium / MODEL_TIME_SYSTEM_BASE (self)->pixels_per_second, self->priv->large_pixel_frames, fps);
815 #line 149 "TimeSystem.vala"
816         self->priv->small_pixel_frames = model_time_system_base_correct_seconds_value (MODEL_TIME_SYSTEM_BASE (self), pixels_per_small / MODEL_TIME_SYSTEM_BASE (self)->pixels_per_second, self->priv->medium_pixel_frames, fps);
817 #line 152 "TimeSystem.vala"
818         if (self->priv->small_pixel_frames == self->priv->medium_pixel_frames) {
819 #line 820 "TimeSystem.c"
820                 gint i;
821 #line 153 "TimeSystem.vala"
822                 i = self->priv->medium_pixel_frames;
823 #line 155 "TimeSystem.vala"
824                 while (TRUE) {
825 #line 155 "TimeSystem.vala"
826                         if (!((i = i - 1) > 0)) {
827 #line 155 "TimeSystem.vala"
828                                 break;
829 #line 830 "TimeSystem.c"
830                         }
831 #line 156 "TimeSystem.vala"
832                         if ((self->priv->medium_pixel_frames % i) == 0) {
833 #line 157 "TimeSystem.vala"
834                                 self->priv->small_pixel_frames = i;
835 #line 158 "TimeSystem.vala"
836                                 break;
837 #line 838 "TimeSystem.c"
838                         }
839                 }
840         }
841 #line 163 "TimeSystem.vala"
842         self->priv->pixels_per_frame = MODEL_TIME_SYSTEM_BASE (self)->pixels_per_second / ((float) fps);
843 #line 164 "TimeSystem.vala"
844         MODEL_TIME_SYSTEM_BASE (self)->pixel_snap_time = model_time_system_xsize_to_time (MODEL_TIME_SYSTEM (self), MODEL_TIME_SYSTEM_BASE_PIXEL_SNAP_INTERVAL);
845 #line 846 "TimeSystem.c"
846 }
847
848
849 #line 167 "TimeSystem.vala"
850 static gint model_timecode_time_system_real_frame_to_xsize (ModelTimeSystem* base, gint frame) {
851 #line 852 "TimeSystem.c"
852         ModelTimecodeTimeSystem * self;
853         gint result = 0;
854         self = MODEL_TIMECODE_TIME_SYSTEM (base);
855         result = (gint) (frame * self->priv->pixels_per_frame);
856 #line 168 "TimeSystem.vala"
857         return result;
858 #line 859 "TimeSystem.c"
859 }
860
861
862 #line 171 "TimeSystem.vala"
863 static gint model_timecode_time_system_real_xsize_to_frame (ModelTimeSystem* base, gint xsize) {
864 #line 865 "TimeSystem.c"
865         ModelTimecodeTimeSystem * self;
866         gint result = 0;
867         self = MODEL_TIMECODE_TIME_SYSTEM (base);
868         result = (gint) (xsize / self->priv->pixels_per_frame);
869 #line 172 "TimeSystem.vala"
870         return result;
871 #line 872 "TimeSystem.c"
872 }
873
874
875 #line 175 "TimeSystem.vala"
876 static gint model_timecode_time_system_real_get_start_token (ModelTimeSystem* base, gint xsize) {
877 #line 878 "TimeSystem.c"
878         ModelTimecodeTimeSystem * self;
879         gint result = 0;
880         gint start_frame;
881         self = MODEL_TIMECODE_TIME_SYSTEM (base);
882 #line 176 "TimeSystem.vala"
883         start_frame = model_time_system_xsize_to_frame (MODEL_TIME_SYSTEM (self), xsize);
884 #line 885 "TimeSystem.c"
885         result = self->priv->large_pixel_frames * (start_frame / self->priv->large_pixel_frames);
886 #line 177 "TimeSystem.vala"
887         return result;
888 #line 889 "TimeSystem.c"
889 }
890
891
892 #line 180 "TimeSystem.vala"
893 static gint model_timecode_time_system_real_get_next_position (ModelTimeSystem* base, gint token) {
894 #line 895 "TimeSystem.c"
895         ModelTimecodeTimeSystem * self;
896         gint result = 0;
897         self = MODEL_TIMECODE_TIME_SYSTEM (base);
898         result = token + self->priv->small_pixel_frames;
899 #line 181 "TimeSystem.vala"
900         return result;
901 #line 902 "TimeSystem.c"
902 }
903
904
905 #line 184 "TimeSystem.vala"
906 static char* model_timecode_time_system_real_get_display_string (ModelTimeSystem* base, gint frame) {
907 #line 908 "TimeSystem.c"
908         ModelTimecodeTimeSystem * self;
909         char* result = NULL;
910         self = MODEL_TIMECODE_TIME_SYSTEM (base);
911 #line 185 "TimeSystem.vala"
912         if ((frame % self->priv->large_pixel_frames) == 0) {
913 #line 914 "TimeSystem.c"
914                 TimeCode _tmp1_;
915                 TimeCode _tmp0_ = {0};
916                 result = time_code_to_string ((_tmp1_ = (frame_to_time (frame, &self->frame_rate_fraction, &_tmp0_), _tmp0_), &_tmp1_));
917 #line 186 "TimeSystem.vala"
918                 return result;
919 #line 920 "TimeSystem.c"
920         }
921         result = NULL;
922 #line 188 "TimeSystem.vala"
923         return result;
924 #line 925 "TimeSystem.c"
925 }
926
927
928 #line 191 "TimeSystem.vala"
929 static gint model_timecode_time_system_real_get_pixel_height (ModelTimeSystem* base, gint frame) {
930 #line 931 "TimeSystem.c"
931         ModelTimecodeTimeSystem * self;
932         gint result = 0;
933         self = MODEL_TIMECODE_TIME_SYSTEM (base);
934 #line 192 "TimeSystem.vala"
935         if ((frame % self->priv->medium_pixel_frames) == 0) {
936 #line 937 "TimeSystem.c"
937                 gboolean _tmp0_ = FALSE;
938 #line 193 "TimeSystem.vala"
939                 if (self->priv->medium_pixel_frames == self->priv->small_pixel_frames) {
940 #line 941 "TimeSystem.c"
941                         gboolean _tmp1_ = FALSE;
942 #line 194 "TimeSystem.vala"
943                         if (self->priv->medium_pixel_frames != self->priv->large_pixel_frames) {
944 #line 195 "TimeSystem.vala"
945                                 _tmp1_ = (frame % self->priv->large_pixel_frames) != 0;
946 #line 947 "TimeSystem.c"
947                         } else {
948 #line 194 "TimeSystem.vala"
949                                 _tmp1_ = FALSE;
950 #line 951 "TimeSystem.c"
951                         }
952 #line 194 "TimeSystem.vala"
953                         _tmp0_ = _tmp1_;
954 #line 955 "TimeSystem.c"
955                 } else {
956 #line 193 "TimeSystem.vala"
957                         _tmp0_ = FALSE;
958 #line 959 "TimeSystem.c"
959                 }
960 #line 193 "TimeSystem.vala"
961                 if (_tmp0_) {
962 #line 963 "TimeSystem.c"
963                         result = 2;
964 #line 196 "TimeSystem.vala"
965                         return result;
966 #line 967 "TimeSystem.c"
967                 } else {
968                         result = 6;
969 #line 199 "TimeSystem.vala"
970                         return result;
971 #line 972 "TimeSystem.c"
972                 }
973         } else {
974                 result = 2;
975 #line 202 "TimeSystem.vala"
976                 return result;
977 #line 978 "TimeSystem.c"
978         }
979 }
980
981
982 #line 206 "TimeSystem.vala"
983 static gint* model_timecode_time_system_real_get_timeline_seconds (ModelTimeSystemBase* base, int* result_length1) {
984 #line 985 "TimeSystem.c"
985         ModelTimecodeTimeSystem * self;
986         gint* result = NULL;
987         gint* _tmp0_ = NULL;
988         gint* _tmp1_;
989         self = MODEL_TIMECODE_TIME_SYSTEM (base);
990         result = (_tmp1_ = (_tmp0_ = g_new0 (gint, 15), _tmp0_[0] = 1, _tmp0_[1] = 2, _tmp0_[2] = 5, _tmp0_[3] = 10, _tmp0_[4] = 15, _tmp0_[5] = 20, _tmp0_[6] = 30, _tmp0_[7] = 60, _tmp0_[8] = 120, _tmp0_[9] = 300, _tmp0_[10] = 600, _tmp0_[11] = 900, _tmp0_[12] = 1200, _tmp0_[13] = 1800, _tmp0_[14] = 3600, _tmp0_), *result_length1 = 15, _tmp1_);
991 #line 207 "TimeSystem.vala"
992         return result;
993 #line 994 "TimeSystem.c"
994 }
995
996
997 #line 94 "TimeSystem.vala"
998 ModelTimecodeTimeSystem* model_timecode_time_system_construct (GType object_type) {
999 #line 1000 "TimeSystem.c"
1000         ModelTimecodeTimeSystem * self;
1001 #line 94 "TimeSystem.vala"
1002         self = (ModelTimecodeTimeSystem*) model_time_system_base_construct (object_type);
1003 #line 1004 "TimeSystem.c"
1004         return self;
1005 }
1006
1007
1008 #line 94 "TimeSystem.vala"
1009 ModelTimecodeTimeSystem* model_timecode_time_system_new (void) {
1010 #line 94 "TimeSystem.vala"
1011         return model_timecode_time_system_construct (MODEL_TYPE_TIMECODE_TIME_SYSTEM);
1012 #line 1013 "TimeSystem.c"
1013 }
1014
1015
1016 static void model_timecode_time_system_class_init (ModelTimecodeTimeSystemClass * klass) {
1017         model_timecode_time_system_parent_class = g_type_class_peek_parent (klass);
1018         g_type_class_add_private (klass, sizeof (ModelTimecodeTimeSystemPrivate));
1019         MODEL_TIME_SYSTEM_BASE_CLASS (klass)->correct_sub_second_value = model_timecode_time_system_real_correct_sub_second_value;
1020         MODEL_TIME_SYSTEM_BASE_CLASS (klass)->get_timeline_seconds = model_timecode_time_system_real_get_timeline_seconds;
1021         G_OBJECT_CLASS (klass)->finalize = model_timecode_time_system_finalize;
1022 }
1023
1024
1025 static void model_timecode_time_system_model_time_system_interface_init (ModelTimeSystemIface * iface) {
1026         model_timecode_time_system_model_time_system_parent_iface = g_type_interface_peek_parent (iface);
1027         iface->get_time_string = model_timecode_time_system_real_get_time_string;
1028         iface->get_time_duration = model_timecode_time_system_real_get_time_duration;
1029         iface->calculate_pixel_step = model_timecode_time_system_real_calculate_pixel_step;
1030         iface->frame_to_xsize = model_timecode_time_system_real_frame_to_xsize;
1031         iface->xsize_to_frame = model_timecode_time_system_real_xsize_to_frame;
1032         iface->get_start_token = model_timecode_time_system_real_get_start_token;
1033         iface->get_next_position = model_timecode_time_system_real_get_next_position;
1034         iface->get_display_string = model_timecode_time_system_real_get_display_string;
1035         iface->get_pixel_height = model_timecode_time_system_real_get_pixel_height;
1036         iface->xpos_to_time = (gint64 (*)(ModelTimeSystem* ,gint)) model_time_system_base_xpos_to_time;
1037         iface->xsize_to_time = (gint64 (*)(ModelTimeSystem* ,gint)) model_time_system_base_xsize_to_time;
1038         iface->time_to_xpos = (gint (*)(ModelTimeSystem* ,gint64)) model_time_system_base_time_to_xpos;
1039         iface->get_pixel_snap_time = (gint64 (*)(ModelTimeSystem*)) model_time_system_base_get_pixel_snap_time;
1040         iface->time_to_xsize = (gint (*)(ModelTimeSystem* ,gint64)) model_time_system_base_time_to_xsize;
1041         iface->get_pixel_percentage = (float (*)(ModelTimeSystem*)) model_time_system_base_get_pixel_percentage;
1042 }
1043
1044
1045 static void model_timecode_time_system_instance_init (ModelTimecodeTimeSystem * self) {
1046         Fraction _tmp0_ = {0};
1047         self->priv = MODEL_TIMECODE_TIME_SYSTEM_GET_PRIVATE (self);
1048         self->priv->small_pixel_frames = 0;
1049         self->priv->medium_pixel_frames = 0;
1050         self->priv->large_pixel_frames = 0;
1051         self->frame_rate_fraction = (fraction_init (&_tmp0_, 30000, 1001), _tmp0_);
1052 }
1053
1054
1055 static void model_timecode_time_system_finalize (GObject* obj) {
1056         ModelTimecodeTimeSystem * self;
1057         self = MODEL_TIMECODE_TIME_SYSTEM (obj);
1058         G_OBJECT_CLASS (model_timecode_time_system_parent_class)->finalize (obj);
1059 }
1060
1061
1062 GType model_timecode_time_system_get_type (void) {
1063         static volatile gsize model_timecode_time_system_type_id__volatile = 0;
1064         if (g_once_init_enter (&model_timecode_time_system_type_id__volatile)) {
1065                 static const GTypeInfo g_define_type_info = { sizeof (ModelTimecodeTimeSystemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) model_timecode_time_system_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ModelTimecodeTimeSystem), 0, (GInstanceInitFunc) model_timecode_time_system_instance_init, NULL };
1066                 static const GInterfaceInfo model_time_system_info = { (GInterfaceInitFunc) model_timecode_time_system_model_time_system_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
1067                 GType model_timecode_time_system_type_id;
1068                 model_timecode_time_system_type_id = g_type_register_static (MODEL_TYPE_TIME_SYSTEM_BASE, "ModelTimecodeTimeSystem", &g_define_type_info, 0);
1069                 g_type_add_interface_static (model_timecode_time_system_type_id, MODEL_TYPE_TIME_SYSTEM, &model_time_system_info);
1070                 g_once_init_leave (&model_timecode_time_system_type_id__volatile, model_timecode_time_system_type_id);
1071         }
1072         return model_timecode_time_system_type_id__volatile;
1073 }
1074
1075
1076 #line 212 "TimeSystem.vala"
1077 void model_tempo_information_get_time_signature (ModelTempoInformation* self, Fraction* result) {
1078 #line 212 "TimeSystem.vala"
1079         MODEL_TEMPO_INFORMATION_GET_INTERFACE (self)->get_time_signature (self, result);
1080 #line 1081 "TimeSystem.c"
1081 }
1082
1083
1084 #line 213 "TimeSystem.vala"
1085 gint model_tempo_information_get_bpm (ModelTempoInformation* self) {
1086 #line 213 "TimeSystem.vala"
1087         return MODEL_TEMPO_INFORMATION_GET_INTERFACE (self)->get_bpm (self);
1088 #line 1089 "TimeSystem.c"
1089 }
1090
1091
1092 static void model_tempo_information_base_init (ModelTempoInformationIface * iface) {
1093         static gboolean initialized = FALSE;
1094         if (!initialized) {
1095                 initialized = TRUE;
1096                 g_signal_new ("time_signature_changed", MODEL_TYPE_TEMPO_INFORMATION, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__BOXED, G_TYPE_NONE, 1, TYPE_FRACTION);
1097                 g_signal_new ("bpm_changed", MODEL_TYPE_TEMPO_INFORMATION, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
1098         }
1099 }
1100
1101
1102 GType model_tempo_information_get_type (void) {
1103         static volatile gsize model_tempo_information_type_id__volatile = 0;
1104         if (g_once_init_enter (&model_tempo_information_type_id__volatile)) {
1105                 static const GTypeInfo g_define_type_info = { sizeof (ModelTempoInformationIface), (GBaseInitFunc) model_tempo_information_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
1106                 GType model_tempo_information_type_id;
1107                 model_tempo_information_type_id = g_type_register_static (G_TYPE_INTERFACE, "ModelTempoInformation", &g_define_type_info, 0);
1108                 g_once_init_leave (&model_tempo_information_type_id__volatile, model_tempo_information_type_id);
1109         }
1110         return model_tempo_information_type_id__volatile;
1111 }
1112
1113
1114 #line 249 "TimeSystem.vala"
1115 static void _model_bar_beat_time_system_on_bpm_changed_model_tempo_information_bpm_changed (ModelTempoInformation* _sender, gint bpm, gpointer self) {
1116 #line 1117 "TimeSystem.c"
1117         model_bar_beat_time_system_on_bpm_changed (self, bpm);
1118 }
1119
1120
1121 #line 243 "TimeSystem.vala"
1122 static void _model_bar_beat_time_system_on_time_signature_changed_model_tempo_information_time_signature_changed (ModelTempoInformation* _sender, Fraction* time_signature, gpointer self) {
1123 #line 1124 "TimeSystem.c"
1124         model_bar_beat_time_system_on_time_signature_changed (self, time_signature);
1125 }
1126
1127
1128 #line 235 "TimeSystem.vala"
1129 ModelBarBeatTimeSystem* model_bar_beat_time_system_construct (GType object_type, ModelTempoInformation* tempo_information) {
1130 #line 1131 "TimeSystem.c"
1131         ModelBarBeatTimeSystem * self;
1132         Fraction _tmp0_ = {0};
1133 #line 235 "TimeSystem.vala"
1134         g_return_val_if_fail (MODEL_IS_TEMPO_INFORMATION (tempo_information), NULL);
1135 #line 235 "TimeSystem.vala"
1136         self = (ModelBarBeatTimeSystem*) model_time_system_base_construct (object_type);
1137 #line 236 "TimeSystem.vala"
1138         self->priv->bpm = model_tempo_information_get_bpm (tempo_information);
1139 #line 237 "TimeSystem.vala"
1140         self->priv->time_signature = (model_tempo_information_get_time_signature (tempo_information, &_tmp0_), _tmp0_);
1141 #line 238 "TimeSystem.vala"
1142         g_signal_connect_object (tempo_information, "bpm-changed", (GCallback) _model_bar_beat_time_system_on_bpm_changed_model_tempo_information_bpm_changed, self, 0);
1143 #line 239 "TimeSystem.vala"
1144         g_signal_connect_object (tempo_information, "time-signature-changed", (GCallback) _model_bar_beat_time_system_on_time_signature_changed_model_tempo_information_time_signature_changed, self, 0);
1145 #line 240 "TimeSystem.vala"
1146         model_bar_beat_time_system_set_constants (self);
1147 #line 1148 "TimeSystem.c"
1148         return self;
1149 }
1150
1151
1152 #line 235 "TimeSystem.vala"
1153 ModelBarBeatTimeSystem* model_bar_beat_time_system_new (ModelTempoInformation* tempo_information) {
1154 #line 235 "TimeSystem.vala"
1155         return model_bar_beat_time_system_construct (MODEL_TYPE_BAR_BEAT_TIME_SYSTEM, tempo_information);
1156 #line 1157 "TimeSystem.c"
1157 }
1158
1159
1160 #line 243 "TimeSystem.vala"
1161 static void model_bar_beat_time_system_on_time_signature_changed (ModelBarBeatTimeSystem* self, Fraction* time_signature) {
1162 #line 243 "TimeSystem.vala"
1163         g_return_if_fail (MODEL_IS_BAR_BEAT_TIME_SYSTEM (self));
1164 #line 244 "TimeSystem.vala"
1165         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_time_signature_changed");
1166 #line 245 "TimeSystem.vala"
1167         self->priv->time_signature = *time_signature;
1168 #line 246 "TimeSystem.vala"
1169         model_bar_beat_time_system_set_constants (self);
1170 #line 1171 "TimeSystem.c"
1171 }
1172
1173
1174 #line 249 "TimeSystem.vala"
1175 static void model_bar_beat_time_system_on_bpm_changed (ModelBarBeatTimeSystem* self, gint bpm) {
1176 #line 249 "TimeSystem.vala"
1177         g_return_if_fail (MODEL_IS_BAR_BEAT_TIME_SYSTEM (self));
1178 #line 250 "TimeSystem.vala"
1179         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_bpm_changed");
1180 #line 251 "TimeSystem.vala"
1181         self->priv->bpm = bpm;
1182 #line 252 "TimeSystem.vala"
1183         model_bar_beat_time_system_set_constants (self);
1184 #line 1185 "TimeSystem.c"
1185 }
1186
1187
1188 #line 255 "TimeSystem.vala"
1189 static void model_bar_beat_time_system_set_constants (ModelBarBeatTimeSystem* self) {
1190 #line 255 "TimeSystem.vala"
1191         g_return_if_fail (MODEL_IS_BAR_BEAT_TIME_SYSTEM (self));
1192 #line 256 "TimeSystem.vala"
1193         self->priv->bars_per_minute = self->priv->bpm / ((float) self->priv->time_signature.numerator);
1194 #line 257 "TimeSystem.vala"
1195         self->priv->bars_per_second = self->priv->bars_per_minute / 60.0f;
1196 #line 259 "TimeSystem.vala"
1197         self->priv->sixteenths_per_beat = 16 / self->priv->time_signature.denominator;
1198 #line 260 "TimeSystem.vala"
1199         self->priv->sixteenths_per_bar = self->priv->time_signature.numerator * self->priv->sixteenths_per_beat;
1200 #line 261 "TimeSystem.vala"
1201         g_signal_emit_by_name (MODEL_TIME_SYSTEM (self), "geometry-changed");
1202 #line 1203 "TimeSystem.c"
1203 }
1204
1205
1206 #line 264 "TimeSystem.vala"
1207 static gint model_bar_beat_time_system_real_correct_sub_second_value (ModelTimeSystemBase* base, float bars, gint div, gint unused) {
1208 #line 1209 "TimeSystem.c"
1209         ModelBarBeatTimeSystem * self;
1210         gint result = 0;
1211         gint sixteenths;
1212         self = MODEL_BAR_BEAT_TIME_SYSTEM (base);
1213 #line 265 "TimeSystem.vala"
1214         sixteenths = (gint) (self->priv->sixteenths_per_bar * bars);
1215 #line 267 "TimeSystem.vala"
1216         if (sixteenths == 0) {
1217 #line 1218 "TimeSystem.c"
1218                 result = 1;
1219 #line 268 "TimeSystem.vala"
1220                 return result;
1221 #line 1222 "TimeSystem.c"
1222         }
1223 #line 271 "TimeSystem.vala"
1224         if (sixteenths > self->priv->sixteenths_per_beat) {
1225 #line 1226 "TimeSystem.c"
1226                 result = self->priv->sixteenths_per_beat;
1227 #line 272 "TimeSystem.vala"
1228                 return result;
1229 #line 1230 "TimeSystem.c"
1230         }
1231 #line 275 "TimeSystem.vala"
1232         if (sixteenths > 2) {
1233 #line 1234 "TimeSystem.c"
1234                 result = 2;
1235 #line 276 "TimeSystem.vala"
1236                 return result;
1237 #line 1238 "TimeSystem.c"
1238         }
1239         result = 1;
1240 #line 279 "TimeSystem.vala"
1241         return result;
1242 #line 1243 "TimeSystem.c"
1243 }
1244
1245
1246 #line 282 "TimeSystem.vala"
1247 static char* model_bar_beat_time_system_beats_to_string (ModelBarBeatTimeSystem* self, gint total_sixteenths, gboolean maximum_resolution, gboolean zero_based) {
1248 #line 1249 "TimeSystem.c"
1249         char* result = NULL;
1250         gint number_of_measures;
1251         gint number_of_beats;
1252         gint number_of_sixteenths;
1253         float pixels_per_bar;
1254         float pixels_per_large_gap;
1255         gboolean _tmp0_ = FALSE;
1256 #line 282 "TimeSystem.vala"
1257         g_return_val_if_fail (MODEL_IS_BAR_BEAT_TIME_SYSTEM (self), NULL);
1258 #line 284 "TimeSystem.vala"
1259         number_of_measures = (total_sixteenths / self->priv->sixteenths_per_beat) / self->priv->time_signature.numerator;
1260 #line 287 "TimeSystem.vala"
1261         number_of_beats = (total_sixteenths / self->priv->sixteenths_per_beat) % self->priv->time_signature.numerator;
1262 #line 288 "TimeSystem.vala"
1263         number_of_sixteenths = total_sixteenths % self->priv->sixteenths_per_beat;
1264 #line 289 "TimeSystem.vala"
1265         if (!zero_based) {
1266 #line 290 "TimeSystem.vala"
1267                 number_of_measures = number_of_measures + 1;
1268 #line 291 "TimeSystem.vala"
1269                 number_of_beats = number_of_beats + 1;
1270 #line 292 "TimeSystem.vala"
1271                 number_of_sixteenths = number_of_sixteenths + 1;
1272 #line 1273 "TimeSystem.c"
1273         }
1274 #line 294 "TimeSystem.vala"
1275         pixels_per_bar = MODEL_TIME_SYSTEM_BASE (self)->pixels_per_second / self->priv->bars_per_second;
1276 #line 295 "TimeSystem.vala"
1277         pixels_per_large_gap = self->priv->large_pixel_sixteenth * self->priv->pixels_per_sixteenth;
1278 #line 296 "TimeSystem.vala"
1279         if (maximum_resolution) {
1280 #line 296 "TimeSystem.vala"
1281                 _tmp0_ = TRUE;
1282 #line 1283 "TimeSystem.c"
1283         } else {
1284                 gboolean _tmp1_ = FALSE;
1285 #line 297 "TimeSystem.vala"
1286                 if (pixels_per_large_gap < (self->priv->pixels_per_sixteenth * self->priv->sixteenths_per_beat)) {
1287 #line 298 "TimeSystem.vala"
1288                         _tmp1_ = number_of_sixteenths > 1;
1289 #line 1290 "TimeSystem.c"
1290                 } else {
1291 #line 297 "TimeSystem.vala"
1292                         _tmp1_ = FALSE;
1293 #line 1294 "TimeSystem.c"
1294                 }
1295 #line 297 "TimeSystem.vala"
1296                 _tmp0_ = _tmp1_;
1297 #line 1298 "TimeSystem.c"
1298         }
1299 #line 296 "TimeSystem.vala"
1300         if (_tmp0_) {
1301 #line 1302 "TimeSystem.c"
1302                 result = g_strdup_printf ("%d.%d.%d", number_of_measures, number_of_beats, number_of_sixteenths);
1303 #line 299 "TimeSystem.vala"
1304                 return result;
1305 #line 1306 "TimeSystem.c"
1306         } else {
1307                 gboolean _tmp2_ = FALSE;
1308 #line 300 "TimeSystem.vala"
1309                 if (pixels_per_large_gap < pixels_per_bar) {
1310 #line 300 "TimeSystem.vala"
1311                         _tmp2_ = number_of_beats > 1;
1312 #line 1313 "TimeSystem.c"
1313                 } else {
1314 #line 300 "TimeSystem.vala"
1315                         _tmp2_ = FALSE;
1316 #line 1317 "TimeSystem.c"
1317                 }
1318 #line 300 "TimeSystem.vala"
1319                 if (_tmp2_) {
1320 #line 1321 "TimeSystem.c"
1321                         result = g_strdup_printf ("%d.%d", number_of_measures, number_of_beats);
1322 #line 301 "TimeSystem.vala"
1323                         return result;
1324 #line 1325 "TimeSystem.c"
1325                 } else {
1326                         result = g_strdup_printf ("%d", number_of_measures);
1327 #line 303 "TimeSystem.vala"
1328                         return result;
1329 #line 1330 "TimeSystem.c"
1330                 }
1331         }
1332 }
1333
1334
1335 #line 307 "TimeSystem.vala"
1336 static char* model_bar_beat_time_system_real_get_time_string (ModelTimeSystem* base, gint64 the_time) {
1337 #line 1338 "TimeSystem.c"
1338         ModelBarBeatTimeSystem * self;
1339         char* result = NULL;
1340         double beats_per_second;
1341         double sixteenths_per_second;
1342         double sixteenths_per_nanosecond;
1343         gint total_beats;
1344         self = MODEL_BAR_BEAT_TIME_SYSTEM (base);
1345 #line 308 "TimeSystem.vala"
1346         beats_per_second = self->priv->bpm / 60.0;
1347 #line 309 "TimeSystem.vala"
1348         sixteenths_per_second = self->priv->sixteenths_per_beat * beats_per_second;
1349 #line 310 "TimeSystem.vala"
1350         sixteenths_per_nanosecond = sixteenths_per_second / GST_SECOND;
1351 #line 311 "TimeSystem.vala"
1352         total_beats = (gint) (the_time * sixteenths_per_nanosecond);
1353 #line 1354 "TimeSystem.c"
1354         result = model_bar_beat_time_system_beats_to_string (self, total_beats, TRUE, FALSE);
1355 #line 312 "TimeSystem.vala"
1356         return result;
1357 #line 1358 "TimeSystem.c"
1358 }
1359
1360
1361 #line 315 "TimeSystem.vala"
1362 static char* model_bar_beat_time_system_real_get_time_duration (ModelTimeSystem* base, gint64 the_time) {
1363 #line 1364 "TimeSystem.c"
1364         ModelBarBeatTimeSystem * self;
1365         char* result = NULL;
1366         double beats_per_second;
1367         double sixteenths_per_second;
1368         double sixteenths_per_nanosecond;
1369         gint total_beats;
1370         gboolean _tmp0_ = FALSE;
1371         self = MODEL_BAR_BEAT_TIME_SYSTEM (base);
1372 #line 316 "TimeSystem.vala"
1373         beats_per_second = self->priv->bpm / 60.0;
1374 #line 317 "TimeSystem.vala"
1375         sixteenths_per_second = self->priv->sixteenths_per_beat * beats_per_second;
1376 #line 318 "TimeSystem.vala"
1377         sixteenths_per_nanosecond = sixteenths_per_second / GST_SECOND;
1378 #line 319 "TimeSystem.vala"
1379         total_beats = (gint) (the_time * sixteenths_per_nanosecond);
1380 #line 320 "TimeSystem.vala"
1381         if (total_beats == 0) {
1382 #line 320 "TimeSystem.vala"
1383                 _tmp0_ = the_time > 0;
1384 #line 1385 "TimeSystem.c"
1385         } else {
1386 #line 320 "TimeSystem.vala"
1387                 _tmp0_ = FALSE;
1388 #line 1389 "TimeSystem.c"
1389         }
1390 #line 320 "TimeSystem.vala"
1391         if (_tmp0_) {
1392 #line 322 "TimeSystem.vala"
1393                 total_beats = 1;
1394 #line 1395 "TimeSystem.c"
1395         }
1396         result = model_bar_beat_time_system_beats_to_string (self, total_beats, TRUE, TRUE);
1397 #line 324 "TimeSystem.vala"
1398         return result;
1399 #line 1400 "TimeSystem.c"
1400 }
1401
1402
1403 #line 327 "TimeSystem.vala"
1404 static void model_bar_beat_time_system_real_calculate_pixel_step (ModelTimeSystem* base, float inc, float pixel_min, float pixel_div) {
1405 #line 1406 "TimeSystem.c"
1406         ModelBarBeatTimeSystem * self;
1407         gint pixels_per_large;
1408         gint pixels_per_medium;
1409         gint pixels_per_small;
1410         float pixels_per_bar;
1411         self = MODEL_BAR_BEAT_TIME_SYSTEM (base);
1412 #line 328 "TimeSystem.vala"
1413         pixels_per_large = 80;
1414 #line 329 "TimeSystem.vala"
1415         pixels_per_medium = 40;
1416 #line 330 "TimeSystem.vala"
1417         pixels_per_small = 20;
1418 #line 332 "TimeSystem.vala"
1419         MODEL_TIME_SYSTEM_BASE (self)->pixel_percentage = MODEL_TIME_SYSTEM_BASE (self)->pixel_percentage + inc;
1420 #line 333 "TimeSystem.vala"
1421         if (MODEL_TIME_SYSTEM_BASE (self)->pixel_percentage < 0.0f) {
1422 #line 334 "TimeSystem.vala"
1423                 MODEL_TIME_SYSTEM_BASE (self)->pixel_percentage = 0.0f;
1424 #line 1425 "TimeSystem.c"
1425         } else {
1426 #line 335 "TimeSystem.vala"
1427                 if (MODEL_TIME_SYSTEM_BASE (self)->pixel_percentage > 1.0f) {
1428 #line 336 "TimeSystem.vala"
1429                         MODEL_TIME_SYSTEM_BASE (self)->pixel_percentage = 1.0f;
1430 #line 1431 "TimeSystem.c"
1431                 }
1432         }
1433 #line 339 "TimeSystem.vala"
1434         MODEL_TIME_SYSTEM_BASE (self)->pixels_per_second = pixel_min * powf (pixel_div, MODEL_TIME_SYSTEM_BASE (self)->pixel_percentage);
1435 #line 340 "TimeSystem.vala"
1436         pixels_per_bar = MODEL_TIME_SYSTEM_BASE (self)->pixels_per_second / self->priv->bars_per_second;
1437 #line 341 "TimeSystem.vala"
1438         self->priv->large_pixel_sixteenth = model_time_system_base_correct_seconds_value (MODEL_TIME_SYSTEM_BASE (self), pixels_per_large / pixels_per_bar, 0, self->priv->sixteenths_per_bar);
1439 #line 344 "TimeSystem.vala"
1440         self->priv->medium_pixel_sixteenth = model_time_system_base_correct_seconds_value (MODEL_TIME_SYSTEM_BASE (self), pixels_per_medium / pixels_per_bar, self->priv->large_pixel_sixteenth, self->priv->sixteenths_per_bar);
1441 #line 346 "TimeSystem.vala"
1442         self->priv->small_pixel_sixteenth = model_time_system_base_correct_seconds_value (MODEL_TIME_SYSTEM_BASE (self), pixels_per_small / pixels_per_bar, self->priv->medium_pixel_sixteenth, self->priv->sixteenths_per_bar);
1443 #line 348 "TimeSystem.vala"
1444         if (self->priv->small_pixel_sixteenth == self->priv->medium_pixel_sixteenth) {
1445 #line 1446 "TimeSystem.c"
1446                 gint i;
1447 #line 349 "TimeSystem.vala"
1448                 i = self->priv->medium_pixel_sixteenth;
1449 #line 351 "TimeSystem.vala"
1450                 while (TRUE) {
1451 #line 351 "TimeSystem.vala"
1452                         if (!((i = i - 1) > 0)) {
1453 #line 351 "TimeSystem.vala"
1454                                 break;
1455 #line 1456 "TimeSystem.c"
1456                         }
1457 #line 352 "TimeSystem.vala"
1458                         if ((self->priv->medium_pixel_sixteenth % i) == 0) {
1459 #line 353 "TimeSystem.vala"
1460                                 self->priv->small_pixel_sixteenth = i;
1461 #line 354 "TimeSystem.vala"
1462                                 break;
1463 #line 1464 "TimeSystem.c"
1464                         }
1465                 }
1466         }
1467 #line 359 "TimeSystem.vala"
1468         self->priv->pixels_per_sixteenth = pixels_per_bar / ((float) self->priv->sixteenths_per_bar);
1469 #line 360 "TimeSystem.vala"
1470         MODEL_TIME_SYSTEM_BASE (self)->pixel_snap_time = model_time_system_xsize_to_time (MODEL_TIME_SYSTEM (self), MODEL_TIME_SYSTEM_BASE_PIXEL_SNAP_INTERVAL);
1471 #line 1472 "TimeSystem.c"
1472 }
1473
1474
1475 #line 363 "TimeSystem.vala"
1476 static gint model_bar_beat_time_system_real_frame_to_xsize (ModelTimeSystem* base, gint frame) {
1477 #line 1478 "TimeSystem.c"
1478         ModelBarBeatTimeSystem * self;
1479         gint result = 0;
1480         self = MODEL_BAR_BEAT_TIME_SYSTEM (base);
1481         result = (gint) (frame * self->priv->pixels_per_sixteenth);
1482 #line 364 "TimeSystem.vala"
1483         return result;
1484 #line 1485 "TimeSystem.c"
1485 }
1486
1487
1488 #line 367 "TimeSystem.vala"
1489 static gint model_bar_beat_time_system_real_xsize_to_frame (ModelTimeSystem* base, gint xsize) {
1490 #line 1491 "TimeSystem.c"
1491         ModelBarBeatTimeSystem * self;
1492         gint result = 0;
1493         self = MODEL_BAR_BEAT_TIME_SYSTEM (base);
1494         result = (gint) (xsize / self->priv->pixels_per_sixteenth);
1495 #line 368 "TimeSystem.vala"
1496         return result;
1497 #line 1498 "TimeSystem.c"
1498 }
1499
1500
1501 #line 371 "TimeSystem.vala"
1502 static gint model_bar_beat_time_system_real_get_start_token (ModelTimeSystem* base, gint xsize) {
1503 #line 1504 "TimeSystem.c"
1504         ModelBarBeatTimeSystem * self;
1505         gint result = 0;
1506         gint start_frame;
1507         self = MODEL_BAR_BEAT_TIME_SYSTEM (base);
1508 #line 372 "TimeSystem.vala"
1509         start_frame = model_time_system_xsize_to_frame (MODEL_TIME_SYSTEM (self), xsize);
1510 #line 1511 "TimeSystem.c"
1511         result = self->priv->large_pixel_sixteenth * (start_frame / self->priv->large_pixel_sixteenth);
1512 #line 373 "TimeSystem.vala"
1513         return result;
1514 #line 1515 "TimeSystem.c"
1515 }
1516
1517
1518 #line 376 "TimeSystem.vala"
1519 static gint model_bar_beat_time_system_real_get_next_position (ModelTimeSystem* base, gint token) {
1520 #line 1521 "TimeSystem.c"
1521         ModelBarBeatTimeSystem * self;
1522         gint result = 0;
1523         self = MODEL_BAR_BEAT_TIME_SYSTEM (base);
1524         result = token + self->priv->small_pixel_sixteenth;
1525 #line 377 "TimeSystem.vala"
1526         return result;
1527 #line 1528 "TimeSystem.c"
1528 }
1529
1530
1531 #line 380 "TimeSystem.vala"
1532 static char* model_bar_beat_time_system_real_get_display_string (ModelTimeSystem* base, gint frame) {
1533 #line 1534 "TimeSystem.c"
1534         ModelBarBeatTimeSystem * self;
1535         char* result = NULL;
1536         self = MODEL_BAR_BEAT_TIME_SYSTEM (base);
1537 #line 381 "TimeSystem.vala"
1538         if ((frame % self->priv->large_pixel_sixteenth) == 0) {
1539 #line 1540 "TimeSystem.c"
1540                 result = model_bar_beat_time_system_beats_to_string (self, frame, FALSE, FALSE);
1541 #line 382 "TimeSystem.vala"
1542                 return result;
1543 #line 1544 "TimeSystem.c"
1544         }
1545         result = NULL;
1546 #line 384 "TimeSystem.vala"
1547         return result;
1548 #line 1549 "TimeSystem.c"
1549 }
1550
1551
1552 #line 387 "TimeSystem.vala"
1553 static gint model_bar_beat_time_system_real_get_pixel_height (ModelTimeSystem* base, gint frame) {
1554 #line 1555 "TimeSystem.c"
1555         ModelBarBeatTimeSystem * self;
1556         gint result = 0;
1557         self = MODEL_BAR_BEAT_TIME_SYSTEM (base);
1558 #line 388 "TimeSystem.vala"
1559         if ((frame % self->priv->medium_pixel_sixteenth) == 0) {
1560 #line 1561 "TimeSystem.c"
1561                 gboolean _tmp0_ = FALSE;
1562 #line 389 "TimeSystem.vala"
1563                 if (self->priv->medium_pixel_sixteenth == self->priv->small_pixel_sixteenth) {
1564 #line 1565 "TimeSystem.c"
1565                         gboolean _tmp1_ = FALSE;
1566 #line 390 "TimeSystem.vala"
1567                         if (self->priv->medium_pixel_sixteenth != self->priv->large_pixel_sixteenth) {
1568 #line 391 "TimeSystem.vala"
1569                                 _tmp1_ = (frame % self->priv->large_pixel_sixteenth) != 0;
1570 #line 1571 "TimeSystem.c"
1571                         } else {
1572 #line 390 "TimeSystem.vala"
1573                                 _tmp1_ = FALSE;
1574 #line 1575 "TimeSystem.c"
1575                         }
1576 #line 390 "TimeSystem.vala"
1577                         _tmp0_ = _tmp1_;
1578 #line 1579 "TimeSystem.c"
1579                 } else {
1580 #line 389 "TimeSystem.vala"
1581                         _tmp0_ = FALSE;
1582 #line 1583 "TimeSystem.c"
1583                 }
1584 #line 389 "TimeSystem.vala"
1585                 if (_tmp0_) {
1586 #line 1587 "TimeSystem.c"
1587                         result = 2;
1588 #line 392 "TimeSystem.vala"
1589                         return result;
1590 #line 1591 "TimeSystem.c"
1591                 } else {
1592                         result = 6;
1593 #line 395 "TimeSystem.vala"
1594                         return result;
1595 #line 1596 "TimeSystem.c"
1596                 }
1597         } else {
1598                 result = 2;
1599 #line 398 "TimeSystem.vala"
1600                 return result;
1601 #line 1602 "TimeSystem.c"
1602         }
1603 }
1604
1605
1606 static gint* _vala_array_dup1 (gint* self, int length) {
1607         return g_memdup (self, length * sizeof (gint));
1608 }
1609
1610
1611 #line 402 "TimeSystem.vala"
1612 static gint* model_bar_beat_time_system_real_get_timeline_seconds (ModelTimeSystemBase* base, int* result_length1) {
1613 #line 1614 "TimeSystem.c"
1614         ModelBarBeatTimeSystem * self;
1615         gint* result = NULL;
1616         gint* _tmp0_;
1617         gint* _tmp1_;
1618         self = MODEL_BAR_BEAT_TIME_SYSTEM (base);
1619         result = (_tmp1_ = (_tmp0_ = self->priv->timeline_bars, (_tmp0_ == NULL) ? ((gpointer) _tmp0_) : _vala_array_dup1 (_tmp0_, self->priv->timeline_bars_length1)), *result_length1 = self->priv->timeline_bars_length1, _tmp1_);
1620 #line 403 "TimeSystem.vala"
1621         return result;
1622 #line 1623 "TimeSystem.c"
1623 }
1624
1625
1626 static void model_bar_beat_time_system_class_init (ModelBarBeatTimeSystemClass * klass) {
1627         model_bar_beat_time_system_parent_class = g_type_class_peek_parent (klass);
1628         g_type_class_add_private (klass, sizeof (ModelBarBeatTimeSystemPrivate));
1629         MODEL_TIME_SYSTEM_BASE_CLASS (klass)->correct_sub_second_value = model_bar_beat_time_system_real_correct_sub_second_value;
1630         MODEL_TIME_SYSTEM_BASE_CLASS (klass)->get_timeline_seconds = model_bar_beat_time_system_real_get_timeline_seconds;
1631         G_OBJECT_CLASS (klass)->finalize = model_bar_beat_time_system_finalize;
1632 }
1633
1634
1635 static void model_bar_beat_time_system_model_time_system_interface_init (ModelTimeSystemIface * iface) {
1636         model_bar_beat_time_system_model_time_system_parent_iface = g_type_interface_peek_parent (iface);
1637         iface->get_time_string = model_bar_beat_time_system_real_get_time_string;
1638         iface->get_time_duration = model_bar_beat_time_system_real_get_time_duration;
1639         iface->calculate_pixel_step = model_bar_beat_time_system_real_calculate_pixel_step;
1640         iface->frame_to_xsize = model_bar_beat_time_system_real_frame_to_xsize;
1641         iface->xsize_to_frame = model_bar_beat_time_system_real_xsize_to_frame;
1642         iface->get_start_token = model_bar_beat_time_system_real_get_start_token;
1643         iface->get_next_position = model_bar_beat_time_system_real_get_next_position;
1644         iface->get_display_string = model_bar_beat_time_system_real_get_display_string;
1645         iface->get_pixel_height = model_bar_beat_time_system_real_get_pixel_height;
1646         iface->xpos_to_time = (gint64 (*)(ModelTimeSystem* ,gint)) model_time_system_base_xpos_to_time;
1647         iface->xsize_to_time = (gint64 (*)(ModelTimeSystem* ,gint)) model_time_system_base_xsize_to_time;
1648         iface->time_to_xpos = (gint (*)(ModelTimeSystem* ,gint64)) model_time_system_base_time_to_xpos;
1649         iface->get_pixel_snap_time = (gint64 (*)(ModelTimeSystem*)) model_time_system_base_get_pixel_snap_time;
1650         iface->time_to_xsize = (gint (*)(ModelTimeSystem* ,gint64)) model_time_system_base_time_to_xsize;
1651         iface->get_pixel_percentage = (float (*)(ModelTimeSystem*)) model_time_system_base_get_pixel_percentage;
1652 }
1653
1654
1655 static void model_bar_beat_time_system_instance_init (ModelBarBeatTimeSystem * self) {
1656         gint* _tmp1_ = NULL;
1657         self->priv = MODEL_BAR_BEAT_TIME_SYSTEM_GET_PRIVATE (self);
1658         self->priv->small_pixel_sixteenth = 0;
1659         self->priv->medium_pixel_sixteenth = 0;
1660         self->priv->large_pixel_sixteenth = 0;
1661         self->priv->timeline_bars = (_tmp1_ = g_new0 (gint, 15), _tmp1_[0] = 1, _tmp1_[1] = 2, _tmp1_[2] = 4, _tmp1_[3] = 8, _tmp1_[4] = 16, _tmp1_[5] = 24, _tmp1_[6] = 32, _tmp1_[7] = 64, _tmp1_[8] = 128, _tmp1_[9] = 256, _tmp1_[10] = 512, _tmp1_[11] = 768, _tmp1_[12] = 1024, _tmp1_[13] = 2048, _tmp1_[14] = 3192, _tmp1_);
1662         self->priv->timeline_bars_length1 = 15;
1663         self->priv->_timeline_bars_size_ = self->priv->timeline_bars_length1;
1664 }
1665
1666
1667 static void model_bar_beat_time_system_finalize (GObject* obj) {
1668         ModelBarBeatTimeSystem * self;
1669         self = MODEL_BAR_BEAT_TIME_SYSTEM (obj);
1670         self->priv->timeline_bars = (g_free (self->priv->timeline_bars), NULL);
1671         G_OBJECT_CLASS (model_bar_beat_time_system_parent_class)->finalize (obj);
1672 }
1673
1674
1675 GType model_bar_beat_time_system_get_type (void) {
1676         static volatile gsize model_bar_beat_time_system_type_id__volatile = 0;
1677         if (g_once_init_enter (&model_bar_beat_time_system_type_id__volatile)) {
1678                 static const GTypeInfo g_define_type_info = { sizeof (ModelBarBeatTimeSystemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) model_bar_beat_time_system_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ModelBarBeatTimeSystem), 0, (GInstanceInitFunc) model_bar_beat_time_system_instance_init, NULL };
1679                 static const GInterfaceInfo model_time_system_info = { (GInterfaceInitFunc) model_bar_beat_time_system_model_time_system_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
1680                 GType model_bar_beat_time_system_type_id;
1681                 model_bar_beat_time_system_type_id = g_type_register_static (MODEL_TYPE_TIME_SYSTEM_BASE, "ModelBarBeatTimeSystem", &g_define_type_info, 0);
1682                 g_type_add_interface_static (model_bar_beat_time_system_type_id, MODEL_TYPE_TIME_SYSTEM, &model_time_system_info);
1683                 g_once_init_leave (&model_bar_beat_time_system_type_id__volatile, model_bar_beat_time_system_type_id);
1684         }
1685         return model_bar_beat_time_system_type_id__volatile;
1686 }
1687
1688
1689
1690 static void g_cclosure_user_marshal_VOID__BOXED (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
1691         typedef void (*GMarshalFunc_VOID__BOXED) (gpointer data1, gpointer arg_1, gpointer data2);
1692         register GMarshalFunc_VOID__BOXED callback;
1693         register GCClosure * cc;
1694         register gpointer data1, data2;
1695         cc = (GCClosure *) closure;
1696         g_return_if_fail (n_param_values == 2);
1697         if (G_CCLOSURE_SWAP_DATA (closure)) {
1698                 data1 = closure->data;
1699                 data2 = param_values->data[0].v_pointer;
1700         } else {
1701                 data1 = param_values->data[0].v_pointer;
1702                 data2 = closure->data;
1703         }
1704         callback = (GMarshalFunc_VOID__BOXED) (marshal_data ? marshal_data : cc->callback);
1705         callback (data1, g_value_get_boxed (param_values + 1), data2);
1706 }
1707
1708
1709