sphear_process_h2n_recording 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/bash
  2. #
  3. #
  4. LSCONV=../../drc-3.2.1/source/lsconv
  5. if [ "$1" == "" ] ; then
  6. echo "usage: sphear_process_h2n_recording FILEPREFIX INVSWEEP (SR00x where x is the recording number)"
  7. exit 1
  8. else
  9. BASENAME=$1;
  10. fi
  11. if [ "$2" == "" ] ; then
  12. echo "usage: sphear_process_h2n_recording FILEPREFIX INVSWEEP (SR00x where x is the recording number)"
  13. exit 1
  14. else
  15. INVSWEEP=$2;
  16. fi
  17. XYFILE=${BASENAME}XY.WAV
  18. MSFILE=${BASENAME}MS.WAV
  19. if [ ! -r ${XYFILE} ] ; then
  20. echo "ERROR: could not find ${XYFILE}!"
  21. exit 1
  22. fi
  23. if [ ! -r ${MSFILE} ] ; then
  24. echo "ERROR: could not find ${MSFILE}!"
  25. exit 1
  26. fi
  27. echo "-- convert input files to pcm..."
  28. sox ${XYFILE} -t f32 -c 1 -r 48000 a-format-4.pcm remix 1
  29. sox ${XYFILE} -t f32 -c 1 -r 48000 a-format-3.pcm remix 2
  30. echo "-- calculate impulse responses..."
  31. # process XY
  32. ${LSCONV} a-format-4.pcm ${INVSWEEP} a-format-ir-4.pcm
  33. ${LSCONV} a-format-3.pcm ${INVSWEEP} a-format-ir-3.pcm
  34. sox -t f32 -c 1 -r 48000 a-format-ir-4.pcm a-format-ir-4.wav
  35. sox -t f32 -c 1 -r 48000 a-format-ir-3.pcm a-format-ir-3.wav
  36. # process MS
  37. sox ${MSFILE} a-format-MSL.wav remix 1 gain
  38. sox ${MSFILE} a-format-MSR.wav remix 2 gain 2.0
  39. # invert R
  40. sox a-format-MSR.wav a-format-MSRI.wav remix 1i0
  41. # M = L + R / 2
  42. sox --combine mix a-format-MSL.wav a-format-MSR.wav a-format-1.wav gain 0.5
  43. # S = (L - R) / 2
  44. sox --combine mix a-format-MSL.wav a-format-MSRI.wav a-format-2.wav gain 0.5
  45. # convert to pcm and run lsconv
  46. sox a-format-1.wav -t f32 -c 1 -r 48000 a-format-1.pcm
  47. sox a-format-2.wav -t f32 -c 1 -r 48000 a-format-2.pcm
  48. ${LSCONV} a-format-1.pcm ${INVSWEEP} a-format-ir-1.pcm
  49. ${LSCONV} a-format-2.pcm ${INVSWEEP} a-format-ir-2.pcm
  50. sox -t f32 -c 1 -r 48000 a-format-ir-1.pcm a-format-ir-1.wav
  51. sox -t f32 -c 1 -r 48000 a-format-ir-2.pcm a-format-ir-2.wav
  52. echo "-- removing temporary files..."
  53. rm -f a-format-ir-XY1.pcm a-format-ir-XY2.pcm
  54. rm -f a-format-ir-MSL.pcm a-format-ir-MSR.pcm
  55. rm -f a-format-?.pcm
  56. rm -f a-format-ir-?.pcm
  57. #rm -f a-format-MS?.wav
  58. #rm -f a-format-MSRI.wav
  59. echo "-- done"