aboutsummaryrefslogtreecommitdiff
path: root/scripts/showstoppedmtc
blob: e1e42fec7187494c45113f0a2bc5453c8ac66d45 (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
#!/usr/bin/perl -w --
$|=1;  # disable output buffering
use strict;
open (MTCSOURCE, "amidi --dump --port=hw:1,0,0|");
my $hour=0;
my $min=0;
my $sec=0;
my $frame=0;
my $qframe=-1;
while (<MTCSOURCE>) {
	chomp($_);
	if (/F0 7F (.*) 06 44 06 01 (.*) F7/) {
		print $_;
		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\r\n";
		}
		else
		{
		print "$min minutes $sec seconds $roundedframe\r\n";
		}
	}
}
close (MTCSOURCE);