| 1 | #! /bin/bash -e |
| 2 | |
| 3 | # Define some common paths |
| 4 | . faustpath |
| 5 | # Define compilation flags |
| 6 | . faustoptflags |
| 7 | # Helper file to build the 'help' option |
| 8 | . usage.sh |
| 9 | |
| 10 | CXXFLAGS+=" $MYGCCFLAGS" # So that additional CXXFLAGS can be used |
| 11 | |
| 12 | # The architecture file name |
| 13 | ARCHFILE1=$FAUSTARCH/comparator/minimal-floating-point.cpp |
| 14 | ARCHFILE2=$FAUSTARCH/comparator/minimal-fixed-point.cpp |
| 15 | |
| 16 | # Global variables |
| 17 | OPTIONS="" |
| 18 | FILES="" |
| 19 | |
| 20 | #------------------------------------------------------------------- |
| 21 | # dispatch command arguments |
| 22 | #------------------------------------------------------------------- |
| 23 | |
| 24 | while [ $1 ] |
| 25 | do |
| 26 | p=$1 |
| 27 | |
| 28 | if [ $p = "-help" ] || [ $p = "-h" ]; then |
| 29 | usage faust2comparator "[options] [Faust options] <file.dsp>" |
| 30 | exit |
| 31 | fi |
| 32 | |
| 33 | echo "dispatch command arguments" |
| 34 | |
| 35 | if [ ${p:0:1} = "-" ]; then |
| 36 | OPTIONS="$OPTIONS $p" |
| 37 | elif [[ -f "$p" ]] && [ ${p: -4} == ".dsp" ]; then |
| 38 | FILES="$FILES $p" |
| 39 | else |
| 40 | OPTIONS="$OPTIONS $p" |
| 41 | fi |
| 42 | |
| 43 | shift |
| 44 | done |
| 45 | |
| 46 | #------------------------------------------------------------------- |
| 47 | # compile the *.dsp files |
| 48 | #------------------------------------------------------------------- |
| 49 | |
| 50 | for f in $FILES; do |
| 51 | |
| 52 | # compile the DSP to c++ using the architecture file |
| 53 | echo "compile the DSP to c++ using the architecture file" |
| 54 | faust -i -a $ARCHFILE1 $OPTIONS -cn "fldsp" "$f" -o "float.cpp" || exit |
| 55 | faust -i -a $ARCHFILE2 $OPTIONS -fx -cn "fxdsp" "$f" -o "fixed.cpp" -it || exit |
| 56 | |
| 57 | # compile c++ to binary |
| 58 | echo "compile c++ to binary" |
| 59 | ( |
| 60 | $CXX $CXXFLAGS -g "$FAUSTARCH/comparator/compclass.cpp" "-I/usr/local/include/ap_fixed" `pkg-config --cflags --static --libs sndfile jack gtk+-2.0` -o "${f%.dsp}" |
| 61 | ) > /dev/null || exit |
| 62 | |
| 63 | # remove tempory files # actually, they're useful to have to track bugs in FX inference |
| 64 | # rm -f "float.cpp" |
| 65 | # rm -f "fixed.cpp" |
| 66 | |
| 67 | # collect binary file name for FaustWorks |
| 68 | BINARIES="$BINARIES${f%.dsp};" |
| 69 | done |
| 70 | |
| 71 | echo $BINARIES |
| 72 |