Browse Source

add parameters and generalize directories for bash function that calculates reference filter

Fernando Pablo Lopez-Lezcano 7 years ago
parent
commit
04a7f57ab4
1 changed files with 19 additions and 5 deletions
  1. 19 5
      calibration/src/sphear_make_reference_filter

+ 19 - 5
calibration/src/sphear_make_reference_filter

@@ -5,8 +5,10 @@
 # make_reference_drc_filter: create an inverse equalization filter based
 #                            on the recorded reference microphone signal
 #
+# $1 -> microphone calibration file
+# $2 -> path for reference measurement (use current default if not supplied)
 #
-# Copyright 2016-2017, Fernando Lopez-Lezcano, All Rights Reserved
+# Copyright 2016-2018, Fernando Lopez-Lezcano, All Rights Reserved
 # nando@ccrma.stanford.edu
 #
 #  This program is free software: you can redistribute it and/or modify
@@ -22,24 +24,35 @@
 #  You should have received a copy of the GNU General Public License
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+MIC_CAL=$1
+if [ -z "$MIC_CAL" ] ; then
+    echo "microphone calibration name not supplied!"
+    exit 1
+fi
+REF_PATH=$2
+if [ -z "$REF_PATH" ] ; then
+    REF_PATH="../data/current/"
+fi
+
 # we assume DRC is installed, see:
 # http://drc-fir.sourceforge.net/
 #
 DRC_BASE="../drc-3.2.1"
 
 # we use the trimmed reference impulse response as input
-REFERENCE="../data/current/export/reference-001-1.wav"
+# REFERENCE="../data/current/export/reference-001-1.wav"
+REFERENCE="$REF_PATH/cal/reference-001-1.wav"
 
 # raw pcm output file base name
 OUTFILE="drc-filter"
 
 # calibration data directory
-CAL_DIR="../data/current/cal"
+CAL_DIR="$REF_PATH/cal"
 
 # configuration file (based on the "minimal" stock preset)
 # CONFIG="drc/erb_orig.drc"
-# CONFIG="drc/normal.drc"
-CONFIG="drc/minimal.drc"
+# CONFIG="drc/minimal.drc"
+CONFIG="drc/normal.drc"
 
 # see if we have a microphone calibration file
 if [ -n "$1" ] ; then
@@ -54,6 +67,7 @@ fi
 REFDRC=`echo ${REFERENCE}|sed "s|.wav|-norm.raw|"`
 sox --norm=-3 ${REFERENCE} -t f32 -c 1 ${REFDRC}
 
+# run drc
 ${DRC_BASE}/source/drc --BCInFile ${REFDRC} --PSOutFile ${CAL_DIR}/${OUTFILE}.pcm ${CONFIG} \
 	   --PSPointsFile drc/flat.txt $PSPOINTSFILE