git @ Cat's Eye Technologies Dipple / master perl / noise
master

Tree @master (Download .tar.gz)

noise @masterraw · history · blame

#!/usr/bin/env perl

# noise[.pl] v2001.0622 Chris Pressey
# Fairly realistic line noise simulator.
#
# SPDX-FileCopyrightText: Chris Pressey, the original author of this work, has dedicated it to the public domain.
# For more information, please refer to <https://unlicense.org/>
# SPDX-License-Identifier: Unlicense

# Usage: [perl] noise[.pl] [average-long-delay-in-seconds] &
#
# `noise` is a tiny utility whose purpose is to simulate line noise -- those
# random bursts of static that occur when communicating with a non-error-
# correcting modem over an unreliable phone line.  Start it up in the
# background and keep working at your shell prompt -- or, keep *trying* to!

# As of May 21 2012, this source is hereby placed in the public domain.

### BEGIN noise[.pl] ###

$bk = 30;
if(defined($arg = shift @ARGV))
{
  $bk = 0+$arg;
}

### MAIN ###

$| = 1;
while(1)
{
  $rv = int(rand(1) * ($bk/3) - $bk/3);
  sleep $bk + $rv;
  $cy = int(rand(1) * 8) + 1;
  for($i=1;$i <= $cy; $i++)
  {
    $cc = int(rand(1) * 12) + 1;
    for($j=1; $j <= $cc; $j++)
    {
      print chr(int(rand(1) * 256));
    }
    $sp = int(rand(1) * 3) + 1;
    sleep $sp;
  }
}

### END of noise[.pl] ###