#!/usr/bin/perl # Attempt to model the sound of a plane passing near (15 km) my house # Copyright : http://www.fsf.org/copyleft/gpl.html # Author : Dan Jacobson -- http://jidanni.org/comm/air/ # Created On : Dec 2013 # Last Modified On: Mon Dec 9 07:31:26 2013 # Update Count : 32 die "what a mess"; use strict; use warnings FATAL => 'all'; my $v = 309; #m/s, ~600 knots my $d = 15000; #meters direct to where the plane is in the sky at closest point my $t1 = 200; #seconds range printf "%4s %5s\n", "SEC", "DB"; for ( my ( $f, $t ) = ( pop, -$t1 ) ; $t <= $t1 ; $t += $t1 / 15 ) { my $k = 10 * log10( $d**2 / ( $d**2 + ( $v * $t )**2 ) ) + $f * $t * $v / sqrt( $d**2 + ( $v * $t )**2 ) ; printf "%4d %5.1f %s\n", $t, $k, "*" x (( $f + $k )*7) if $k >= -$f; # my $k = # 10 * log10( $f+($t*$v*$d**2 / ( $d**2 + ( $v * $t )**2 )**(3/2))); printf "%4d %5.1f %s\n", $t, $k, "*" x (( $f + $k )*7) if $k >= -$f; } sub log10 { return log(shift) / log(10); }