This is an intro to the ascii to tab script: How to run it: ./process.perl -in -out Input file format: 1) The input should have a tuning statement. This statement looks as like: tuning: E B G D A E. The string numbers increase from left to right. 2) The format for specifying is: string-fret. .e.g 1-2 means that string 1 is pressed at 2 fret. 3) 1-2 2-3 means 'First string second fret' 'second string third fret' at the same time. To get them one after another you should specify 1-2 2-3 i.e newline is significant. This way you can create ringing notes by putting more and more lines in the middle. This can help you give some relative timing. Mail me if you find this useful. I will also try to make the script more useful and incorporate more features in it. Your feedback will be welcome. I might later even write a c program. A sample input file: - -------- Cut here ------------ tuning: e b g d a e 1-1 2-1 3-1 4-1 5-1 6-0 1-2 3-4 1-13 4-17 1-4 1-2 - ---------- Cut here Output looks like: - ------------Cut Here ------------ e-1--2--13--4--------2- b-1-------------------- g-1--4----------------- d-1-----17------------- a-1-------------------- e-0-------------------- - ---------- Cut here ---------- Any problems, requests etc. mail to: bhutani@lsil.com ------------------------------------------------------------------------- Sandeep Bhutani Third Party Interface & CAD +-----+ LSI Logic Corporation phone : (408) 433-8744 LSI|LOGIC| 1501 McCarthy Blvd. FAX : (408) 433-4156 | | M/S E-192 email : bhutani +-----+ Milpitas, Ca. 95035 internet : bhutani@lsil.com -------------------------------------------------------------------------- ---------------- Cut Here for Perl Script ----------------------------- #!/usr/local/bin/perl # The above line has to be modified to point to the correct location of PERL # at your site. # I have already recvd. some enhancement ideas and I will work # on them from here on. # Here I have set the maximum number of columns allowed in the output. You # can set it to whatever number you fancy. $MAXCOL = 72; #### This is where I print out the usage message if ( @ARGV < 4 ) { print "Usage:\n"; print "./process.perl -in -out \n"; print "\n"; die ""; } ## This is where the input parameters are processed. while ( @ARGV ) { if ( $ARGV[0] eq "-in" ) { shift(@ARGV); $infile = $ARGV[0]; shift(@ARGV); } elsif ( $ARGV[0] eq "-out" ) { shift (@ARGV); $outfile = $ARGV[0]; shift(@ARGV); } else { print " Bad argument $ARGV[0]\n"; die; } } # Here I open the input file for reading &die_open(INFILE, $infile); # Here I open the output file for writing to. $new_outfile = ">".$outfile; &die_open(OUTFILE, $new_outfile); ## This is here the magic of PERL comes in. I can read the entire input file ## by just this one command. @entire_in_file = ; ## I search through the entire file looking for 'tuning' keyword $file_index = 0; while ( ( $file_index < @entire_in_file ) && !($entire_in_file[$file_index] =~ /tuning/) ) { $file_index++; } ## Here i set the tuning &get_tuning(); # Initialise string names # Here I use the tuning given by the used to write out the string names. $index = 1; while ( $index < 7 ) { $defined_string[$index] = 999; $string[$index] = $tune[$index]; $index++; } $file_index = 0; $col_index = 0; # Walk through the entire file. Skip the line that contains 'tuning' # keyword while ( $file_index < @entire_in_file ) { if ( ($set_tune_index == 1) && ($file_index == $tune_index) ) { $file_index++; next ; } # Right now this part is not supported. I am not letting the user type in # anything. This is meant to be a comment line which goes as is into the # output. Right now I am using * at the begining of the line to be the # start of the comment. if ( $entire_in_file[$file_index] =~ /^\*/ ) { print OUTFILE $entire_in_file[$file_index] ; $file_index++; } ## This is where the real work actually takes place. &readandprocess(); } ## Print here if there are some leftovers. Else the printing is done ## entirely in the readandprocess &print_strings(); ### Be neat and clen up upon exit close ( OUTFILE ); close ( INFILE ); sub die_open { open ($_[0], $_[1] ) || die " Sorry can not open file $_[1]\n"; } ## This function sets the tuning fields. sub get_tuning { if ( $entire_in_file[$file_index] =~ /tuning/ ) { ($tuning, $tune[1], $tune[2], $tune[3], $tune[4], $tune[5], $tune[6]) = split (/\s+/,$entire_in_file[$file_index]); $tune_index = $file_index ; $set_tune_index = 1; } else { print " No tuning statement specified\n"; print " Defaulting to E B G D A E \n"; $tune[1] = E; $tune[2] = B; $tune[3] = G; $tune[4] = D; $tune[5] = A; $tune[6] = E; $set_tune_index = 0; } print "Tuning is $tuning $tune[1] $tune[2] $tune[3] $tune[4] $tune[5] $tune[6]\n"; } ## This is the work horse. sub readandprocess { $mult_factor = 1; ## Remove the \n at the end of the line chop( $entire_in_file[$file_index]); ## Break up the input on per string basis ($in_str[1], $in_str[2], $in_str[3], $in_str[4], $in_str[5], $in_str[6]) = split(/\s+/, $entire_in_file[$file_index] ); $col_index++; ## Than process each line &processeachline(); $col_index += 2 + $mult_factor; $mult_factor = 1; $file_index++; if ( $col_index >= $MAXCOL ) { &print_strings(); print OUTFILE "\n\n\n"; } } ## Print out each string and than reset it to tuning sub print_strings { for( $temp_index = 1; $temp_index < 7 ; $temp_index++ ) { if ( $col_index != 0 ) { print OUTFILE "$string[$temp_index]\n"; } $string[$temp_index] = $tune[$temp_index]; } $col_index = 0; } ## This mult_factor is used to correct the number of "-"s that I have ## in the output. e.g. if the fret number is 17 than i will need 2 "-"s ## in the other strings not initialised sub processeachline { &get_mult_factor(); for ( $temp_index = 1; $temp_index < 7; $temp_index++ ) { if ( $in_str[$temp_index] != undef ) { ($first, $fret) = split (/\-/, $in_str[$temp_index]); if ( ($first > 6) || ($first < 1) ) { print "String number $first is not valid\n"; die ; } ($abc, $xyz) = split(//,$fret); if ( $xyz != undef) { $defined_string[$first] = 1; $string[$first] = $string[$first]."-".$fret."-"; } else { $defined_string[$first] = 1; $string[$first] = $string[$first].("-"x$mult_factor).$fret."-"; } } else { last; } } for ( $temp_index = 1; $temp_index < 7; $temp_index++ ) { if ( $defined_string[$temp_index] == 1 ) { $defined_string[$temp_index] = 999; next; } $string[$temp_index] = $string[$temp_index]."--".("-"x$mult_factor); } } sub get_mult_factor { for ( $temp_index = 1; $temp_index < 7; $temp_index++ ) { if ( $in_str[$temp_index] != undef ) { ($first, $fret) = split (/\-/, $in_str[$temp_index]); ($abc, $xyz) = split(//,$fret); if ( $xyz != undef) { $mult_factor = 2; $defined_string[$first] = 1; last; } else { $mult_factor = 1; $defined_string[$first] = 1; } } else { last; } } }