| 1 | #!/bin/bash |
| 2 | |
| 3 | ##################################################################### |
| 4 | # # |
| 5 | # Compiles Faust programs to impulse tests # |
| 6 | # (c) Grame, 2017 # |
| 7 | # # |
| 8 | ##################################################################### |
| 9 | |
| 10 | for p in $@; do |
| 11 | if [ ${p:0:1} = "-" ]; then |
| 12 | OPTIONS="$OPTIONS $p" |
| 13 | elif [[ -f "$p" ]]; then |
| 14 | FILES="$FILES $p" |
| 15 | else |
| 16 | OPTIONS="$OPTIONS $p" |
| 17 | fi |
| 18 | done |
| 19 | |
| 20 | #------------------------------------------------------------------- |
| 21 | # compile the *.dsp files |
| 22 | |
| 23 | for f in $FILES; do |
| 24 | |
| 25 | name=$(basename "$f" .dsp) |
| 26 | name_exp=$name"_exp.dsp" |
| 27 | dirname=$(dirname "$f"); |
| 28 | |
| 29 | # compile Faust to c++ |
| 30 | faust -e "$f" |
| 31 | cd $dirname |
| 32 | faust $OPTIONS -i -A .. -a impulsearch.cpp $name_exp -o "$name.cpp" || exit |
| 33 | |
| 34 | # compile c++ to binary |
| 35 | ( |
| 36 | ${CXX=g++} ${CXXFLAGS=-O3 -pthread -std=c++11} $OMP "$name.cpp" -o "$name" |
| 37 | ) > /dev/null || exit |
| 38 | |
| 39 | # run the resulting binary to generate the impulse response |
| 40 | ./"$name" -n 30000 |
| 41 | |
| 42 | # cleanup |
| 43 | rm "$name" "$name.cpp" $name_exp |
| 44 | |
| 45 | done |
| 46 |