#!/usr/bin/perl sub menu { print "\n\t*** Use [Ctrl] + [C] to end the note and return to the ptune menu. ***\n\n"; print "\tPlease select a note to play:\n\n"; print "\t\t[6] E - 6th string\n"; print "\t\t[5] A - 5th string\n"; print "\t\t[4] D - 4th string\n"; print "\t\t[3] G - 3rd string\n"; print "\t\t[2] B - 2nd string\n"; print "\t\t[1] e - 1st string\n"; # print "\t\t[A] All notes in sequence\n"; print "\t\t[H] Help\n"; print "\t\t[Q] Quit\n\n"; print "String: "; chomp($note = ); if ($note =~ m/6/) { $freq = 164.81; &single; } elsif ($note =~ m/5/) { $freq = 220; &single; } elsif ($note =~ m/4/) { $freq = 293.67; &single;; } elsif ($note =~ m/3/) { $freq = 392; &single; } elsif ($note =~ m/2/) { $freq = 493.88; &single; } elsif ($note =~ m/1/) { $freq = 659.26; &single; # } elsif ($note =~ m/a/i) { # &all; } elsif ($note =~ m/h/i) { &help; } elsif ($note =~ m/q/i) { &quit; } else { print "\n\t*** Please select an bracketed option from the list. ***\n"; sleep(1); &menu; } } sub single { system("play -n synth sine $freq"); #if ($note = 6) { #$freq = 164.81; #system("play -n synth sine $freq"); #} elsif ($note = 5) { #$freq = 220; #system("play -n synth sine $freq"); #} elsif ($note = 4) { #$freq = 293.67; #system("play -n synth sine $freq"); #} elsif ($note = 3) { #$freq = 392; #system("play -n synth sine $freq"); #} elsif ($note = 2) { #$freq = 493.88; #system("play -n synth sine $freq"); #} elsif ($note = 1) { #$freq = 659.26; #system("play -n synth sine $freq"); #} &menu; } #sub all { # system ("for freqlist in {164.81,220,293.67,392,493.88,659.26}; do play -n synth sine $freqlist; done"); #} sub help { print "\n\t*** Use [Ctrl] + [C] to end the note and return to the ptune menu. ***\n\n"; print "\tFrequencies are defined as follows:\n\n"; print "\t\t6th string E = 164.81\n"; print "\t\t5th string A = 220\n"; print "\t\t4th string D = 293.67\n"; print "\t\t3rd string G = 392\n"; print "\t\t2nd string B = 493.88\n"; print "\t\t1st string e = 659.26\n\n"; print "\tptune was created by Manata\n\n"; print "[R]eturn to main menu: "; chomp($return = ); if ($return =~ m/r/i) { &menu; } else { &help; } } sub quit { print "\n\tThank you for using ptune!\n\n"; exit; } &menu;