aboutsummaryrefslogtreecommitdiff
path: root/scripts/mtcspeak
blob: 6ea6c27246798f72e3e7fca03e9da66014d8e9cd (plain)
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
#!/usr/bin/perl -w --
$|=1;  # disable output buffering
use strict;
open (MTCSOURCE, "amidi --dump --port=hw:1,0,0|");
open (STDOUT, "|espeak");
my $hour=0;
my $min=0;
my $sec=0;
my $frame=0;
my $qframe=-1;
my $roundedframe;
while (<MTCSOURCE>) {
	chomp($_);
	if (/F0 7F (.*) 06 44 06 01 (.*) F7/) {
		my @tc=split(' ',substr($_,21,17));
		$hour=hex("0x".$tc[0]) & 31;
		$min=hex("0x".$tc[1]);
		$sec=hex("0x".$tc[2]);
		$frame=hex("0x".$tc[3]);
		$qframe=hex("0x".$tc[4]);
		$roundedframe=$frame;
		if ($qframe>=50) {
			$roundedframe++;
		}
		if ($hour>0) {
		print "$hour hours $min minutes $sec seconds $roundedframe frames\r\n";
		}
		else
		{
		print "$min minutes $sec seconds $roundedframe frames\r\n";
		}
	}
}
close (MTCSOURCE);