I recently decided to try my hand at a musical instrument. The bass guitar seemed like a good fit for me so I picked it up started a with a few lessons. I quickly realized that in order to have any success with it, I needed to memorize the fret-board. Given my affinity for PowerShell, I decided to blend the two. Following is a script that I threw in my profile to prompt me upon start-up for a few notes.
function Get-BassNote {
param($Count=2)
$BassNotes = @{
"Fret0" = @{
"String1" = {E}
"String2" = {A}
"String3" = {D}
"String4" = {G} }
"Fret1" = @{
"String1" = {F}
"String2" = {A#}
"String3" = {D#}
"String4" = {G#} }
"Fret2" = @{
"String1" = {F#}
"String2" = {B}
"String3" = {E}
"String4" = {A} }
"Fret3" = @{
"String1" = {G}
"String2" = {C}
"String3" = {F}
"String4" = {A#} }
"Fret4" = @{
"String1" = {G#}
"String2" = {C#}
"String3" = {F#}
"String4" = {B} }
"Fret5" = @{
"String1" = {A}
"String2" = {D}
"String3" = {G}
"String4" = {C} }
"Fret6" = @{
"String1" = {A#}
"String2" = {D#}
"String3" = {G#}
"String4" = {C#} }
"Fret7" = @{
"String1" = {B}
"String2" = {E}
"String3" = {A}
"String4" = {D} }
"Fret8" = @{
"String1" = {C}
"String2" = {F}
"String3" = {A#}
"String4" = {D#} }
"Fret9" = @{
"String1" = {C#}
"String2" = {F#}
"String3" = {B}
"String4" = {E} }
"Fret10" = @{
"String1" = {D}
"String2" = {G}
"String3" = {C}
"String4" = {F} }
"Fret11" = @{
"String1" = {D#}
"String2" = {G#}
"String3" = {C#}
"String4" = {F#} }
"Fret12" = @{
"String1" = {E}
"String2" = {A}
"String3" = {D}
"String4" = {G} }
}
for ($i=1; $i-le$Count; $i++){
$fretNumber = Get-Random -Minimum 0 -Maximum 12
$stringNumber = Get-Random -Minimum 1 -Maximum 4
[string]$Answer = $BassNotes."Fret$($FretNumber)"."String$($StringNumber)"
$prompt = "What is the note for string $($stringNumber), fret $($fretNumber)"
do { $Response = Read-Host $Prompt }
until ($Answer -eq $Response)
}
}
Rock on!