1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
|
#!/bin/bash -e
#####################################################################
# #
# faust2daisy generator #
# (c) Grame, 2020 #
# #
#####################################################################
. faustpath
. faustoptflags
. usage.sh
CXXFLAGS+=" $MYGCCFLAGS" # So that additional CXXFLAGS can be used
ARCHFILE=$FAUSTARCH/daisy/ex_faust.cpp
# exit if a command fails
set -e
# global option variables
NVOICES=0
MIDI=false
POLY=""
PATCH=false
POD=false
PATCHSM=false
USE_SDRAM=false
SR=44100
BS=16
SOURCE=false
echoHelp ()
{
echo "faust2daisy [-patch] [-midi] [-nvoices <num>] [-sr <num>] [-bs <num>] [-source] [Faust options (-vec -vs 8...)] <file.dsp>"
echo "Compiles Faust programs to Daisy boards (see https://github.com/grame-cncm/faust/tree/master-dev/architecture/daisy)"
option
option -patch "to compile for 4 ins/outs Patch (knob[1,2,3,4])"
option -pod "to compile for 2 ins/outs Pod (knob[1,3])"
option -patchsm "to compile for the Pod.init eurorack module"
option -sdram "to compile using SDRAM for long delay lines/tables etc."
options -midi
option "-nvoices <num>"
option "-sr <num>"
option "-bs <num>"
option -source
option "Faust options"
echo ""
exit
}
if [ "$#" -eq 0 ]; then
echo 'Please, provide a Faust file to process !'
echo ''
echoHelp
fi
###########################
# Processing Arguments
###########################
while [ $1 ]
do
p=$1
# help
if [ $p = "-help" ] || [ $p = "-h" ]; then
echoHelp
# -nvoices:
elif [ $p = "-nvoices" ]; then
shift
NVOICES=$1
# -midi
elif [ $p = "-midi" ]; then
MIDI=true
#patch
elif [ $p = "-patch" ]; then
PATCH=true
elif [ $p = "-pod" ]; then
POD=true
elif [ $p = "-patchsm" ]; then
PATCHSM=true
# -sdram
elif [ $p = "-sdram" ]; then
USE_SDRAM=true
# -sr
elif [ $p = "-sr" ]; then
shift
SR=$1
# -bs
elif [ $p = "-bs" ]; then
shift
BS=$1
# -source
elif [ $p = "-source" ]; then
SOURCE=true
elif [[ -f "$p" ]]; then
FILE="$p"
# other compile options
else
OPTIONS="$OPTIONS $p"
fi
shift
done
###########################
# Compile the *.dsp files
###########################
for p in $FILE; do
CUR=$(pwd)
f=$(basename "$p")
SRCDIR=$(dirname "$p")
# creates the dir
dspName="${f%.dsp}"
rm -rf "$SRCDIR/$dspName"
mkdir "$SRCDIR/$dspName"
# compile faust to c++
cp -r "$FAUSTARCH/daisy/Makefile" "$SRCDIR/$dspName/"
faust -i -a "$ARCHFILE" $OPTIONS "$f" -o "$SRCDIR/$dspName/ex_faust.cpp" || exit
# for PATCH support
if [ $PATCH == true ]; then
echo "#define PATCH" | cat - "$SRCDIR/$dspName/ex_faust.cpp" > temp && mv temp "$SRCDIR/$dspName/ex_faust.cpp"
fi
# for POD support
if [ $POD == true ]; then
echo "#define POD" | cat - "$SRCDIR/$dspName/ex_faust.cpp" > temp && mv temp "$SRCDIR/$dspName/ex_faust.cpp"
fi
# for PODSM support
if [ $PATCHSM == true ]; then
echo "#define PATCHSM" | cat - "$SRCDIR/$dspName/ex_faust.cpp" > temp && mv temp "$SRCDIR/$dspName/ex_faust.cpp"
fi
# for MIDI
if [ $MIDI == true ]; then
echo "#define MIDICTRL" | cat - "$SRCDIR/$dspName/ex_faust.cpp" > temp && mv temp "$SRCDIR/$dspName/ex_faust.cpp"
fi
# for Sample Rate
echo "#define MY_SAMPLE_RATE $SR" | cat - "$SRCDIR/$dspName/ex_faust.cpp" > temp && mv temp "$SRCDIR/$dspName/ex_faust.cpp"
# for Buffer Size
echo "#define MY_BUFFER_SIZE $BS" | cat - "$SRCDIR/$dspName/ex_faust.cpp" > temp && mv temp "$SRCDIR/$dspName/ex_faust.cpp"
# for DAISY_NO_RTTI preprocessor flag (to avoid dynamic casts since libdaisy is compiled with -fno-rtti flag)
echo "#define DAISY_NO_RTTI" | cat - "$SRCDIR/$dspName/ex_faust.cpp" > temp && mv temp "$SRCDIR/$dspName/ex_faust.cpp"
# for POLY
if [ "$NVOICES" -gt "0" ]; then
echo "#define POLY" | cat - "$SRCDIR/$dspName/ex_faust.cpp" > temp && mv temp "$SRCDIR/$dspName/ex_faust.cpp"
echo "#define NVOICES $NVOICES" | cat - "$SRCDIR/$dspName/ex_faust.cpp" > temp && mv temp "$SRCDIR/$dspName/ex_faust.cpp"
fi
if [ $USE_SDRAM == true ]; then
python3 "$FAUSTARCH/daisy/faust_sdram_converter.py" "$SRCDIR/$dspName/ex_faust.cpp"
fi
# compile and install plugin or keep the source folder
if [ $SOURCE == false ]; then
read -p "Press ENTER when Daisy is in DFU mode"
( cd "$SRCDIR/$dspName" && make && make program-dfu ) > /dev/null || exit
rm -rf "$SRCDIR/$dspName"
echo "Success !"
else
echo "Create the $SRCDIR/$dspName folder"
fi
done
|