...
 
Commits (4)
......@@ -45,6 +45,10 @@ module Midi_event = struct
}
let make ~ticks ~status ~channel ~data_1 ~data_2 =
{ticks; status; channel; data_1; data_2}
let pp fmt {ticks; status; channel; data_1; data_2} =
let open Format in
fprintf fmt "{T: %d;@ S: %x;@ C: %d;@ D1: %d;@ D2: %d}"
ticks status channel data_1 data_2
end
module Meta_event = struct
......@@ -54,6 +58,13 @@ module Meta_event = struct
service_data : int array;
}
let make ~ticks ~service_id ~service_data = {ticks; service_id; service_data}
let pp fmt {ticks; service_id; service_data} =
let open Format in
fprintf fmt "{T: %d;@ Id: %x;@ Data: "
ticks service_id;
ArrayLabels.iter service_data ~f:(fun d -> fprintf fmt "%x;" d);
fprintf fmt "}"
end
module Sys_event = struct
......@@ -70,6 +81,15 @@ module Event = struct
let empty = Empty
(* let max_midi_val = ref 127 *)
let pp fmt =
let open Format in
function
| Empty -> fprintf fmt "(Empty)"
| Midi e -> fprintf fmt "@[([email protected] %a)@]" Midi_event.pp e
| Meta e -> fprintf fmt "@[([email protected] %a)@]" Meta_event.pp e
| Sys _ -> fprintf fmt "(System NOT-IMPLEMENTED)"
end
module Track = struct
......
......@@ -273,7 +273,7 @@ let parse_smf file = (
(* Read all the tracks: *)
ret.Midi.File.tracks <- Midi.File.make_tracks ret.Midi.File.track_number ;
pr "%d tracks.\n" ret.Midi.File.track_number ;
(* pr "%d tracks.\n" ret.Midi.File.track_number ; *)
for cur_track = 0 to ret.Midi.File.track_number - 1 do
read_track ret.Midi.File.tracks.(cur_track) fin;
done;
......@@ -323,7 +323,8 @@ let write_track track fout =
);
let len = I.of_int (Buffer.length buffer) in
if (len <> track.Midi.Track.length) then (
pr "Grrr... must be a problem: %ld <> %ld\n" len track.Midi.Track.length;
pr "WARNING: Ignoring wrong track.Midi.Track.length: %ld <> %ld\n"
track.Midi.Track.length len;
);
write_long fout track.Midi.Track.id ;
write_long fout len ;
......