summaryrefslogtreecommitdiff
path: root/datasets/dataset.pl
diff options
context:
space:
mode:
Diffstat (limited to 'datasets/dataset.pl')
-rwxr-xr-xdatasets/dataset.pl67
1 files changed, 67 insertions, 0 deletions
diff --git a/datasets/dataset.pl b/datasets/dataset.pl
new file mode 100755
index 0000000..4e3b9a9
--- /dev/null
+++ b/datasets/dataset.pl
@@ -0,0 +1,67 @@
+#!/usr/bin/perl
+
+use strict;
+use Getopt::Std;
+
+our $opt_c;
+getopts('c');
+
+my $fmt = <<FMT;
+Input File : '01_snapping_clean.wav'
+Channels : 1
+Sample Rate : 44100
+Precision : 16-bit
+Duration : 00:03:09.35 = 8350438 samples = 14201.4 CDDA sectors
+File Size : 16.7M
+Bit Rate : 706k
+Sample Encoding: 16-bit Signed Integer PCM
+FMT
+
+sub process($) {
+ my $filename = shift or die "Usage: $0 [...filenames]\n";
+ my ($name, $ext) = split(/\./, $filename, 2);
+
+ my $soxi = `soxi $filename`;
+ my @lines = split("\n", $soxi);
+
+ print $soxi;
+
+ my $seconds;
+ for my $line (@lines) {
+ if ($line =~ /Duration : (\d\d):(\d\d):(\d\d)\./) {
+ my $h = $1;
+ my $m = $2;
+ my $s = $3;
+ $seconds = (((($h * 60) + $m) * 60) + $s) + 0;
+ }
+ }
+
+ 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;
+ if ($opt_c) {
+ print "Normalizing...";
+ system("sox", "-v", 0.945, $filename, $a_tmp);
+ } else {
+ $a_tmp = $filename;
+ }
+ 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);
+ }
+ system("/bin/rm", $b_tmp);
+}
+
+foreach my $file (@ARGV) {;
+ if ( -e $file ) {
+ process($file);
+ }
+}
+
+