#!/usr/bin/perl -w

$env = 0.0;

$hist = ();

while (<>) {
	/(.*)\t(.*)/;
	$sig = abs($2);
	if ($sig > $env) {
		$env = $env * 0.2 + $sig * 0.8;
	} else {
		$env = $env * 0.9 + $sig * 0.1;
	}
	$hist[$1] = $env;
	$out = ($hist[$1-3] + $hist[$1-2] + $hist[$1-1] + $hist[$1]) * 0.25;
	print "$1\t$out\n";
}
