1 infile
, err
= io
.open(arg
[1], "r");
3 error("Can't open input file: " .. err
);
6 outfile
, err
= io
.open(arg
[2], "w");
8 error("Can't open output file: " .. err
);
15 emit_transition
= function(time
, tohigh
)
16 x
= time
- last_trans_time
;
18 while x
>= 4294967295 do
19 print("Skipping time ahead");
20 s
= s
.. string.char(255, 255, 255, 255);
22 last_trans_time
= last_trans_time
+ 4294967295;
34 if is_high
~= tohigh
then
35 s
= s
.. string.char(x1
, x2
, x3
, x4
);
37 s
= s
.. string.char(255, 255, 255, 255);
39 s
= s
.. string.char(0, 0, 0, 0);
42 s
= s
.. string.char(0, 0, 0, 0, 255, 255, 255, 255);
44 s
= s
.. string.char(0, 0, 0, 0, 0, 0, 0, 0);
46 last_trans_time
= time
;
52 emit_transition(0, false);
59 scaled
= math
.floor(50 * string.byte(inb
) / 255 + 0.5);
60 if scaled
== 0 and is_high
then
61 emit_transition(50000 * samplenum
, false);
62 elseif scaled
== 0 then
67 emit_transition(50000 * samplenum
, true);
70 emit_transition(50000 * samplenum
+ 1000 * scaled
, false);
74 samplenum
= samplenum
+ 1;