diff options
Diffstat (limited to 'datasets')
| -rwxr-xr-x | datasets/dataset.pl | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/datasets/dataset.pl b/datasets/dataset.pl index cf1c1e2..a89e3f8 100755 --- a/datasets/dataset.pl +++ b/datasets/dataset.pl @@ -4,7 +4,9 @@ use strict; use Getopt::Std; our $opt_c; -getopts('c'); +our $opt_j; +getopts('c'); # normalize the file +getopts('j'); # jitter the pitch of each subsample by N rather than repitching big chunks print "<<<< DATASET >>>>\n"; my $fmt = <<FMT; @@ -45,11 +47,8 @@ sub process($) { } } - my $scale = sprintf("%.09f", 5e-7 * $seconds); print "Seconds: $seconds\n"; - print "Scale factor: $scale\n"; - print "\n"; my $a_tmp = "a_" . $filename; my $b_tmp = "b_" . $filename; @@ -59,8 +58,39 @@ sub process($) { } else { $a_tmp = $filename; } - system("./spread.sh", $a_tmp, $b_tmp, 0.999, $scale, 1.001); - system("./split44k.sh", $b_tmp, 8, $name); + + # jitter mide: make copies of the original file and join together, + # split into chunks, and then pitchshift the chunks. + if ($opt_j) { + my $copies = 4080 / $seconds; + print "Copies to make: $copies\n"; + print "\n"; + for (my $i = 0; $i < $copies; $i++) { + system('cp', $a_tmp, sprintf("tmp_%d.wav", $i)); + } + system 'sox', glob 'tmp_*', $b_tmp; + system 'rm', glob 'tmp_*'; + system './split44k.sh', $b_tmp, 8, $name; + opendir my $dh, $name or die "cant opendir $name: $!"; + while (readdir $dh) { + next if /^\./; + my $fn = $_; + my $n = rand( 2 * $j ) - $j; + system 'sox', $name . '/' . $fn, $name . '/z_' . $fn, 'pitch', $n; + system 'rm', $name . '/' . $fn; + } + closedir $dh; + } + + # standard mode: make a bunch of copies and then join them together, + # then subdivide into 8s chunks + else { + my $scale = sprintf("%.09f", 5e-7 * $seconds); + print "Scale factor: $scale\n"; + print "\n"; + system("./spread.sh", $a_tmp, $b_tmp, 0.999, $scale, 1.001); + system("./split44k.sh", $b_tmp, 8, $name); + } if (!$opt_c) { system("/bin/rm", $a_tmp); } |
