Perl, 133 (129) chars
Perl, 167 160 156 147 142 133 D’oh! 147 144 137 134 133 chars
$_=shift;die grep{5>$n?y/*/#/:y/#*/ |/;$n++-8||y/ /_/} @Q=(substr(("*# #".("*# #*# | #")x2)x9, 4*/#/+(7&ord)*5,1+/#/+5*pop).$/)x9
Here’s a 129 char solution, borrowing several ideas from molf’s Ruby solution:
($_,$c)=@ARGV;$j=($k=/#/)+ord; for$n(0..8){print$/,substr+(join'',map{8-$n?5>$n&&$_%7%4?"### " :" | ":"_|___"}$j..$j+$c),!$k,-3}
and with help from the Acme::AsciiArtinator:
sub init_piano{$S=$";$H='#';
( $
T ,$P,$U)=qw(
T |
_ |
/ )
; $
d =$T.$H.$S.$S;$t =
$ d . $H
. $ d . $
S .$P.$S.$S.$S.$H;$ t= $
d.$H.$t.$t;};$_=shift;-/-/;&init_piano();$Z=/#/;-/| |
| | |
| YAMAHA | /
;die grep{4>$n++?y/T/#/:y/#T/ |/;$n-8||y/ /_/;}@q=(m{
// // /// // /// // /// // /// // /// // /// // /// /
// // /// // /// // /// // /// // /// // /// // /// /
} .
substr(${t}x(9),4*${Z}+(7&ord)*5,1+$Z+5*pop).$/)x(8)
; ' \ /
| | | |
/_\ /';