From 6fe185e50393f57aa7125bb83866aeb96cb88c92 Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 9 Apr 2018 07:39:22 +0200 Subject: including results scripts --- results/crossfade_cat.sh | 129 +++++++++++++++++++++++++++++++++++++++++++++++ results/loop.sh | 20 ++++++++ results/xfade.sh | 25 +++++++++ 3 files changed, 174 insertions(+) create mode 100755 results/crossfade_cat.sh create mode 100755 results/loop.sh create mode 100755 results/xfade.sh (limited to 'results') diff --git a/results/crossfade_cat.sh b/results/crossfade_cat.sh new file mode 100755 index 0000000..13a8e90 --- /dev/null +++ b/results/crossfade_cat.sh @@ -0,0 +1,129 @@ +#!/bin/bash +# +# crossfade_cat.sh +# +# Concatenates two files together with a crossfade of $1 seconds. +# Filenames are specified as $2 and $3. +# +# $4 is optional and specifies if a fadeout should be performed on +# first file. +# $5 is optional and specifies if a fadein should be performed on +# second file. +# +# Example: crossfade_cat.sh 10 infile1.wav infile2.wav auto auto +# +# By default, the script attempts to guess if the audio files +# already have a fadein/out on them or if they just have really +# low volumes that won't cause clipping when mixxing. If this +# is not detected then the script will perform a fade in/out to +# prevent clipping. +# +# The user may specify "yes" or "no" to force the fade in/out +# to occur. They can also specify "auto" which is the default. +# +# Crossfaded file is created as "mix.wav". +# +# Original script from Kester Clegg. Mods by Chris Bagwell to show +# more examples of sox features. +# + +SOX=sox +SOXI=soxi + +if [ "$3" == "" ]; then + echo "Usage: $0 crossfade_seconds first_file second_file [ fadeout ] [ fadein ]" + echo + echo "If a fadeout or fadein is not desired then specify \"no\" for that option. \"yes\" will force a fade and \"auto\" will try to detect if a fade should occur." + echo + echo "Example: $0 10 infile1.wav infile2.wav auto auto" + exit 1 +fi + +fade_length=$1 +first_file=$2 +second_file=$3 + +fade_first="auto" +if [ "$4" != "" ]; then + fade_first=$4 +fi + +fade_second="auto" +if [ "$5" != "" ]; then + fade_second=$5 +fi + +fade_first_opts= +if [ "$fade_first" != "no" ]; then + fade_first_opts="fade t 0 0:0:$fade_length 0:0:$fade_length" +fi + +fade_second_opts= +if [ "$fade_second" != "no" ]; then + fade_second_opts="fade t 0:0:$fade_length" +fi + +echo "crossfade and concatenate files" +echo +echo "Finding length of $first_file..." +first_length=`$SOX "$first_file" 2>&1 -n stat | grep Length | cut -d : -f 2 | cut -f 1` +echo "Length is $first_length seconds" + +trim_length=`echo "$first_length - $fade_length" | bc` + +# Get crossfade section from first file and optionally do the fade out +echo "Obtaining $fade_length seconds of fade out portion from $first_file..." +$SOX "$first_file" -e signed-integer -b 16 fadeout1.wav trim $trim_length + +# When user specifies "auto" try to guess if a fadeout is needed. +# "RMS amplitude" from the stat effect is effectively an average +# value of samples for the whole fade length file. If it seems +# quite then assume a fadeout has already been done. An RMS value +# of 0.1 was just obtained from trail and error. +if [ "$fade_first" == "auto" ]; then + RMS=`$SOX fadeout1.wav 2>&1 -n stat | grep RMS | grep amplitude | cut -d : -f 2 | cut -f 1` + should_fade=`echo "$RMS > 0.1" | bc` + if [ $should_fade == 0 ]; then + echo "Auto mode decided not to fadeout with RMS of $RMS" + fade_first_opts="" + else + echo "Auto mode will fadeout" + fi +fi + +$SOX fadeout1.wav fadeout2.wav $fade_first_opts + +# Get the crossfade section from the second file and optionally do the fade in +echo "Obtaining $fade_length seconds of fade in portion from $second_file..." +$SOX "$second_file" -e signed-integer -b 16 fadein1.wav trim 0 $fade_length + +# For auto, do similar thing as for fadeout. +if [ "$fade_second" == "auto" ]; then + RMS=`$SOX fadein1.wav 2>&1 -n stat | grep RMS | grep amplitude | cut -d : -f 2 | cut -f 1` + should_fade=`echo "$RMS > 0.1" | bc` + if [ $should_fade == 0 ]; then + echo "Auto mode decided not to fadein with RMS of $RMS" + fade_second_opts="" + else + echo "Auto mode will fadein" + fi +fi + +$SOX fadein1.wav fadein2.wav $fade_second_opts + +# Mix the crossfade files together at full volume +echo "Crossfading..." +$SOX -m -v 1.0 fadeout2.wav -v 1.0 fadein2.wav crossfade.wav + +echo "Trimming off crossfade sections from original files..." + +$SOX "$first_file" -e signed-integer -b 16 song1.wav trim 0 $trim_length +$SOX "$second_file" -e signed-integer -b 16 song2.wav trim $fade_length +$SOX song1.wav crossfade.wav song2.wav mix.wav + +echo -e "Removing temporary files...\n" +rm fadeout1.wav fadeout2.wav fadein1.wav fadein2.wav crossfade.wav song1.wav song2.wav +mins=`echo "$trim_length / 60" | bc` +secs=`echo "$trim_length % 60" | bc` +echo "The crossfade in mix.wav occurs at around $mins mins $secs secs" + diff --git a/results/loop.sh b/results/loop.sh new file mode 100755 index 0000000..beb1286 --- /dev/null +++ b/results/loop.sh @@ -0,0 +1,20 @@ +rm fades.txt +rm files.txt +rm mix.sh + +ITER=0 +NEXT=1 +for i in `ls -v *.wav` +do +echo "[0$ITER][$NEXT]acrossfade=ns=5:o=1:c1=tri:c2=tri[0$NEXT];" >> fades.txt +printf '\-i %s ' $i >> files.txt +ITER=$(expr $ITER + 1) +NEXT=$(expr $NEXT + 1) +done + +printf "ffmpeg " >> mix.sh +cat files.txt >> mix.sh +printf " -filter_complex \"" >> mix.sh +cat fades.txt >> mix.sh +echo '\" out.wav' >> mix.sh + diff --git a/results/xfade.sh b/results/xfade.sh new file mode 100755 index 0000000..9fc4d39 --- /dev/null +++ b/results/xfade.sh @@ -0,0 +1,25 @@ +crossfade_dur=1 +i=0 +limit=10000 + +for file in `ls *.wav | sort -V` +do + i=$((i+1)) + if [ $i -eq $limit ] + then + break + fi + + if [ $i -eq 1 ] + then + cp $file mix.wav + else + # ../../crossfade_cat.sh $crossfade_dur mix.wav $file yes yes + echo $file + sox $file tmp.wav highpass 10 + sox mix.wav tmp.wav out.wav splice $(soxi -D mix.wav),0.01 + mv out.wav mix.wav + rm tmp.wav + fi +done + -- cgit v1.2.3-70-g09d2 From d559edfb51c7a28f9b3d426f652f90215fef5e26 Mon Sep 17 00:00:00 2001 From: jules on spawn Date: Tue, 10 Apr 2018 21:12:28 +0200 Subject: upload log dogg --- results/xfade.sh | 2 +- upload.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'results') diff --git a/results/xfade.sh b/results/xfade.sh index 9fc4d39..0a5e34a 100755 --- a/results/xfade.sh +++ b/results/xfade.sh @@ -15,7 +15,7 @@ do cp $file mix.wav else # ../../crossfade_cat.sh $crossfade_dur mix.wav $file yes yes - echo $file + # echo $file sox $file tmp.wav highpass 10 sox mix.wav tmp.wav out.wav splice $(soxi -D mix.wav),0.01 mv out.wav mix.wav diff --git a/upload.js b/upload.js index 6bbb71e..ca15029 100644 --- a/upload.js +++ b/upload.js @@ -31,7 +31,8 @@ var r = request.post('https://bucky.asdf.us/api/thread/' + id + '/comment', func console.log('Upload successful!') console.log('\n') argv['_'].forEach(fn => { - console.log('https://s3.amazonaws.com/i.asdf.us/bucky/data/' + id + '/' + fn); + const partz = fn.split('/') + console.log('https://s3.amazonaws.com/i.asdf.us/bucky/data/' + id + '/' + partz[partz.length-1]); }) }) -- cgit v1.2.3-70-g09d2 From d9f28aa4b5c538468f8b3b8cf39189afc3d13ca5 Mon Sep 17 00:00:00 2001 From: jules on spawn Date: Thu, 12 Apr 2018 15:53:25 +0200 Subject: highpass on first wav --- datasets/dataset.pl | 4 ++-- mix.sh | 5 ++--- results/xfade.sh | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) (limited to 'results') diff --git a/datasets/dataset.pl b/datasets/dataset.pl index 8b77af9..edde43f 100755 --- a/datasets/dataset.pl +++ b/datasets/dataset.pl @@ -48,7 +48,7 @@ sub process($) { my $a_tmp = "a_" . $filename; my $b_tmp = "b_" . $filename; - if ($opt_c) { + if (!$opt_c) { print "Normalizing..."; system("sox", "-v", 0.945, $filename, $a_tmp); } else { @@ -56,7 +56,7 @@ sub process($) { } system("./spread.sh", $a_tmp, $b_tmp, 0.999, $scale, 1.001); system("./split44k.sh", $b_tmp, 8, $name); - if ($opt_c) { + if (!$opt_c) { system("/bin/rm", $a_tmp); } system("/bin/rm", $b_tmp); diff --git a/mix.sh b/mix.sh index 821d802..9df81a7 100755 --- a/mix.sh +++ b/mix.sh @@ -14,9 +14,8 @@ echo "rendering $name" cd "$dir/samples" mkdir "$name" ../../xfade.sh -sox mix.wav norm.wav norm -lame -V 0 norm.wav "../../../output/$name.mp3" -rm mix.wav norm.wav +lame -V 0 mix.wav "../../../output/$name.mp3" +rm mix.wav mv *.wav "$name" cd .. grep valid log diff --git a/results/xfade.sh b/results/xfade.sh index 0a5e34a..55d343d 100755 --- a/results/xfade.sh +++ b/results/xfade.sh @@ -12,7 +12,7 @@ do if [ $i -eq 1 ] then - cp $file mix.wav + sox $file mix.wav highpass 10 else # ../../crossfade_cat.sh $crossfade_dur mix.wav $file yes yes # echo $file -- cgit v1.2.3-70-g09d2