Debian Codegraph @

tools/faust2appls/faust2jackconsole

raw symbols SCIP
1 #! /bin/bash -e
2
3 #####################################################################
4 # #
5 # Compiles Faust programs to JACK-console #
6 # (c) Grame, 2009-2025 #
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/jack-console.cpp
17
18 OSCDEFS=""
19 POLY="POLY"
20 NVOICES=-1
21 SOUNDFILE="0"
22 SOUNDFILEDEFS=""
23 SOUNDFILELIBS=""
24
25 # Check Darwin specifics
26 #
27 if [[ $(uname) == Darwin ]]; then
28 ARCHLIB+=" -framework CoreMIDI -framework CoreFoundation -framework CoreAudio -framework AudioUnit -framework CoreServices"
29 else
30 ARCHLIB+=" `pkg-config --cflags --libs alsa`"
31 fi
32
33 echoHelp()
34 {
35 usage faust2jackconsole "[options] [Faust options] <file.dsp>"
36 require Jack
37 echo "Compiles Faust programs to CLI and JACK"
38 option
39 options -httpd -osc -midi -soundfile
40 option "-nvoices <num>"
41 option "-effect <effect.dsp>"
42 option "-effect auto"
43 option "Faust options"
44 exit
45 }
46
47 if [ "$#" -eq 0 ]; then
48 echo 'Please, provide a Faust file to process !'
49 echo ''
50 echoHelp
51 fi
52
53 #-------------------------------------------------------------------
54 # Analyze command arguments :
55 # faust options -> OPTIONS
56 # if -omp : -openmp or -fopenmp -> OPENMP
57 # existing *.dsp files -> FILES
58 #
59
60 # dispatch command arguments
61 while [ $1 ]
62 do
63 p=$1
64
65 if [ $p = "-help" ] || [ $p = "-h" ]; then
66 echoHelp
67 elif [ $p = "-osc" ]; then
68 OSCDEFS="-DOSCCTRL -lOSCFaust"
69 elif [ $p = "-httpd" ]; then
70 HTTPDEFS="-DHTTPCTRL -lHTTPDFaust"
71 HTTPLIBS=`pkg-config --cflags --libs libmicrohttpd`
72 elif [ $p = "-nvoices" ]; then
73 POLYDEFS="-DPOLY"
74 shift
75 NVOICES=$1
76 if [ $NVOICES -ge 0 ]; then
77 CXXFLAGS="$CXXFLAGS -DNVOICES=$NVOICES"
78 fi
79 elif [ $p = "-effect" ]; then
80 POLYDEFS="-DPOLY2"
81 POLY="POLY2"
82 shift
83 EFFECT=$1
84 elif [ $p = "-midi" ]; then
85 MIDIDEFS="-DMIDICTRL"
86 elif [ $p = "-soundfile" ]; then
87 SOUNDFILE="1"
88 SOUNDFILEDEFS="-DSOUNDFILE"
89 SOUNDFILELIBS=`pkg-config --cflags --static --libs sndfile`
90 elif [ $p = "-arch32" ]; then
91 PROCARCH="-m32 -L/usr/lib32"
92 elif [ $p = "-arch64" ]; then
93 PROCARCH="-m64"
94 elif [ ${p:0:1} = "-" ]; then
95 OPTIONS="$OPTIONS $p"
96 elif [[ -f "$p" ]] && [ ${p: -4} == ".dsp" ]; then
97 FILES="$FILES $p"
98 else
99 OPTIONS="$OPTIONS $p"
100 fi
101
102 shift
103
104 done
105
106 #-------------------------------------------------------------------
107 # compile the *.dsp files using JACK and console
108 #
109 for f in $FILES; do
110
111 # compile faust to c++
112 if [ $POLY = "POLY2" ]; then
113 if [ $EFFECT = "auto" ]; then
114 cat > effect.dsp << EndOfCode
115 adapt(1,1) = _;
116 adapt(2,2) = _,_;
117 adapt(1,2) = _ <: _,_;
118 adapt(2,1) = _,_ :> _;
119 adaptor(F,G) = adapt(outputs(F),inputs(G));
120 process = adaptor(library("$f").process, library("$f").effect) : library("$f").effect;
121 EndOfCode
122 faust -i -json -a $ARCHFILE $OPTIONS "$f" -o "$f.cpp" || exit
123 faust -i -cn effect -a minimal-effect.cpp effect.dsp -o effect.h || exit
124 rm effect.dsp
125 else
126 faust -i -json -a $ARCHFILE $OPTIONS "$f" -o "$f.cpp" || exit
127 faust -i -cn effect -a minimal-effect.cpp "$EFFECT" -o "effect.h" || exit
128 fi
129 else
130 faust -i -a $ARCHFILE $OPTIONS "$f" -o "$f.cpp"|| exit
131 fi
132
133 # compile c++ to binary
134 (
135 $CXX $CXXFLAGS $FAUSTTOOLSFLAGS "$f.cpp" -I/usr/local/include -L/usr/local/lib `pkg-config --cflags --libs jack` $PROCARCH $SOUNDFILELIBS $OSCDEFS $HTTPDEFS $HTTPLIBS $MIDIDEFS $POLYDEFS $SOUNDFILEDEFS $ARCHLIB -ldl -pthread -o "${f%.dsp}"
136 if [[ $(uname) == Darwin ]]; then
137 codesign --sign - --deep --force "${f%.dsp}"
138 fi
139 ) > /dev/null || exit
140
141 # remove temporary files
142 rm -f "$f.cpp" effect.h "$f.json"
143
144 # collect binary file name for FaustWorks
145 BINARIES="$BINARIES${f%.dsp};"
146 done
147
148 echo $BINARIES