Debian Codegraph @

tools/faust2appls/faust2csvplot

raw symbols SCIP
1 #! /bin/bash -e
2
3 #####################################################################
4 # #
5 # Compiles Faust programs to plotters #
6 # (c) Grame, 2019-2022 #
7 # #
8 #####################################################################
9
10 . faustpath
11 . faustoptflags
12 . usage.sh
13
14 CXXFLAGS+=" $MYGCCFLAGS" # So that additional CXXFLAGS can be used
15
16 ARCHFILE=$FAUSTARCH/csvplot.cpp
17 ARCHLIB+=" -pthread"
18
19 FAUSTFLOAT=float
20 SOUNDFILELIBS=""
21
22 echoHelp() {
23 usage faust2csvplot "[options] [Faust options] <file.dsp>"
24 echo "Compiles Faust programs to plotters, additional control parameters depend of the DSP, the following 5 options are given at runtime:"
25 options -dyn
26 option "-s <n>" "start at the sample number <n> (default is 0)"
27 option "-n <n>" "render <n> samples (default is 16)"
28 option "-r <rate>" "change the sample rate (default is 44100 Hz)"
29 option "-bs <buffer>" "change the buffer size (default is 512 frames)"
30 option
31 option -arch32 "generates a 32 bit architecture."
32 option -arch64 "generates a 64 bit architecture."
33 option -double "generates code with samples of type 'double'."
34 option -soundfile
35 option "Faust options"
36 exit
37 }
38
39 if [ "$#" -eq 0 ]; then
40 echo 'Please, provide a Faust file to process !'
41 echo ''
42 echoHelp
43 fi
44
45 #-------------------------------------------------------------------
46 # Analyze command arguments :
47 # faust options -> OPTIONS
48 # if -omp : -openmp or -fopenmp -> OPENMP
49 # existing *.dsp files -> FILES
50 #
51
52 # dispatch command arguments
53 for p in $@; do
54
55 if [ $p = "-help" ] || [ $p = "-h" ]; then
56 echoHelp
57 elif [ $p = "-arch32" ]; then
58 PROCARCH="-m32 -L/usr/lib32"
59 elif [ $p = "-arch64" ]; then
60 PROCARCH="-m64"
61 elif [ $p = "-double" ]; then
62 OPTIONS="$OPTIONS $p"
63 FAUSTFLOAT="double"
64 elif [ $p = "-soundfile" ]; then
65 CXXFLAGS="$CXXFLAGS -DSOUNDFILE"
66 SOUNDFILELIBS=`pkg-config --cflags --static --libs sndfile`
67 elif [ $p = "-fx" ]; then
68 OPTIONS="$OPTIONS $p"
69 CXXFLAGS="$CXXFLAGS -I /usr/local/include/ap_fixed -DFIXED_POINT"
70 elif [ $p = "-dyn" ]; then
71 OPTIONS="$OPTIONS -inj template-llvm.cpp"
72 LLVM_LIBS="$STRIP $FAUSTLDDIR/libfaust.a `llvm-config --link-static --ldflags --libs all --system-libs`"
73 elif [ ${p:0:1} = "-" ]; then
74 OPTIONS="$OPTIONS $p"
75 elif [[ -f "$p" ]] && [ ${p: -4} == ".dsp" ]; then
76 FILES="$FILES $p"
77 else
78 OPTIONS="$OPTIONS $p"
79 fi
80 done
81
82 #-------------------------------------------------------------------
83 # compile the *.dsp files
84
85 for f in $FILES; do
86
87 # compile Faust to c++
88 faust -i -a $ARCHFILE $OPTIONS "$f" -o "$f.cpp" || exit
89
90 # compile c++ to binary
91 (
92 $CXX $CXXFLAGS "$f.cpp" $PROCARCH $LLVM_LIBS $ARCHLIB $SOUNDFILELIBS $OMP -DFAUSTFLOAT=$FAUSTFLOAT -o "${f%.dsp}"
93 ) > /dev/null || exit
94 rm "$f.cpp"
95
96 # collect binary file name for FaustWorks
97 BINARIES="$BINARIES${f%.dsp};"
98 done
99 echo $BINARIES