소스 검색

calibration: add shell script to create the DRC calibration filter, change path where the filter is stored

Fernando Pablo Lopez-Lezcano 9 년 전
부모
커밋
efc97e0b2e
2개의 변경된 파일과 56개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      calibration/src/sphear_af_calibrate.m
  2. 54 0
      calibration/src/sphear_make_reference_filter

+ 2 - 2
calibration/src/sphear_af_calibrate.m

@@ -28,13 +28,13 @@
 %%  You should have received a copy of the GNU General Public License
 %%  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-function [trunc] = sphear_af_calibrate(measurements, keep, fade);
+function [] = sphear_af_calibrate(measurements, keep, fade);
   %% the measurement from the reference microphone is processed through
   %% DRC (Digital Room Correction) to create a convolution kernel that is
   %% used to equalize the measurements
   %%
   %% read the convolution kernel
-  [ref, Fs] = wavread('drc/filter.wav');
+  [ref, Fs] = wavread('../data/current/cal/drc-filter.wav');
 
   %% window the DRC generated filter, eliminate the stuff before the main
   %% peak and limit the length to the approximate useful length of the

+ 54 - 0
calibration/src/sphear_make_reference_filter

@@ -0,0 +1,54 @@
+# -*- mode: sh -*-
+#
+# *SpHEAR Project
+#
+# make_reference_drc_filter: create an inverse equalization filter based
+#                            on the recorded reference microphone signal
+#
+#
+# Copyright 2016-2017, Fernando Lopez-Lezcano, All Rights Reserved
+# nando@ccrma.stanford.edu
+#
+#  This program is free software: you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# we assume DRC is installed, see:
+# http://drc-fir.sourceforge.net/
+#
+DRC_BASE="../drc-3.2.1"
+
+# we use the full reference microphone recording as input
+REFERENCE="../data/current/ref-all/reference-001-1.wav"
+
+# raw pcm output file base name
+OUTFILE="drc-filter"
+
+# calibration data directory
+CAL_DIR="../data/current/cal"
+
+# configuration file (based on the "minimal" stock preset)
+CONFIG="drc/minimal.drc"
+
+# normalize reference soundfile and convert to a format that DRC likes
+REFDRC=`echo ${REFERENCE}|sed "s|.wav|-norm.raw|"`
+sox --norm=-3 ${REFERENCE} ${REFDRC}
+
+${DRC_BASE}/source/drc --BCInFile ${REFDRC} --PSOutFile ${CAL_DIR}/${OUTFILE}.pcm ${CONFIG} \
+	   --PSPointsFile drc/flat.txt \
+	   --MCPointsFile drc/mics/emm-6-5850/emm-6-5850-cal.txt
+
+# convert the raw PCM output to a wav file that octave can understand
+sox -e floating-point -b 32 -r 48000 -c 1 -t raw ${CAL_DIR}/${OUTFILE}.pcm ${CAL_DIR}/${OUTFILE}.wav
+
+echo "filter written to ${CAL_DIR}/${OUTFILE}.wav"
+echo "done!"