#!/usr/bin/perl use Jcode; $wav_file_name = "MatsunagaTakashi.MOKOMOKO.wav"; $artist = "松永 貴志"; $album = "MOKO-MOKO"; $year = 2003; # 2003/11/06 @titles = ( "南十字星", "モコモコ", "新しい朝", "道頓堀川", "ジャングル・ソング", "哀しみの世界", "暴風ゾーン", "夢の扉", "鯨のブルース" ); @length = ( "6:41", "6:40", "5:10", "4:14", "4:53", "5:07", "4:25", "5:28", "4:02" ); @start_pos = ( 0, 401, 801, 1112, # 1111 1366, # 1365 1659, # 1658 1966, # 1965 2231, # 2230 2558 ); sub ss_to_ms { my $ss = @_[0]; my $m = int( $ss / 60 ); my $s = $ss % 60; $m = "0" . $m if $m < 10; $s = "0" . $s if $s < 10; my $res = $m . ":" . $s . ":00"; return $res; } sub print_toc { print "CD_DA\n\n"; for ( $i = 0; $i < 9; $i++ ) { $start_pos = ss_to_ms( $start_pos[$i] ); $end_pos = ss_to_ms( $start_pos[$i + 1] ); $end_pos = "End of File" if $start_pos[$i + 1] == 0; $length = $start_pos[$i + 1] - $start_pos[$i]; $length = ss_to_ms( $length ) if $length > 0; $length = "" if $length < 0; print "// Track " . ($i + 1) . " $titles[$i] [" . $start_pos . " - " . $end_pos . "]\n"; print "TRACK AUDIO\n"; print "FILE \"$wav_file_name\" " . $start_pos . " " . $length . "\n\n"; } } sub wav_to_mp3 { for ( $i = 0; $i < 9; $i++ ) { $start_pos = $start_pos[$i]; $length = $start_pos[$i + 1] - $start_pos[$i]; $mp3_file_name = "0" . ($i + 1) . ".mp3"; $cmd1 = "ecasound -i:$wav_file_name -y:$start_pos "; $cmd1 .= "-t:$length " if $length > 0; $cmd1 .= "-o:stdout | lame -hx - $mp3_file_name"; $artist = Jcode->new($artist)->sjis; $album = Jcode->new($album)->sjis; $title = Jcode->new($titles[$i])->sjis; $tracknumber = $i + 1; $cmd2 = "mp3info -a \"$artist\" -l \"$album\" "; $cmd2 .= "-n $tracknumber -t \"$title\" -y $year $mp3_file_name"; #print $cmd ."\n"; #print $cmd2 ."\n"; system($cmd1) eq 0 or die "system $cmd1 faild: $?\n"; system($cmd2) eq 0 or die "system $cmd2 faild: $?\n"; } } sub print_start_pos { $total_of_length = 0; foreach ( @length ) { print $total_of_length . "\n"; ( $m, $s ) = split /:/, $_; $total_of_length = $total_of_length + ( $m * 60 + $s ); } } #print_toc; #print_start_pos; wav_to_mp3; # cdrdao write --device 0,0,0 --driver generic-mmc tocfile