Created
September 29, 2012 09:42
-
-
Save Shinpeim/3803586 to your computer and use it in GitHub Desktop.
Revisions
-
Shinpeim created this gist
Sep 29, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ use strict; use warnings; use IO::File; my $filename = shift or die "usage: $0 source > dest"; my $fp = IO::File->new($filename,"r"); my $pcm = ""; while ($fp->read(my $buff,1024)) { $pcm .= $buff; } $fp->close; my $size = length $pcm; my @wave_header = ( "RIFF", pack("V",$size + 36), #全体のファイルサイズ - 8 "WAVE", "fmt ", "\x10\x00\x00\x00", #リニアPCM "\x01\x00", #リニアPCM "\x01\x00", #モノラル "\x40\x1f\x00\x00", #8kHz "\x40\x1f\x00\x00", #データ速度 "\x01\x00", #ブロックサイズ "\x08\x00", #量子化ビットサイズ "data", pack("V",$size), ); print join("",@wave_header,$pcm);