<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl
#
# lrc2smi lyrics to plain text (wmp smi) v1.00 (perl)
#
# convert lyrics .lrc to WMP smi
#
# copyright 2004 Lechee.Lai  lecheel at yahoo dot com
#

# global variable
use File::Basename;
my $tcount=0;
my $tcontext;


$argc=@ARGV
&amp;convertLRC();
exit 1;


sub convertLRC {
  	open(FILE, @ARGV[0]) or die "lrc2smi: you must have \"@ARGV[0]\" for convert :-)\n";
        my $out=basename(@ARGV[0],"");
        if ($out=~/(.*)\..*/ and !$option{'withextension'}) {$out=~s/(.*)\..*/$1\.smi/;}
        else {$out.=".smi";}
        $pureLrc = "&gt;$out";
        
  	@file = &lt;FILE&gt;;
  	close (FILE);
  	open (NEWFILE, $pureLrc) or die "$!";
        &amp;SMIbegin();
        &amp;SMItitle();
  	foreach $line (@file) {
		chomp ($line);
		$line1 = $line;
#		if ($line1 =~ /^\[(\d{2})\:(\d{2})\](.*)$/) {  # check [nn:nn]
               if ($line1 =~ /^(.*)(:)(.*)(])/) {     # check *:*]
                    $line2 = $line1;
                   if ($line2 =~ /\d(:)+\d+(])/) {    # check nnn:nnn]
#                    if (1) {
                        $l1 = $line1;
                        checkTimeStamp($line1);
                        $noMore=0;
                        
                        while ($noMore==0) {
                        
                            if ($l1 =~ /^(.*)\d{2}(])/) { # have vaild timestamp
                            	$pos = index($l1, "]");
                            	$timestamp = substr($l1, 0, $pos+1);
                                
                                
    				if ($timestamp =~ /^\[(\d{2})\:(\d{2})\](.*)$/) {
                                
        				my ($m, $s) = ($1, $2);
        				my $sec = $s+60*$m;
                                
        				while (exists $times{$sec}){
            				$sec += 0.01;
        				}
                                        
                                        &amp;SMItime($sec);
                                }
                            	if ($tcount) {
                            		print NEWFILE "$tcontext";
                            	}
			    	print NEWFILE "\n";    
                            	$l1 = substr($l1,$pos+1);
                            } else {
                              $noMore=1;
                            }
                       
                        }
                    } else {
                    
#                        print "###$line1\n";
                    }
                } else {
#                	print "---$line\n";    
                }
               
	}
	&amp;SMIend();
		close(NEWFILE);
}

sub checkTimeStamp($) {
	my ($line) = @_;
        $tcount = 0;        # initialize for TimeCount 
        $pos = rindex($line,"]");
        $tcontext = substr($line,$pos+1);
        if ($pos&gt;5) {
            $tcount = 1;
        }
#        print "...$tcontext\n";

}



sub SMIbegin {
	print NEWFILE "&lt;SAMI&gt;\n";
        print NEWFILE "&lt;HEAD&gt;\n";
        print NEWFIEL "&lt;TITLE&gt;Lechee Lyrics SMI&lt;/TITLE&gt;\n"; 
}

sub SMItitle {
        print NEWFILE "&lt;STYLE TYPE=\"text/css\"&gt;\n&lt;!--\nP {\n";
        print NEWFILE "margin-left:8pt;\n";
        print NEWFILE "margin-right:8pt;\n";
        print NEWFILE "margin-bottom:24pt;\n";
        print NEWFILE "Background-image : url();\n";
        print NEWFILE "line-height:48pt;\n";
        print NEWFILE "Background-color:#000000;\n";
        print NEWFILE "text-align:center;\n";
        print NEWFILE "font-size:16pt;\n";
        print NEWFILE "font-family:,tahoma,arial,dotum,sans-serif;\n";
        print NEWFILE "font-weight:bold;\n";
        print NEWFILE "font-style:Normal;\n";
        print NEWFILE "color:#ffff00;\n";    
        print NEWFILE "}\n";
        print NEWFILE ".CCUS {Name:English; lang: en-US;\n}\n--&gt;\n";
        print NEWFILE "&lt;/STYLE&gt;/n&lt;/HEAD&gt;\n";
        print NEWFILE "&lt;BODY&gt;\n";
}

sub SMIend {
	print NEWFILE "&lt;/BODY&gt;\n";
        print NEWFILE "&lt;/SAMI&gt;\n";
}

sub SMItime($) {
	my ($tt) = @_;
	print NEWFILE "&lt;SYNC Start=";
        print NEWFILE $tt;
        print NEWFILE "000&gt;&lt;P Class=EGCC&gt;";    
}
</pre></body></html>