Skip to content

Instantly share code, notes, and snippets.

@coderofsalvation
Last active December 29, 2015 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coderofsalvation/7718992 to your computer and use it in GitHub Desktop.
Save coderofsalvation/7718992 to your computer and use it in GitHub Desktop.
Simple drumloopslicer using purely bash, sox and vamp plugin on the console
#!/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