Last active
December 29, 2015 19:39
-
-
Save coderofsalvation/7718992 to your computer and use it in GitHub Desktop.
Simple drumloopslicer using purely bash, sox and vamp plugin on the console
This file contains 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 characters
#!/bin/bash | |
# Simple drumloopslicer using purely bash, sox and vamp plugin on the console | |
# @dependancy bc vamp-simple-host | |
slice(){ | |
input="$1" | |
which bc || { echo "please install 'bc' from your package manager"; exit 1; } | |
which vamp-simple-host || { echo "please install 'vamp-examples' from your package manager"; exit 1; } | |
hits="$(vamp-simple-host vamp-example-plugins:percussiononsets "$input" 2>/dev/null | grep -E " [0-9].*" | sed 's/ //g;s/://g')"; | |
declare -a hitArray; | |
last="" | |
i=0 | |
IFS=' | |
' # set field seperator to newlines | |
for hit in $hits; do hitArray[$i]=$hit; ((i++)); done | |
for((i=0;i<${#hitArray[@]}-1;i++)); do | |
hit=${hitArray[$i]} | |
hitnext=${hitArray[$i+1]} | |
length="$( echo "$hitnext-$hit" | bc )"; [[ ${length:0:1} == "." ]] && length="0$length" | |
echo "processing $input slice #$i" | |
sox "$input" "$input.$hit.wav" trim $hit $length fade t 0 0 1500s | |
done | |
} | |
slice "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment