Fret Not! guitar fretboard tutor program

I got a nice acoustic guitar for Christmas.  I haven’t played in years, really since my eldest son was born 17 years ago.  At the time I was really into Mississippi River Delta Blues, and finger-style playing in alternate tunings.  I mostly read tablature.  I knew some pentatonic shapes to play up and down the fretboard, but not the actual note names I was playing.  This time around,  I want to learn how to read notes on a staff, and that means knowing the fretboard unconsciously.  To help,  I wrote a very simple perl script that I call ‘Fret Not!’

Fret Not! guitar fretboard tutoring perl script
Fret Not! guitar fretboard tutoring perl script teaches notes on the fretboard

It uses the ascii art program figlet for some simple command line graphics.  It basically is an endless loop asking you to name the note on a particular string at a particular fret.  It really is helping me to memorize the note positions on a fretboard.

 
     1	#!/usr/bin/perl -w
     2	#use Data::Dumper;
     3	use strict;
     4	$| = 1;	#flush output
       
     5	#display heading
     6	print "#####################################################################################\n";
     7	system('figlet "FretNot!" -c');
     8	print "#####################################################################################\n";
       
     9	#guitar string arrays
    10	my @e1 = ('E','F','F#','G','G#','A','A#','B','C','C#','D','D#','E');
    11	my @a = ('A','A#','B','C','C#','D','D#','E','F','F#','G','G#','A');
    12	my @d = ('D','D#','E','F','F#','G','G#','A','A#','B','C','C#','D');
    13	my @g = ('G','G#','A','A#','B','C','C#','D','D#','E','F','F#','G');
    14	my @b = ('B','C','C#','D','D#','E','F','F#','G','G#','A','A#','B');
    15	my @e2 = ('E','F','F#','G','G#','A','A#','B','C','C#','D','D#','E');
       
    16	#hashref of all strings
    17	my $stringref = [\@e1, \@a, \@d, \@g, \@b, \@e2];
       
    18	#testing; worked
    19	#print Dumper($stringref);
       
    20	for(;;){
    21		my $str_num = 1 + int rand(6);
    22		my $fret_num = 1 + int rand(12);
    23		print "What is the note on string $str_num at fret $fret_num ?:";
    24		chomp(my $answer = );
    25		$str_num-=1;
    26		#$fret_num-=1;
    27		my $note = ${$stringref}[$str_num][$fret_num]; 
    28		print "note: $note\tans: $answer\n";
       
    29		if($note eq $answer){
    30			system('figlet "correct!"');
    31		}#end if
    32		else{
    33			system('figlet "LOSER!"');
    34		}#end else
    35	}#end for

As you can see, I created a data structure in the form of a reference of array references.  It randomly chooses a string at a particular fret.  A mere 35 lines of perl, but very effective for it’s purpose.  To use this,  you will have to install figlet on your linux box.

Leave a Reply

Your email address will not be published. Required fields are marked *