Debian Codegraph @

tools/faust2appls/faust2netjackconsole

raw symbols SCIP
1 #! /bin/bash -e
2
3 . faustpath
4 . faustoptflags
5 . usage.sh
6
7 CXXFLAGS+=" $MYGCCFLAGS" # So that additional CXXFLAGS can be used
8
9 ARCHFILE=$FAUSTARCH/netjack-console.cpp
10
11 NVOICES=-1
12 POLY="POLY"
13 EFFECT=""
14
15 echoHelp()
16 {
17 usage faust2netjackconsole "[options] [Faust options] <file.dsp>"
18 require Jack
19 echo "Compiles Faust programs to NetJack"
20 option
21 options -httpd -osc -midi
22 option "-nvoices <num>"
23 option "-effect <effect.dsp>"
24 option "-effect auto"
25 option "Faust options"
26 exit
27 }
28
29 if [ "$#" -eq 0 ]; then
30 echo 'Please, provide a Faust file to process !'
31 echo ''
32 echoHelp
33 fi
34
35 #-------------------------------------------------------------------
36 # Check Darwin specifics
37 #
38 if [[ $(uname) == Darwin ]]; then
39 ARCHLIB="-L/usr/local/lib -ljacknet -ljack -pthread -framework CoreMIDI -framework CoreFoundation -framework CoreAudio -framework AudioUnit -framework CoreServices"
40 else
41 ARCHLIB+="-L/usr/local/lib -ljacknet -ljack -pthread"
42 fi
43
44 #-------------------------------------------------------------------
45 # Analyze command arguments :
46 # faust options -> OPTIONS
47 # existing *.dsp files -> FILES
48 #
49
50 while [ $1 ]
51 do
52 p=$1
53
54 if [ $p = "-help" ] || [ $p = "-h" ]; then
55 echoHelp
56 elif [ $p = "-nvoices" ]; then
57 POLYDEFS="-DPOLY"
58 shift
59 NVOICES=$1
60 if [ $NVOICES -ge 0 ]; then
61 CXXFLAGS="$CXXFLAGS -DNVOICES=$NVOICES"
62 fi
63 elif [ $p = "-effect" ]; then
64 POLYDEFS="-DPOLY2"
65 POLY="POLY2"
66 shift
67 EFFECT=$1
68 elif [ $p = "-osc" ]; then
69 OSCDEFS="-DOSCCTRL -lOSCFaust"
70 elif [ $p = "-httpd" ]; then
71 HTTPDEFS="-DHTTPCTRL -lHTTPDFaust"
72 HTTPLIBS=`pkg-config --cflags --libs libmicrohttpd`
73 elif [ $p = "-midi" ]; then
74 MIDIDEFS="-DMIDICTRL"
75 elif [ ${p:0:1} = "-" ]; then
76 OPTIONS="$OPTIONS $p"
77 elif [[ -f "$p" ]] && [ ${p: -4} == ".dsp" ]; then
78 FILES="$FILES $p"
79 else
80 OPTIONS="$OPTIONS $p"
81 fi
82
83 shift
84
85 done
86
87 #-------------------------------------------------------------------
88 # compile the *.dsp files
89 #
90 for f in $FILES; do
91
92 CUR=$(pwd)
93 f=$(basename "$p")
94 SRCDIR=$(dirname "$p")
95
96 # creates a temporary dir
97 TDR=$(mktemp -d faust.XXX)
98 TMP="$TDR/${f%.dsp}"
99 mkdir "$TMP"
100
101 # compile faust to c++
102 if [ $POLY = "POLY2" ]; then
103 if [ $EFFECT = "auto" ]; then
104 cat > $TMP/effect.dsp << EndOfCode
105 adapt(1,1) = _;
106 adapt(2,2) = _,_;
107 adapt(1,2) = _ <: _,_;
108 adapt(2,1) = _,_ :> _;
109 adaptor(F,G) = adapt(outputs(F),inputs(G));
110 process = adaptor(library("$SRCDIR/$f").process, library("$SRCDIR/$f").effect) : library("$SRCDIR/$f").effect;
111 EndOfCode
112 faust -i -json -a $ARCHFILE $OPTIONS "$SRCDIR/$f" -o "$TMP/${f%.dsp}.cpp" || exit
113 faust -i -cn effect -a minimal-effect.cpp "$TMP/effect.dsp" -o "$TMP/effect.h" || exit
114 rm "$TMP/effect.dsp"
115 else
116 faust -i -json -a $ARCHFILE $OPTIONS "$SRCDIR/$f" -o "$TMP/${f%.dsp}.cpp" || exit
117 faust -i -cn effect -a minimal-effect.cpp "$SRCDIR/$EFFECT" -o "$TMP/effect.h" || exit
118 fi
119 else
120 faust -i -json -a $ARCHFILE $OPTIONS "$SRCDIR/$f" -o "$TMP/${f%.dsp}.cpp" || exit
121 fi
122
123 # compile c++ to binary
124 $CXX $CXXFLAGS "$TMP/${f%.dsp}.cpp" $FAUSTTOOLSFLAGS $ARCHLIB $OSCDEFS $HTTPDEFS $HTTPLIBS $MIDIDEFS $POLYDEFS -o "${f%.dsp}" || exit
125 if [[ $(uname) == Darwin ]]; then
126 codesign --sign - --deep --force "${f%.dsp}"
127 fi
128 rm -rf "$TDR"
129
130 # collect binary file name for FaustGIDE
131 BINARIES="$BINARIES${f%.dsp}$EXT;"
132 done
133
134 echo $BINARIES
135