#!/local/bin/perl
#OGRE (online guitare)
#Aldy Hernandez
#aldy@andrews.edu
#nov 1995
#this code is pathetic, but it works for me.
#it was just a quick hack for myself. i had no idea so many would use it.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
@scale_modes = ('Major', 'Minor', 'Ionian', 'Aeolian', 'Dorian',
'Phrygian', 'Lydian', 'Mixolydian', 'Locrian',
'Harmonic_Minor', 'Harmonic_Major',
'Neapolitan_Major', 'Neapolitan_Minor', 'Enigmatic',
'Enigmatic_Minor', 'Hungarian_Major',
'Hungarian_Minor', 'Melodic', 'CompositeII',
'Persian', 'Ionian_b5', 'Locrian_7',
'Pentatonic_Major', 'Pentatonic_Minor', 'Kumoi',
'Hirojoshi', 'Blues', 'Whole', 'Augmented',
'Dominant_Sus', 'Pelog', 'Bebop_Locrian',
'Bebop_Dominant', 'Bebop_Dorian', 'Bebop_Major',
'Diminished', 'Spanish', 'Chromatic');
print "Content-type: text/html\n
OGRE
OGRE (Online Guitare)
\n";
if ($chord = @ARGV[0]) {
if ($chord =~ /^SCALE/) { # do the scale thing
$chord =~ s/^SCALE,//;
$_ = ;
/=(.+)$/;
$mode = $1;
print "$mode scale for $chord
\n";
open (X, "(echo scale $chord $mode; echo quit) | /homes/csu/1991/aldy/guitare|") || &die2 ("no guitare?");
print "\n";
while () {
if (/^command/) {
$on = 1;
next;
}
next unless $on;
last if /^Bye/;
if (/\*\*\* ERROR/) {
print "Error Getting Scale!
\n";
last;
}
s/^\s+scale /scale /;
print;
}
close (X);
print "
\n";
&trailer;
exit;
}
$single_note = " (see below for scale options)" if $chord =~ /^[A-G][\#b]?$/;
print "
$chord $single_note
The roman numerals indicate the starting fret.
";
&get_chord;
if ($single_note) { # only give scale option if single note
$chord =~ s/\#/%23/; # put that # back!
print "
\n";
print "
\n";
}
} else {
# &update_counter; #---arghhh this counter has a bug somewhere
&announcements;
print "
Examples:
A#m7
D#
C/G
";
}
print "\n";
&trailer;
sub trailer {
print "
Notes:
OGRE calls GUITARE V5.0 by Pascal Obry.
Visit InterChart: a
guitar charting program in Java
Visit my homepage.
Send me a note if you like it.
\n";
}
#sub get_chord {
# open (X, "/homes/csu/1991/aldy/c $chord|") || &die2 ("no c?");
# while () {
# s/ F /F#/ if $chord eq "F#dim"; # little bug in guitare
# print;
# }
# close (X);
#}
sub get_chord {
$temp="/tmp/x.$$";
open (X, "|/homes/csu/1991/aldy/guitare>$temp");
# print X "tune @ARGV[1]\n" if @ARGV[1];
print X "chord $chord\n";
print X "help nothing\n"; # get an error message on purpose (as a marker)
print X "position\n\n\n\n\n\n\n";
print X "quit\n";
close(X);
open (X, "$temp") || die "Can't open file";
while () {
++$x if /ANAL/;
next unless $x > 1;
while () {
next if /^Press/ || /^mode/;
last if /command/ || /^Bye/;
s/ F /F#/ if $chord eq "F#dim"; # little bug in guitare
print;
}
}
unlink("$temp");
}
sub update_counter {
#update counter
open (X, ".ogre");
$c = ;
close (X);
$c += 1 unless ($ENV{'REMOTE_HOST'} =~ /mh219a/ ||
$ENV{'REMOTE_HOST'} =~ /sauron/);
#write counter to temporary file (because sometimes it fails)
open (X, ">.ogre.tmp");
print X "$c\n";
close (X);
#verify that the write actually worked
open (X, ".ogre.tmp");
$c_new = ;
close (X);
if ($c_new eq "$c\n") {
# everything went fine, let's really write
system("cp .ogre.tmp .ogre");
}
print "You are visitor #$c
\n";
#update who file
open (X, ">>.ogre-who");
if ($ENV{'REMOTE_HOST'}) {
print X $ENV{'REMOTE_HOST'} . "\n" unless $ENV{'REMOTE_HOST'} =~ /mh219a/;
} else {
print X $ENV{'REMOTE_ADDR'} . "\n";
}
close (X);
}
sub die2 {
($x) = @_;
print "$x\n";
exit;
}
sub announcements {
# print "
#If you enter a single note (i.e. A, B#, Cb), Ogre will list the
#various scales for the selected note (Pentatonic, Ionian, etc) in
#addition to the chord.\n";
# print "Try it out!!\n";
}