Skip to content

Instantly share code, notes, and snippets.

@cleverfox
Last active July 22, 2018 15:10
Show Gist options
  • Save cleverfox/33d99ee0443d59603424 to your computer and use it in GitHub Desktop.
Save cleverfox/33d99ee0443d59603424 to your computer and use it in GitHub Desktop.
Notes pitch freq. calclulator
my @nn=("A ","Bb","B ","C ","C#", "D ","Eb","E ","F ","F#","G ","G#");
for(-48..39){
printf("%s %f\n",note($_),440*2**($_/12));
};
sub note {
my $n=shift;
return sprintf("%s%2d",$nn[($n%12)],int(($n+(12*4)+9)/12)-3);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment