#!/usr/bin/perl -w
#
# author: Kai Lauterbach (klaute at gmail dot com)
# date: 01/2012
# license: GPL v3
#

use Time::HiRes qw(usleep nanosleep);
my @list = <STDIN>;
my $i = 0;

foreach my $line (@list)
{
    chomp $line;
    if ($line ne "")
    {
        my $frame = hex(substr($line,2,8));
        print "Adding ". $line. " with ". ($frame >> 27). " delay\n";
        my $cframe = $frame & 0x07ffffff;
        #printf("0x%08x\n", $cframe);
        system("../client/clcc --save --pos $i --delay ". ($frame >> 27)." --frame $cframe");
        usleep(250000);
        $i++;
    }
}
