Source file scene_format_b.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
[@@@ocaml.warning "-27-32-33-35-39"]
type bpm_operation = Scene_format_t.bpm_operation
type id = Scene_format_t.id
type midi_event = Scene_format_t.midi_event = {
port: int;
status: int;
channel: int;
data1: int;
data2: int option
}
type event = Scene_format_t.event =
Track_ends of id
| Track_starts of id
| Midi_input of midi_event
type action = Scene_format_t.action =
Raw_midi of midi_event
| Track_on of (id * int)
| Track_off of id
| Bpm_operation of bpm_operation
| Add_event_handler of event_handler
| Remove_event_handler of event_handler
| Remove_event_handler_by_event of event
| All_tracks_off
| Stop
and event_handler = Scene_format_t.event_handler = {
name: string;
events: event list;
actions: action list
}
type ticked_action = Scene_format_t.ticked_action = {
tick: int;
action: action
}
type track = Scene_format_t.track = {
id: id;
events: ticked_action list;
length: int;
name: string
}
type scene = Scene_format_t.scene = {
active: id list;
handlers: event_handler list;
bpm: int;
ppqn: int;
tracks: track list
}
let _1_tag = Bi_io.num_variant_tag
let write_untagged__1 = (
Atdgen_runtime.Ob_run.write_untagged_option (
Bi_io.write_svint
)
)
let write__1 ob x =
Bi_io.write_tag ob Bi_io.num_variant_tag;
write_untagged__1 ob x
let string_of__1 ?(len = 1024) x =
let ob = Bi_outbuf.create len in
write__1 ob x;
Bi_outbuf.contents ob
let get__1_reader = (
fun tag ->
if tag <> 22 then Atdgen_runtime.Ob_run.read_error () else
fun ib ->
match Char.code (Bi_inbuf.read_char ib) with
| 0 -> None
| 0x80 ->
Some (
(
Atdgen_runtime.Ob_run.read_int
)
ib
)
| _ -> Atdgen_runtime.Ob_run.read_error_at ib
)
let read__1 = (
fun ib ->
if Bi_io.read_tag ib <> 22 then Atdgen_runtime.Ob_run.read_error_at ib;
match Char.code (Bi_inbuf.read_char ib) with
| 0 -> None
| 0x80 ->
Some (
(
Atdgen_runtime.Ob_run.read_int
)
ib
)
| _ -> Atdgen_runtime.Ob_run.read_error_at ib
)
let _1_of_string ?pos s =
read__1 (Bi_inbuf.from_string ?pos s)
let bpm_operation_tag = Bi_io.variant_tag
let write_untagged_bpm_operation = (
fun ob x ->
match x with
| `Set x ->
Bi_outbuf.add_char4 ob '\128' '?' 'S' '\130';
(
Bi_io.write_svint
) ob x
| `Incr x ->
Bi_outbuf.add_char4 ob '\176' '\148' 'a' '\244';
(
Bi_io.write_svint
) ob x
| `Decr x ->
Bi_outbuf.add_char4 ob '\173' '?' '|' '\144';
(
Bi_io.write_svint
) ob x
| `Mul x ->
Bi_outbuf.add_char4 ob '\128' ':' '\211' '\228';
(
Bi_io.write_float64
) ob x
)
let write_bpm_operation ob x =
Bi_io.write_tag ob Bi_io.variant_tag;
write_untagged_bpm_operation ob x
let string_of_bpm_operation ?(len = 1024) x =
let ob = Bi_outbuf.create len in
write_bpm_operation ob x;
Bi_outbuf.contents ob
let get_bpm_operation_reader = (
fun tag ->
if tag <> 23 then Atdgen_runtime.Ob_run.read_error () else
fun ib ->
Bi_io.read_hashtag ib (fun ib h has_arg ->
match h, has_arg with
| 4150146, true -> (`Set (
(
Atdgen_runtime.Ob_run.read_int
) ib
))
| 815030772, true -> (`Incr (
(
Atdgen_runtime.Ob_run.read_int
) ib
))
| 759135376, true -> (`Decr (
(
Atdgen_runtime.Ob_run.read_int
) ib
))
| 3855332, true -> (`Mul (
(
Atdgen_runtime.Ob_run.read_float64
) ib
))
| _ -> Atdgen_runtime.Ob_run.unsupported_variant h has_arg
)
)
let read_bpm_operation = (
fun ib ->
if Bi_io.read_tag ib <> 23 then Atdgen_runtime.Ob_run.read_error_at ib;
Bi_io.read_hashtag ib (fun ib h has_arg ->
match h, has_arg with
| 4150146, true -> (`Set (
(
Atdgen_runtime.Ob_run.read_int
) ib
))
| 815030772, true -> (`Incr (
(
Atdgen_runtime.Ob_run.read_int
) ib
))
| 759135376, true -> (`Decr (
(
Atdgen_runtime.Ob_run.read_int
) ib
))
| 3855332, true -> (`Mul (
(
Atdgen_runtime.Ob_run.read_float64
) ib
))
| _ -> Atdgen_runtime.Ob_run.unsupported_variant h has_arg
)
)
let bpm_operation_of_string ?pos s =
read_bpm_operation (Bi_inbuf.from_string ?pos s)
let id_tag = Bi_io.string_tag
let write_untagged_id = (
Bi_io.write_untagged_string
)
let write_id ob x =
Bi_io.write_tag ob Bi_io.string_tag;
write_untagged_id ob x
let string_of_id ?(len = 1024) x =
let ob = Bi_outbuf.create len in
write_id ob x;
Bi_outbuf.contents ob
let get_id_reader = (
Atdgen_runtime.Ob_run.get_string_reader
)
let read_id = (
Atdgen_runtime.Ob_run.read_string
)
let id_of_string ?pos s =
read_id (Bi_inbuf.from_string ?pos s)
let midi_event_tag = Bi_io.record_tag
let write_untagged_midi_event : Bi_outbuf.t -> midi_event -> unit = (
fun ob x ->
Bi_vint.write_uvint ob 5;
Bi_outbuf.add_char4 ob '\202' '\\' '\131' '\129';
(
Bi_io.write_svint
) ob x.port;
Bi_outbuf.add_char4 ob '\133' '\251' '\231' '2';
(
Bi_io.write_svint
) ob x.status;
Bi_outbuf.add_char4 ob '\204' '\210' '\000' '\195';
(
Bi_io.write_svint
) ob x.channel;
Bi_outbuf.add_char4 ob '\212' '\136' '\014' '\199';
(
Bi_io.write_svint
) ob x.data1;
Bi_outbuf.add_char4 ob '\212' '\136' '\014' '\200';
(
write__1
) ob x.data2;
)
let write_midi_event ob x =
Bi_io.write_tag ob Bi_io.record_tag;
write_untagged_midi_event ob x
let string_of_midi_event ?(len = 1024) x =
let ob = Bi_outbuf.create len in
write_midi_event ob x;
Bi_outbuf.contents ob
let get_midi_event_reader = (
fun tag ->
if tag <> 21 then Atdgen_runtime.Ob_run.read_error () else
fun ib ->
let field_port = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_status = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_channel = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_data1 = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_data2 = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let bits0 = ref 0 in
let len = Bi_vint.read_uvint ib in
for i = 1 to len do
match Bi_io.read_field_hashtag ib with
| -899906687 ->
field_port := (
(
Atdgen_runtime.Ob_run.read_int
) ib
);
bits0 := !bits0 lor 0x1;
| 100394802 ->
field_status := (
(
Atdgen_runtime.Ob_run.read_int
) ib
);
bits0 := !bits0 lor 0x2;
| -858652477 ->
field_channel := (
(
Atdgen_runtime.Ob_run.read_int
) ib
);
bits0 := !bits0 lor 0x4;
| -729280825 ->
field_data1 := (
(
Atdgen_runtime.Ob_run.read_int
) ib
);
bits0 := !bits0 lor 0x8;
| -729280824 ->
field_data2 := (
(
read__1
) ib
);
bits0 := !bits0 lor 0x10;
| _ -> Bi_io.skip ib
done;
if !bits0 <> 0x1f then Atdgen_runtime.Ob_run.missing_fields [| !bits0 |] [| "port"; "status"; "channel"; "data1"; "data2" |];
(
{
port = !field_port;
status = !field_status;
channel = !field_channel;
data1 = !field_data1;
data2 = !field_data2;
}
: midi_event)
)
let read_midi_event = (
fun ib ->
if Bi_io.read_tag ib <> 21 then Atdgen_runtime.Ob_run.read_error_at ib;
let field_port = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_status = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_channel = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_data1 = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_data2 = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let bits0 = ref 0 in
let len = Bi_vint.read_uvint ib in
for i = 1 to len do
match Bi_io.read_field_hashtag ib with
| -899906687 ->
field_port := (
(
Atdgen_runtime.Ob_run.read_int
) ib
);
bits0 := !bits0 lor 0x1;
| 100394802 ->
field_status := (
(
Atdgen_runtime.Ob_run.read_int
) ib
);
bits0 := !bits0 lor 0x2;
| -858652477 ->
field_channel := (
(
Atdgen_runtime.Ob_run.read_int
) ib
);
bits0 := !bits0 lor 0x4;
| -729280825 ->
field_data1 := (
(
Atdgen_runtime.Ob_run.read_int
) ib
);
bits0 := !bits0 lor 0x8;
| -729280824 ->
field_data2 := (
(
read__1
) ib
);
bits0 := !bits0 lor 0x10;
| _ -> Bi_io.skip ib
done;
if !bits0 <> 0x1f then Atdgen_runtime.Ob_run.missing_fields [| !bits0 |] [| "port"; "status"; "channel"; "data1"; "data2" |];
(
{
port = !field_port;
status = !field_status;
channel = !field_channel;
data1 = !field_data1;
data2 = !field_data2;
}
: midi_event)
)
let midi_event_of_string ?pos s =
read_midi_event (Bi_inbuf.from_string ?pos s)
let event_tag = Bi_io.variant_tag
let write_untagged_event : Bi_outbuf.t -> event -> unit = (
fun ob x ->
match x with
| Track_ends x ->
Bi_outbuf.add_char4 ob '\135' '1' 'U' '\204';
(
write_id
) ob x
| Track_starts x ->
Bi_outbuf.add_char4 ob '\193' '\245' '\232' 'e';
(
write_id
) ob x
| Midi_input x ->
Bi_outbuf.add_char4 ob '\251' 'q' 't' '\012';
(
write_midi_event
) ob x
)
let write_event ob x =
Bi_io.write_tag ob Bi_io.variant_tag;
write_untagged_event ob x
let string_of_event ?(len = 1024) x =
let ob = Bi_outbuf.create len in
write_event ob x;
Bi_outbuf.contents ob
let get_event_reader = (
fun tag ->
if tag <> 23 then Atdgen_runtime.Ob_run.read_error () else
fun ib ->
Bi_io.read_hashtag ib (fun ib h has_arg ->
match h, has_arg with
| 120673740, true -> (Track_ends (
(
read_id
) ib
) : event)
| -1040848795, true -> (Track_starts (
(
read_id
) ib
) : event)
| -76450804, true -> (Midi_input (
(
read_midi_event
) ib
) : event)
| _ -> Atdgen_runtime.Ob_run.unsupported_variant h has_arg
)
)
let read_event = (
fun ib ->
if Bi_io.read_tag ib <> 23 then Atdgen_runtime.Ob_run.read_error_at ib;
Bi_io.read_hashtag ib (fun ib h has_arg ->
match h, has_arg with
| 120673740, true -> (Track_ends (
(
read_id
) ib
) : event)
| -1040848795, true -> (Track_starts (
(
read_id
) ib
) : event)
| -76450804, true -> (Midi_input (
(
read_midi_event
) ib
) : event)
| _ -> Atdgen_runtime.Ob_run.unsupported_variant h has_arg
)
)
let event_of_string ?pos s =
read_event (Bi_inbuf.from_string ?pos s)
let _2_tag = Bi_io.array_tag
let write_untagged__2 = (
Atdgen_runtime.Ob_run.write_untagged_list
event_tag
(
write_untagged_event
)
)
let write__2 ob x =
Bi_io.write_tag ob Bi_io.array_tag;
write_untagged__2 ob x
let string_of__2 ?(len = 1024) x =
let ob = Bi_outbuf.create len in
write__2 ob x;
Bi_outbuf.contents ob
let get__2_reader = (
Atdgen_runtime.Ob_run.get_list_reader (
get_event_reader
)
)
let read__2 = (
Atdgen_runtime.Ob_run.read_list (
get_event_reader
)
)
let _2_of_string ?pos s =
read__2 (Bi_inbuf.from_string ?pos s)
let rec _3_tag = Bi_io.array_tag
and write_untagged__3 ob x = (
Atdgen_runtime.Ob_run.write_untagged_list
action_tag
(
write_untagged_action
)
) ob x
and write__3 ob x =
Bi_io.write_tag ob Bi_io.array_tag;
write_untagged__3 ob x
and string_of__3 ?(len = 1024) x =
let ob = Bi_outbuf.create len in
write__3 ob x;
Bi_outbuf.contents ob
and action_tag = Bi_io.variant_tag
and write_untagged_action : Bi_outbuf.t -> action -> unit = (
fun ob x ->
match x with
| Raw_midi x ->
Bi_outbuf.add_char4 ob '\163' '\175' '\222' '\248';
(
write_midi_event
) ob x
| Track_on x ->
Bi_outbuf.add_char4 ob '\217' 'h' '\r' '\179';
(
fun ob x ->
Bi_io.write_tag ob Bi_io.tuple_tag;
Bi_vint.write_uvint ob 2;
(
let x, _ = x in (
write_id
) ob x
);
(
let _, x = x in (
Bi_io.write_svint
) ob x
);
) ob x
| Track_off x ->
Bi_outbuf.add_char4 ob '\225' '\163' '\232' '[';
(
write_id
) ob x
| Bpm_operation x ->
Bi_outbuf.add_char4 ob '\153' '\246' '\251' 'g';
(
write_bpm_operation
) ob x
| Add_event_handler x ->
Bi_outbuf.add_char4 ob '\223' '4' '5' 'g';
(
write_event_handler
) ob x
| Remove_event_handler x ->
Bi_outbuf.add_char4 ob '\156' 'T' '\227' '\n';
(
write_event_handler
) ob x
| Remove_event_handler_by_event x ->
Bi_outbuf.add_char4 ob '\138' '\150' 'C' '\135';
(
write_event
) ob x
| All_tracks_off -> Bi_outbuf.add_char4 ob '{' '\016' '\145' '\182'
| Stop -> Bi_outbuf.add_char4 ob '7' '5' '\028' '"'
)
and write_action ob x =
Bi_io.write_tag ob Bi_io.variant_tag;
write_untagged_action ob x
and string_of_action ?(len = 1024) x =
let ob = Bi_outbuf.create len in
write_action ob x;
Bi_outbuf.contents ob
and event_handler_tag = Bi_io.record_tag
and write_untagged_event_handler : Bi_outbuf.t -> event_handler -> unit = (
fun ob x ->
Bi_vint.write_uvint ob 3;
Bi_outbuf.add_char4 ob '\200' '\255' 'r' 'K';
(
Bi_io.write_string
) ob x.name;
Bi_outbuf.add_char4 ob '\150' 'j' 'O' '\025';
(
write__2
) ob x.events;
Bi_outbuf.add_char4 ob '\231' '.' '\003' '\253';
(
write__3
) ob x.actions;
)
and write_event_handler ob x =
Bi_io.write_tag ob Bi_io.record_tag;
write_untagged_event_handler ob x
and string_of_event_handler ?(len = 1024) x =
let ob = Bi_outbuf.create len in
write_event_handler ob x;
Bi_outbuf.contents ob
let rec get__3_reader tag = (
Atdgen_runtime.Ob_run.get_list_reader (
get_action_reader
)
) tag
and read__3 ib = (
Atdgen_runtime.Ob_run.read_list (
get_action_reader
)
) ib
and _3_of_string ?pos s =
read__3 (Bi_inbuf.from_string ?pos s)
and get_action_reader = (
fun tag ->
if tag <> 23 then Atdgen_runtime.Ob_run.read_error () else
fun ib ->
Bi_io.read_hashtag ib (fun ib h has_arg ->
match h, has_arg with
| 598728440, true -> (Raw_midi (
(
read_midi_event
) ib
) : action)
| -647492173, true -> (Track_on (
(
fun ib ->
if Bi_io.read_tag ib <> 20 then Atdgen_runtime.Ob_run.read_error_at ib;
let len = Bi_vint.read_uvint ib in
if len < 2 then Atdgen_runtime.Ob_run.missing_tuple_fields len [ 0; 1 ];
let x0 =
(
read_id
) ib
in
let x1 =
(
Atdgen_runtime.Ob_run.read_int
) ib
in
for i = 2 to len - 1 do Bi_io.skip ib done;
(x0, x1)
) ib
) : action)
| -509351845, true -> (Track_off (
(
read_id
) ib
) : action)
| 435616615, true -> (Bpm_operation (
(
read_bpm_operation
) ib
) : action)
| -550226585, true -> (Add_event_handler (
(
read_event_handler
) ib
) : action)
| 475325194, true -> (Remove_event_handler (
(
read_event_handler
) ib
) : action)
| 177619847, true -> (Remove_event_handler_by_event (
(
read_event
) ib
) : action)
| -82800202, false -> (All_tracks_off : action)
| 926227490, false -> (Stop : action)
| _ -> Atdgen_runtime.Ob_run.unsupported_variant h has_arg
)
)
and read_action = (
fun ib ->
if Bi_io.read_tag ib <> 23 then Atdgen_runtime.Ob_run.read_error_at ib;
Bi_io.read_hashtag ib (fun ib h has_arg ->
match h, has_arg with
| 598728440, true -> (Raw_midi (
(
read_midi_event
) ib
) : action)
| -647492173, true -> (Track_on (
(
fun ib ->
if Bi_io.read_tag ib <> 20 then Atdgen_runtime.Ob_run.read_error_at ib;
let len = Bi_vint.read_uvint ib in
if len < 2 then Atdgen_runtime.Ob_run.missing_tuple_fields len [ 0; 1 ];
let x0 =
(
read_id
) ib
in
let x1 =
(
Atdgen_runtime.Ob_run.read_int
) ib
in
for i = 2 to len - 1 do Bi_io.skip ib done;
(x0, x1)
) ib
) : action)
| -509351845, true -> (Track_off (
(
read_id
) ib
) : action)
| 435616615, true -> (Bpm_operation (
(
read_bpm_operation
) ib
) : action)
| -550226585, true -> (Add_event_handler (
(
read_event_handler
) ib
) : action)
| 475325194, true -> (Remove_event_handler (
(
read_event_handler
) ib
) : action)
| 177619847, true -> (Remove_event_handler_by_event (
(
read_event
) ib
) : action)
| -82800202, false -> (All_tracks_off : action)
| 926227490, false -> (Stop : action)
| _ -> Atdgen_runtime.Ob_run.unsupported_variant h has_arg
)
)
and action_of_string ?pos s =
read_action (Bi_inbuf.from_string ?pos s)
and get_event_handler_reader = (
fun tag ->
if tag <> 21 then Atdgen_runtime.Ob_run.read_error () else
fun ib ->
let field_name = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_events = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_actions = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let bits0 = ref 0 in
let len = Bi_vint.read_uvint ib in
for i = 1 to len do
match Bi_io.read_field_hashtag ib with
| -922783157 ->
field_name := (
(
Atdgen_runtime.Ob_run.read_string
) ib
);
bits0 := !bits0 lor 0x1;
| 376065817 ->
field_events := (
(
read__2
) ib
);
bits0 := !bits0 lor 0x2;
| -416414723 ->
field_actions := (
(
read__3
) ib
);
bits0 := !bits0 lor 0x4;
| _ -> Bi_io.skip ib
done;
if !bits0 <> 0x7 then Atdgen_runtime.Ob_run.missing_fields [| !bits0 |] [| "name"; "events"; "actions" |];
(
{
name = !field_name;
events = !field_events;
actions = !field_actions;
}
: event_handler)
)
and read_event_handler = (
fun ib ->
if Bi_io.read_tag ib <> 21 then Atdgen_runtime.Ob_run.read_error_at ib;
let field_name = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_events = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_actions = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let bits0 = ref 0 in
let len = Bi_vint.read_uvint ib in
for i = 1 to len do
match Bi_io.read_field_hashtag ib with
| -922783157 ->
field_name := (
(
Atdgen_runtime.Ob_run.read_string
) ib
);
bits0 := !bits0 lor 0x1;
| 376065817 ->
field_events := (
(
read__2
) ib
);
bits0 := !bits0 lor 0x2;
| -416414723 ->
field_actions := (
(
read__3
) ib
);
bits0 := !bits0 lor 0x4;
| _ -> Bi_io.skip ib
done;
if !bits0 <> 0x7 then Atdgen_runtime.Ob_run.missing_fields [| !bits0 |] [| "name"; "events"; "actions" |];
(
{
name = !field_name;
events = !field_events;
actions = !field_actions;
}
: event_handler)
)
and event_handler_of_string ?pos s =
read_event_handler (Bi_inbuf.from_string ?pos s)
let ticked_action_tag = Bi_io.record_tag
let write_untagged_ticked_action : Bi_outbuf.t -> ticked_action -> unit = (
fun ob x ->
Bi_vint.write_uvint ob 2;
Bi_outbuf.add_char4 ob '\204' '\252' '\195' ']';
(
Bi_io.write_svint
) ob x.tick;
Bi_outbuf.add_char4 ob '\150' 'F' ';' '\182';
(
write_action
) ob x.action;
)
let write_ticked_action ob x =
Bi_io.write_tag ob Bi_io.record_tag;
write_untagged_ticked_action ob x
let string_of_ticked_action ?(len = 1024) x =
let ob = Bi_outbuf.create len in
write_ticked_action ob x;
Bi_outbuf.contents ob
let get_ticked_action_reader = (
fun tag ->
if tag <> 21 then Atdgen_runtime.Ob_run.read_error () else
fun ib ->
let field_tick = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_action = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let bits0 = ref 0 in
let len = Bi_vint.read_uvint ib in
for i = 1 to len do
match Bi_io.read_field_hashtag ib with
| -855850147 ->
field_tick := (
(
Atdgen_runtime.Ob_run.read_int
) ib
);
bits0 := !bits0 lor 0x1;
| 373701558 ->
field_action := (
(
read_action
) ib
);
bits0 := !bits0 lor 0x2;
| _ -> Bi_io.skip ib
done;
if !bits0 <> 0x3 then Atdgen_runtime.Ob_run.missing_fields [| !bits0 |] [| "tick"; "action" |];
(
{
tick = !field_tick;
action = !field_action;
}
: ticked_action)
)
let read_ticked_action = (
fun ib ->
if Bi_io.read_tag ib <> 21 then Atdgen_runtime.Ob_run.read_error_at ib;
let field_tick = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_action = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let bits0 = ref 0 in
let len = Bi_vint.read_uvint ib in
for i = 1 to len do
match Bi_io.read_field_hashtag ib with
| -855850147 ->
field_tick := (
(
Atdgen_runtime.Ob_run.read_int
) ib
);
bits0 := !bits0 lor 0x1;
| 373701558 ->
field_action := (
(
read_action
) ib
);
bits0 := !bits0 lor 0x2;
| _ -> Bi_io.skip ib
done;
if !bits0 <> 0x3 then Atdgen_runtime.Ob_run.missing_fields [| !bits0 |] [| "tick"; "action" |];
(
{
tick = !field_tick;
action = !field_action;
}
: ticked_action)
)
let ticked_action_of_string ?pos s =
read_ticked_action (Bi_inbuf.from_string ?pos s)
let _4_tag = Bi_io.array_tag
let write_untagged__4 = (
Atdgen_runtime.Ob_run.write_untagged_list
ticked_action_tag
(
write_untagged_ticked_action
)
)
let write__4 ob x =
Bi_io.write_tag ob Bi_io.array_tag;
write_untagged__4 ob x
let string_of__4 ?(len = 1024) x =
let ob = Bi_outbuf.create len in
write__4 ob x;
Bi_outbuf.contents ob
let get__4_reader = (
Atdgen_runtime.Ob_run.get_list_reader (
get_ticked_action_reader
)
)
let read__4 = (
Atdgen_runtime.Ob_run.read_list (
get_ticked_action_reader
)
)
let _4_of_string ?pos s =
read__4 (Bi_inbuf.from_string ?pos s)
let track_tag = Bi_io.record_tag
let write_untagged_track : Bi_outbuf.t -> track -> unit = (
fun ob x ->
Bi_vint.write_uvint ob 4;
Bi_outbuf.add_char4 ob '\128' '\000' '[' '\219';
(
write_id
) ob x.id;
Bi_outbuf.add_char4 ob '\150' 'j' 'O' '\025';
(
write__4
) ob x.events;
Bi_outbuf.add_char4 ob '\159' '\007' '\148' '\230';
(
Bi_io.write_svint
) ob x.length;
Bi_outbuf.add_char4 ob '\200' '\255' 'r' 'K';
(
Bi_io.write_string
) ob x.name;
)
let write_track ob x =
Bi_io.write_tag ob Bi_io.record_tag;
write_untagged_track ob x
let string_of_track ?(len = 1024) x =
let ob = Bi_outbuf.create len in
write_track ob x;
Bi_outbuf.contents ob
let get_track_reader = (
fun tag ->
if tag <> 21 then Atdgen_runtime.Ob_run.read_error () else
fun ib ->
let field_id = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_events = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_length = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_name = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let bits0 = ref 0 in
let len = Bi_vint.read_uvint ib in
for i = 1 to len do
match Bi_io.read_field_hashtag ib with
| 23515 ->
field_id := (
(
read_id
) ib
);
bits0 := !bits0 lor 0x1;
| 376065817 ->
field_events := (
(
read__4
) ib
);
bits0 := !bits0 lor 0x2;
| 520590566 ->
field_length := (
(
Atdgen_runtime.Ob_run.read_int
) ib
);
bits0 := !bits0 lor 0x4;
| -922783157 ->
field_name := (
(
Atdgen_runtime.Ob_run.read_string
) ib
);
bits0 := !bits0 lor 0x8;
| _ -> Bi_io.skip ib
done;
if !bits0 <> 0xf then Atdgen_runtime.Ob_run.missing_fields [| !bits0 |] [| "id"; "events"; "length"; "name" |];
(
{
id = !field_id;
events = !field_events;
length = !field_length;
name = !field_name;
}
: track)
)
let read_track = (
fun ib ->
if Bi_io.read_tag ib <> 21 then Atdgen_runtime.Ob_run.read_error_at ib;
let field_id = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_events = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_length = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_name = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let bits0 = ref 0 in
let len = Bi_vint.read_uvint ib in
for i = 1 to len do
match Bi_io.read_field_hashtag ib with
| 23515 ->
field_id := (
(
read_id
) ib
);
bits0 := !bits0 lor 0x1;
| 376065817 ->
field_events := (
(
read__4
) ib
);
bits0 := !bits0 lor 0x2;
| 520590566 ->
field_length := (
(
Atdgen_runtime.Ob_run.read_int
) ib
);
bits0 := !bits0 lor 0x4;
| -922783157 ->
field_name := (
(
Atdgen_runtime.Ob_run.read_string
) ib
);
bits0 := !bits0 lor 0x8;
| _ -> Bi_io.skip ib
done;
if !bits0 <> 0xf then Atdgen_runtime.Ob_run.missing_fields [| !bits0 |] [| "id"; "events"; "length"; "name" |];
(
{
id = !field_id;
events = !field_events;
length = !field_length;
name = !field_name;
}
: track)
)
let track_of_string ?pos s =
read_track (Bi_inbuf.from_string ?pos s)
let _7_tag = Bi_io.array_tag
let write_untagged__7 = (
Atdgen_runtime.Ob_run.write_untagged_list
track_tag
(
write_untagged_track
)
)
let write__7 ob x =
Bi_io.write_tag ob Bi_io.array_tag;
write_untagged__7 ob x
let string_of__7 ?(len = 1024) x =
let ob = Bi_outbuf.create len in
write__7 ob x;
Bi_outbuf.contents ob
let get__7_reader = (
Atdgen_runtime.Ob_run.get_list_reader (
get_track_reader
)
)
let read__7 = (
Atdgen_runtime.Ob_run.read_list (
get_track_reader
)
)
let _7_of_string ?pos s =
read__7 (Bi_inbuf.from_string ?pos s)
let _6_tag = Bi_io.array_tag
let write_untagged__6 = (
Atdgen_runtime.Ob_run.write_untagged_list
event_handler_tag
(
write_untagged_event_handler
)
)
let write__6 ob x =
Bi_io.write_tag ob Bi_io.array_tag;
write_untagged__6 ob x
let string_of__6 ?(len = 1024) x =
let ob = Bi_outbuf.create len in
write__6 ob x;
Bi_outbuf.contents ob
let get__6_reader = (
Atdgen_runtime.Ob_run.get_list_reader (
get_event_handler_reader
)
)
let read__6 = (
Atdgen_runtime.Ob_run.read_list (
get_event_handler_reader
)
)
let _6_of_string ?pos s =
read__6 (Bi_inbuf.from_string ?pos s)
let _5_tag = Bi_io.array_tag
let write_untagged__5 = (
Atdgen_runtime.Ob_run.write_untagged_list
id_tag
(
write_untagged_id
)
)
let write__5 ob x =
Bi_io.write_tag ob Bi_io.array_tag;
write_untagged__5 ob x
let string_of__5 ?(len = 1024) x =
let ob = Bi_outbuf.create len in
write__5 ob x;
Bi_outbuf.contents ob
let get__5_reader = (
Atdgen_runtime.Ob_run.get_list_reader (
get_id_reader
)
)
let read__5 = (
Atdgen_runtime.Ob_run.read_list (
get_id_reader
)
)
let _5_of_string ?pos s =
read__5 (Bi_inbuf.from_string ?pos s)
let scene_tag = Bi_io.record_tag
let write_untagged_scene : Bi_outbuf.t -> scene -> unit = (
fun ob x ->
Bi_vint.write_uvint ob 5;
Bi_outbuf.add_char4 ob '\150' 'F' 'A' '\198';
(
write__5
) ob x.active;
Bi_outbuf.add_char4 ob '\213' '$' '!' 'i';
(
write__6
) ob x.handlers;
Bi_outbuf.add_char4 ob '\128' 'J' '\190' '\223';
(
Bi_io.write_svint
) ob x.bpm;
Bi_outbuf.add_char4 ob '\202' ']' 'D' '\221';
(
Bi_io.write_svint
) ob x.ppqn;
Bi_outbuf.add_char4 ob '\197' '}' '+' '\136';
(
write__7
) ob x.tracks;
)
let write_scene ob x =
Bi_io.write_tag ob Bi_io.record_tag;
write_untagged_scene ob x
let string_of_scene ?(len = 1024) x =
let ob = Bi_outbuf.create len in
write_scene ob x;
Bi_outbuf.contents ob
let get_scene_reader = (
fun tag ->
if tag <> 21 then Atdgen_runtime.Ob_run.read_error () else
fun ib ->
let field_active = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_handlers = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_bpm = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_ppqn = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_tracks = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let bits0 = ref 0 in
let len = Bi_vint.read_uvint ib in
for i = 1 to len do
match Bi_io.read_field_hashtag ib with
| 373703110 ->
field_active := (
(
read__5
) ib
);
bits0 := !bits0 lor 0x1;
| -719052439 ->
field_handlers := (
(
read__6
) ib
);
bits0 := !bits0 lor 0x2;
| 4898527 ->
field_bpm := (
(
Atdgen_runtime.Ob_run.read_int
) ib
);
bits0 := !bits0 lor 0x4;
| -899857187 ->
field_ppqn := (
(
Atdgen_runtime.Ob_run.read_int
) ib
);
bits0 := !bits0 lor 0x8;
| -981652600 ->
field_tracks := (
(
read__7
) ib
);
bits0 := !bits0 lor 0x10;
| _ -> Bi_io.skip ib
done;
if !bits0 <> 0x1f then Atdgen_runtime.Ob_run.missing_fields [| !bits0 |] [| "active"; "handlers"; "bpm"; "ppqn"; "tracks" |];
(
{
active = !field_active;
handlers = !field_handlers;
bpm = !field_bpm;
ppqn = !field_ppqn;
tracks = !field_tracks;
}
: scene)
)
let read_scene = (
fun ib ->
if Bi_io.read_tag ib <> 21 then Atdgen_runtime.Ob_run.read_error_at ib;
let field_active = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_handlers = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_bpm = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_ppqn = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_tracks = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let bits0 = ref 0 in
let len = Bi_vint.read_uvint ib in
for i = 1 to len do
match Bi_io.read_field_hashtag ib with
| 373703110 ->
field_active := (
(
read__5
) ib
);
bits0 := !bits0 lor 0x1;
| -719052439 ->
field_handlers := (
(
read__6
) ib
);
bits0 := !bits0 lor 0x2;
| 4898527 ->
field_bpm := (
(
Atdgen_runtime.Ob_run.read_int
) ib
);
bits0 := !bits0 lor 0x4;
| -899857187 ->
field_ppqn := (
(
Atdgen_runtime.Ob_run.read_int
) ib
);
bits0 := !bits0 lor 0x8;
| -981652600 ->
field_tracks := (
(
read__7
) ib
);
bits0 := !bits0 lor 0x10;
| _ -> Bi_io.skip ib
done;
if !bits0 <> 0x1f then Atdgen_runtime.Ob_run.missing_fields [| !bits0 |] [| "active"; "handlers"; "bpm"; "ppqn"; "tracks" |];
(
{
active = !field_active;
handlers = !field_handlers;
bpm = !field_bpm;
ppqn = !field_ppqn;
tracks = !field_tracks;
}
: scene)
)
let scene_of_string ?pos s =
read_scene (Bi_inbuf.from_string ?pos s)