diff doSegmentation.sh @ 0:4182672fd6f8

Initial commit of files from the mauch-MIREX directory on octave
author Chris Cannam
date Tue, 24 Apr 2012 11:52:05 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doSegmentation.sh	Tue Apr 24 11:52:05 2012 +0100
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+if [ $# -lt 2 ] ; then
+echo "Usage: $0 [-s] LISTFILENAME OUTPUTDIR"
+exit 1
+fi
+
+retainstructure=0
+
+while [ $# -gt 2 ] ; do
+case $1 in
+-d) retainstructure=1 ; shift 1 ; echo here;;
+*) shift 1 ;;
+esac
+done
+
+listfile="$1"
+echo listfile "$listfile"
+outputdir="$2"
+
+
+while read infile; do
+	if [ "$infile" -a -f "$infile" ]; then
+		before="$(date +%s)"
+		echo "_____________________________________________________"
+		echo " "
+		echo Processing file "$infile"
+		echo " "
+		if [ $retainstructure -eq 0 ]; then
+			pathandfile=`basename "$infile"`
+		else
+			pathandfile="`echo "$infile" | egrep -o '[^/]*/[^/]*/[^/]*$'`"
+			echo pathandfile "$pathandfile"
+		fi
+		outfile="$outputdir"/"$pathandfile".txt
+		
+		logfile=_logfiles/"$pathandfile".log
+		chromafile=_chromadata/"$pathandfile".csv
+		
+		mkdir -p "`dirname "$outfile"`"
+		
+		echo "[sonic annotator] ..."
+		VAMP_PATH=. ./sonic-annotator-unix -d vamp:matthiasm:nnls_chroma:bothchroma -w csv --csv-stdout "$infile" 2> "$logfile" | cut -d ',' -f 2-  > "$chromafile" 
+		infile="`echo "$infile" | sed "s/'/''/g"`"
+		outfile="`echo "$outfile" | sed "s/'/''/g"`"
+		chromafile="`echo "$chromafile" | sed "s/'/''/g"`"		
+		matlab -nodisplay -nojvm -r run_segmentation\(\'"$infile"\',\'"$outfile"\'\,\'"$chromafile"\'\) >> "$logfile"
+		after="$(date +%s)"
+		elapsed_seconds="$(expr $after - $before)"
+		echo "  -->" time elapsed: $elapsed_seconds seconds
+		echo " "
+	else if [ ! "$infile" ]; then echo ...; fi
+	fi		
+done < "$listfile"