• 追加された行はこの色です。
  • 削除された行はこの色です。
*スクリプト集 [#nb5c95b5]
時代はGitHub

**mixman.pl [#oee03e53]
-2つのWAVファイルを重ねあわせて保存する
-16bit, mono only
-RIFFタグは44バイト固定
-サンプリング周波数は合わせて下さい
-個人的に名前がかっこよくてお気に入り

#code[(perl)]{{
#! perl

# 音声を重ねがけ保存 (16bit mono only)
# mixman inputfile mixsoundfile outputfile

use strict;
use warnings;

my $input = $ARGV[0];
my $sound = $ARGV[1];
my $output = $ARGV[2];

open(IN, "<$input") or die("file open error");
binmode IN;

open(DATA, "<$sound") or die("file open error");
binmode DATA;

# まずはサウンドファイルを配列に入れていく
my @effect;
my $temp;

# riffタグスキップ
seek(DATA, 44, 0);

while(read(DATA, $temp, 2)) { # 2byte (short) read
  my $data = unpack("s", $temp);
  push(@effect, $data);
}

open(SAVE, ">$output") or die("file write error");
binmode SAVE;

# 次に入力ファイルに加算保存していく
my $in_cnt = 0;
my $eff_cnt = $#effect;

# riffタグをコピー
for(my $i=0; $i<44; $i++) {
  read(IN, $temp, 1);
  print SAVE $temp;
}

while(read(IN, $temp, 2)) { # 2byte read
  my $data = unpack("s", $temp);
  print SAVE pack("s", ($data + $effect[$in_cnt % $eff_cnt]));
  $in_cnt++;
}

close(SAVE);
close(DATA);
close(IN);
1;
}}

トップ   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS