From cf5d1295878777bdd635f1cd132d863d96e40585 Mon Sep 17 00:00:00 2001 From: Stephane Letz Date: Wed, 22 May 2024 18:50:53 +0200 Subject: [PATCH] Tab/space formatting. --- architecture/stratus.cpp | 594 ++++++++++++++++---------------- tools/faust2appls/faust2stratus | 258 +++++++------- 2 files changed, 426 insertions(+), 426 deletions(-) diff --git a/architecture/stratus.cpp b/architecture/stratus.cpp index 4dbc3b8e3f..9c9f349771 100644 --- a/architecture/stratus.cpp +++ b/architecture/stratus.cpp @@ -59,21 +59,21 @@ typedef unsigned int Uint; // class Meta { - protected: - std::string effectName; - std::string effectId; - std::string version; - public: - void declare(const char* key, const char* value) { - if (strcmp(key,NAME_KEY) == 0) { - effectName.assign(value); - } else if (strcmp(key,STRATUS_ID_KEY) == 0) { - effectId.assign(value); - } else if (strcmp(key,VERSION_KEY) == 0) { - version.assign(value); - } - } - friend class STRATUS_CLASS; + protected: + std::string effectName; + std::string effectId; + std::string version; + public: + void declare(const char* key, const char* value) { + if (strcmp(key,NAME_KEY) == 0) { + effectName.assign(value); + } else if (strcmp(key,STRATUS_ID_KEY) == 0) { + effectId.assign(value); + } else if (strcmp(key,VERSION_KEY) == 0) { + version.assign(value); + } + } + friend class STRATUS_CLASS; }; // @@ -82,159 +82,159 @@ class Meta // algorithm // class UiControlSet { - // - // The maximum number of items in the set (MAXKNOBS or MAXSWITCHES) - // - Uint max; - - // - // Controls with ordering metadata get set immediately - // unordered stuff is inserted afterwards! - // - FAUSTFLOAT** controlValues; - Uint controlCount = 0; - - // - // Add a control to the set - // - // if the provided index is equal to or greater than 0, and less than the - // max value for the set, AND it's indicated slot NULL, we set that slot and - // increment the number that we have set. - // - // Otherwise, the control is ignored - // - void add_control(FAUSTFLOAT* control, int index) { - if (index >= 0 && index < max && controlValues[index] == nullptr) { - controlValues[index] = control; - controlCount++; - } - } - - // - // Return a value if the index is valid and the pointer in that slot - // is valid - // - FAUSTFLOAT getValue(Uint i) { - return (i < max && controlValues[i] != nullptr) ? *(controlValues[i]) : 0; - } - - // - // Set a value if the index is valid and the pointer in that slot - // is valid - // - void setValue(Uint i, FAUSTFLOAT value) { - if (i < max && controlValues[i] != nullptr) *(controlValues[i]) = value; - } - - UiControlSet(Uint max) { - this->max = max; - controlValues = new FAUSTFLOAT*[max]; - for (int i = 0; i < max; ++i) { - controlValues[i] = nullptr; - } - } - - ~UiControlSet() { - delete[] controlValues; - } - - friend class UI; - friend class STRATUS_CLASS; + // + // The maximum number of items in the set (MAXKNOBS or MAXSWITCHES) + // + Uint max; + + // + // Controls with ordering metadata get set immediately + // unordered stuff is inserted afterwards! + // + FAUSTFLOAT** controlValues; + Uint controlCount = 0; + + // + // Add a control to the set + // + // if the provided index is equal to or greater than 0, and less than the + // max value for the set, AND it's indicated slot NULL, we set that slot and + // increment the number that we have set. + // + // Otherwise, the control is ignored + // + void add_control(FAUSTFLOAT* control, int index) { + if (index >= 0 && index < max && controlValues[index] == nullptr) { + controlValues[index] = control; + controlCount++; + } + } + + // + // Return a value if the index is valid and the pointer in that slot + // is valid + // + FAUSTFLOAT getValue(Uint i) { + return (i < max && controlValues[i] != nullptr) ? *(controlValues[i]) : 0; + } + + // + // Set a value if the index is valid and the pointer in that slot + // is valid + // + void setValue(Uint i, FAUSTFLOAT value) { + if (i < max && controlValues[i] != nullptr) *(controlValues[i]) = value; + } + + UiControlSet(Uint max) { + this->max = max; + controlValues = new FAUSTFLOAT*[max]; + for (int i = 0; i < max; ++i) { + controlValues[i] = nullptr; + } + } + + ~UiControlSet() { + delete[] controlValues; + } + + friend class UI; + friend class STRATUS_CLASS; }; class UI { - int nextIndex = -1; - FAUSTFLOAT* nextControl = nullptr; - - void add_knob(FAUSTFLOAT* slider) { - if (slider == nextControl) { - knobs->add_control(slider, nextIndex); - } - } - - void add_switch(FAUSTFLOAT* swtch) { - if (swtch == nextControl) { - switches->add_control(swtch, nextIndex); - } - } - - void reset_declare_state() { - nextIndex = -1; - nextControl = nullptr; - } - - protected: - UiControlSet* knobs; - UiControlSet* switches; - - UI() { - knobs = new UiControlSet(MAXKNOBS); - switches = new UiControlSet(MAXSWITCHES); - reset_declare_state(); - } - ~UI(); - - Uint getKnobCount() { - return knobs->controlCount; - } - - Uint getSwitchCount() { - return switches->controlCount; - } - - public: - void openTabBox(const char* label) {}; - void openHorizontalBox(const char* label) {}; - void openVerticalBox(const char* label) {}; - void closeBox() {}; - void addSoundfile(const char* label, const char* filename, void** sf_zone) {}; - - void addButton(const char* label, FAUSTFLOAT* zone) { - this->add_switch(zone); - reset_declare_state(); - }; - void addCheckButton(const char* label, FAUSTFLOAT* zone) { - this->add_switch(zone); - reset_declare_state(); - }; - void addVerticalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { -// printf("VSLIDER: %s %p %f %f %f %f\n",label,zone,init,min,max,step); - this->add_knob(zone); - reset_declare_state(); - }; - void addHorizontalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { -// printf("HSLIDER: %s %p %f %f %f %f\n",label,zone,init,min,max,step); - this->add_knob(zone); - reset_declare_state(); - }; - void addNumEntry(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { - FAUSTFLOAT steps = (max - min)/step; - if (min == 0 && (max == 1 || max == 2) && step == 1) { - this->add_switch(zone); - } - reset_declare_state(); - }; - void addHorizontalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) { - reset_declare_state(); - }; - void addVerticalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) { - reset_declare_state(); - }; - - // - // The "declare" state machine! - // - // We look for the "stratus" key and a single decimal digit as the value - // - void declare(FAUSTFLOAT* control, const char* key, const char* val) { - if (control != nullptr && strcmp("stratus",key) == 0 && strlen(val) == 1 && val[0] >= '0' && val[0] <= '9') { - nextControl = control; - nextIndex = val[0] - '0'; - } - } - - friend class STRATUS_CLASS; - friend class StratusExtensions; + int nextIndex = -1; + FAUSTFLOAT* nextControl = nullptr; + + void add_knob(FAUSTFLOAT* slider) { + if (slider == nextControl) { + knobs->add_control(slider, nextIndex); + } + } + + void add_switch(FAUSTFLOAT* swtch) { + if (swtch == nextControl) { + switches->add_control(swtch, nextIndex); + } + } + + void reset_declare_state() { + nextIndex = -1; + nextControl = nullptr; + } + + protected: + UiControlSet* knobs; + UiControlSet* switches; + + UI() { + knobs = new UiControlSet(MAXKNOBS); + switches = new UiControlSet(MAXSWITCHES); + reset_declare_state(); + } + ~UI(); + + Uint getKnobCount() { + return knobs->controlCount; + } + + Uint getSwitchCount() { + return switches->controlCount; + } + + public: + void openTabBox(const char* label) {}; + void openHorizontalBox(const char* label) {}; + void openVerticalBox(const char* label) {}; + void closeBox() {}; + void addSoundfile(const char* label, const char* filename, void** sf_zone) {}; + + void addButton(const char* label, FAUSTFLOAT* zone) { + this->add_switch(zone); + reset_declare_state(); + }; + void addCheckButton(const char* label, FAUSTFLOAT* zone) { + this->add_switch(zone); + reset_declare_state(); + }; + void addVerticalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { +// printf("VSLIDER: %s %p %f %f %f %f\n",label,zone,init,min,max,step); + this->add_knob(zone); + reset_declare_state(); + }; + void addHorizontalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { +// printf("HSLIDER: %s %p %f %f %f %f\n",label,zone,init,min,max,step); + this->add_knob(zone); + reset_declare_state(); + }; + void addNumEntry(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { + FAUSTFLOAT steps = (max - min)/step; + if (min == 0 && (max == 1 || max == 2) && step == 1) { + this->add_switch(zone); + } + reset_declare_state(); + }; + void addHorizontalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) { + reset_declare_state(); + }; + void addVerticalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) { + reset_declare_state(); + }; + + // + // The "declare" state machine! + // + // We look for the "stratus" key and a single decimal digit as the value + // + void declare(FAUSTFLOAT* control, const char* key, const char* val) { + if (control != nullptr && strcmp("stratus",key) == 0 && strlen(val) == 1 && val[0] >= '0' && val[0] <= '9') { + nextControl = control; + nextIndex = val[0] - '0'; + } + } + + friend class STRATUS_CLASS; + friend class StratusExtensions; }; /****************************************************************************** @@ -268,108 +268,108 @@ class UI { // class STRATUS_CLASS { - int fSampleRate = 44100; - enum SWITCH_STATE - { - UP = 0, - DOWN = 1, - MIDDLE = 2 - }; - - // Use for switch debugging - void getTextForEnum(SWITCH_STATE enumVal, std::string *out) { - switch (enumVal) { - case 0: *out = "UP"; - case 1: *out = "DOWN"; - case 2: *out = "MIDDLE"; - default: *out = "BAD"; - } - return; - } - - SWITCH_STATE stompSwitch; - std::string effectName; - std::string effectId; - std::string version; - FAUSTCLASS* faust; - - protected: - UI* faustUi; - Meta* faustMeta; - - static SWITCH_STATE switchStateFromValue(int value) { - switch (value) { - case 0: return SWITCH_STATE::UP; - case 1: return SWITCH_STATE::DOWN; - case 2: return SWITCH_STATE::MIDDLE; - default: return SWITCH_STATE::DOWN; - } - } - - public: - STRATUS_CLASS() - { - faustMeta = new Meta; - faust = new FAUSTCLASS; - faust->metadata(faustMeta); - effectId = faustMeta->effectId; - effectName = faustMeta->effectName; - version = faustMeta->version; - - faust->init(fSampleRate); - - faustUi = new UI; - faust->buildUserInterface(faustUi); - - stompSwitch = DOWN; - } - ~STRATUS_CLASS() {} - - STRATUS_API void setKnob(int num, float knobVal) - { - this->faustUi->knobs->setValue(num, knobVal); - } - - STRATUS_API float getKnob(int in) - { - return this->faustUi->knobs->getValue(in); - } - - STRATUS_API void setSwitch(int num, SWITCH_STATE switchVal) - { - this->faustUi->switches->setValue(num, switchVal); - } - - STRATUS_API SWITCH_STATE getSwitch(int in) - { - Uint switchVal = this->faustUi->switches->getValue(in); - return switchStateFromValue(switchVal < 3 ? switchVal : 0); - } - - STRATUS_API void setStompSwitch(SWITCH_STATE switchVal) - { - stompSwitch = switchVal; - } - - STRATUS_API bool getStompSwitch() - { - return stompSwitch; - } - - STRATUS_API void stompSwitchPressed(int count, FAUSTFLOAT *inputs, FAUSTFLOAT *outputs) - { - if (stompSwitch) - { - compute(count, inputs, outputs); - } - return; - } - - STRATUS_API void compute(int count, FAUSTFLOAT *inputs, FAUSTFLOAT *outputs) { - this->faust->compute(count,&inputs,&outputs); - } - - friend class StratusExtensions; + int fSampleRate = 44100; + enum SWITCH_STATE + { + UP = 0, + DOWN = 1, + MIDDLE = 2 + }; + + // Use for switch debugging + void getTextForEnum(SWITCH_STATE enumVal, std::string *out) { + switch (enumVal) { + case 0: *out = "UP"; + case 1: *out = "DOWN"; + case 2: *out = "MIDDLE"; + default: *out = "BAD"; + } + return; + } + + SWITCH_STATE stompSwitch; + std::string effectName; + std::string effectId; + std::string version; + FAUSTCLASS* faust; + + protected: + UI* faustUi; + Meta* faustMeta; + + static SWITCH_STATE switchStateFromValue(int value) { + switch (value) { + case 0: return SWITCH_STATE::UP; + case 1: return SWITCH_STATE::DOWN; + case 2: return SWITCH_STATE::MIDDLE; + default: return SWITCH_STATE::DOWN; + } + } + + public: + STRATUS_CLASS() + { + faustMeta = new Meta; + faust = new FAUSTCLASS; + faust->metadata(faustMeta); + effectId = faustMeta->effectId; + effectName = faustMeta->effectName; + version = faustMeta->version; + + faust->init(fSampleRate); + + faustUi = new UI; + faust->buildUserInterface(faustUi); + + stompSwitch = DOWN; + } + ~STRATUS_CLASS() {} + + STRATUS_API void setKnob(int num, float knobVal) + { + this->faustUi->knobs->setValue(num, knobVal); + } + + STRATUS_API float getKnob(int in) + { + return this->faustUi->knobs->getValue(in); + } + + STRATUS_API void setSwitch(int num, SWITCH_STATE switchVal) + { + this->faustUi->switches->setValue(num, switchVal); + } + + STRATUS_API SWITCH_STATE getSwitch(int in) + { + Uint switchVal = this->faustUi->switches->getValue(in); + return switchStateFromValue(switchVal < 3 ? switchVal : 0); + } + + STRATUS_API void setStompSwitch(SWITCH_STATE switchVal) + { + stompSwitch = switchVal; + } + + STRATUS_API bool getStompSwitch() + { + return stompSwitch; + } + + STRATUS_API void stompSwitchPressed(int count, FAUSTFLOAT *inputs, FAUSTFLOAT *outputs) + { + if (stompSwitch) + { + compute(count, inputs, outputs); + } + return; + } + + STRATUS_API void compute(int count, FAUSTFLOAT *inputs, FAUSTFLOAT *outputs) { + this->faust->compute(count,&inputs,&outputs); + } + + friend class StratusExtensions; }; // @@ -382,39 +382,39 @@ class STRATUS_CLASS // via a new C language function. // class StratusExtensions { - private: - STRATUS_CLASS* effect; - public: - StratusExtensions(STRATUS_CLASS* eff){ - effect = eff; - } - STRATUS_API const char* getName() - { - return this->effect->effectName.c_str(); - } - - STRATUS_API const char* getEffectId() - { - return this->effect->effectId.c_str(); - } - - STRATUS_API const char * getVersion() - { - return this->effect->version.c_str(); - } - - STRATUS_API Uint getKnobCount() { - return this->effect->faustUi->getKnobCount(); - } - - STRATUS_API Uint getSwitchCount() { - return this->effect->faustUi->getSwitchCount(); - } + private: + STRATUS_CLASS* effect; + public: + StratusExtensions(STRATUS_CLASS* eff){ + effect = eff; + } + STRATUS_API const char* getName() + { + return this->effect->effectName.c_str(); + } + + STRATUS_API const char* getEffectId() + { + return this->effect->effectId.c_str(); + } + + STRATUS_API const char * getVersion() + { + return this->effect->version.c_str(); + } + + STRATUS_API Uint getKnobCount() { + return this->effect->faustUi->getKnobCount(); + } + + STRATUS_API Uint getSwitchCount() { + return this->effect->faustUi->getSwitchCount(); + } }; extern "C" { - STRATUS_CLASS* create() {return new STRATUS_CLASS;} - StratusExtensions* getExtensions(STRATUS_CLASS* effect) {return new StratusExtensions(effect);} + STRATUS_CLASS* create() {return new STRATUS_CLASS;} + StratusExtensions* getExtensions(STRATUS_CLASS* effect) {return new StratusExtensions(effect);} } using dsp_creator_t = STRATUS_CLASS *(*)(); diff --git a/tools/faust2appls/faust2stratus b/tools/faust2appls/faust2stratus index 5fbd7f3f01..ef5d973ee8 100755 --- a/tools/faust2appls/faust2stratus +++ b/tools/faust2appls/faust2stratus @@ -57,21 +57,21 @@ STRATUS_CONNECTED= # only ask for the root password once) # connectStratus() { - [[ "$STRATUS_CONNECTED" == "true" ]] && return 0 + [[ "$STRATUS_CONNECTED" == "true" ]] && return 0 - SSH_CFG=$TMP_DIR/ssh-cfg - SSH_SOCKET=$TMP_DIR/ssh-socket + SSH_CFG=$TMP_DIR/ssh-cfg + SSH_SOCKET=$TMP_DIR/ssh-socket - # Create a temporary SSH config file: - cat > "$SSH_CFG" < "$SSH_CFG" < "\${EFFECT_PATH}.txt" && chown update:sftponly "\${EFFECT_PATH}.txt" + EFFECT_PATH="${STRATUS_EFFECTS_DIR}/${EFFECT_ID}" + echo "INSTALLING EFFECT AS: \${EFFECT_PATH}.so" + [[ -e "\${EFFECT_PATH}.so" ]] && cp "\${EFFECT_PATH}.so" "/tmp/${EFFECT_SO_NAME}.so.${BACKUP_SUFFIX}" + chown update:sftponly "/tmp/$EFFECT_SO_NAME" + cp -p "/tmp/$EFFECT_SO_NAME" "\${EFFECT_PATH}.so" + [[ "$EFFECT_VERSION" ]] && echo -n "$EFFECT_VERSION" > "\${EFFECT_PATH}.txt" && chown update:sftponly "\${EFFECT_PATH}.txt" else - echo "Not installing $EFFECT_SO_NAME - no effect ID found, or install not requested" + echo "Not installing $EFFECT_SO_NAME - no effect ID found, or install not requested" fi echo Build of $EFFECT_CPP_NAME succeeded ENDSSH RC=$? - # Download so - scp -F "$SSH_CFG" "$STRATUS_USER@$STRATUS_ADDR:/tmp/$EFFECT_SO_NAME" "${EFFECT_SO}" - return $RC + # Download so + scp -F "$SSH_CFG" "$STRATUS_USER@$STRATUS_ADDR:/tmp/$EFFECT_SO_NAME" "${EFFECT_SO}" + return $RC } #------------------------------------------------------------------- @@ -122,46 +122,46 @@ RC=$? # Build locally (which might still be the Stratus)! # localCompile() { - local EFFECT_CPP="$1" - local EFFECT_SO="$2" - local EFFECT_ID="$3" - local EFFECT_VERSION="$4" - local BACKUP_SUFFIX=$(date +%Y-%m-%dT%H-%M-%S) + local EFFECT_CPP="$1" + local EFFECT_SO="$2" + local EFFECT_ID="$3" + local EFFECT_VERSION="$4" + local BACKUP_SUFFIX=$(date +%Y-%m-%dT%H-%M-%S) ( - echo " $CXX options : $CXXFLAGS $LOCAL_GCCFLAGS $EFFECT_CPP -o $EFFECT_SO" - - $CXX $CXXFLAGS $LOCAL_GCCFLAGS "$EFFECT_CPP" -o "$EFFECT_SO" - RC=$? - if [[ $RC -eq 0 && $(uname) == Darwin ]]; then - codesign --sign - --deep --force "$EFFECT_SO" - RC=$? - fi - exit $RC + echo " $CXX options : $CXXFLAGS $LOCAL_GCCFLAGS $EFFECT_CPP -o $EFFECT_SO" + + $CXX $CXXFLAGS $LOCAL_GCCFLAGS "$EFFECT_CPP" -o "$EFFECT_SO" + RC=$? + if [[ $RC -eq 0 && $(uname) == Darwin ]]; then + codesign --sign - --deep --force "$EFFECT_SO" + RC=$? + fi + exit $RC ) > /dev/null || exit - if [[ "$STRATUSINSTALL" == "true" && "$HOSTNAME" == "stratus" && "$EFFECT_ID" ]]; then - # Install the effect if it has a stratusId global declaration - SO_FILE="${STRATUS_EFFECTS_DIR}/${EFFECT_ID}.so" - VER_FILE="${STRATUS_EFFECTS_DIR}/${EFFECT_ID}.txt" - BACKUP_SUFFIX=$(date +%Y-%m-%dT%H-%M-%S) - [[ -f "${SO_FILE}" ]] && cp "$SO_FILE" /tmp/${EFFECT_ID}.so.${BACKUP_SUFFIX} - chown update:sftponly "/tmp/$EFFECT_SO" - cp -p "$EFFECT_SO" "${SO_FILE}" || { echo "failed to install $EFFECT_SO as $SO_FILE"; exit 1; } - echo "Effect $EFFECT_SO installed as $SO_FILE" - if [[ "$STRATUS_VERSION" ]]; then - [[ -f "${VER_FILE}" ]] && cp "$VER_FILE" /$HOME/${EFFECT_ID}.txt.${BACKUP_SUFFIX} - echo -n "$STRATUS_VERSION" > "$VER_FILE" - chown update:sftponly "VER_FILE" - echo "Effect $EFFECT_SO version set to $STRATUS_VERSION" - else - echo "Unable to set version of $SO_FILE - no version declaration found in the DSP file" - fi - else - [[ "$HOSTNAME" == "stratus" ]] && echo "NOT installing effect $EFFECT_SO into Stratus effect folder $STRATUS_EFFECTS_DIR" - fi - echo "$EFFECT_SO successfully built" - return 0 + if [[ "$STRATUSINSTALL" == "true" && "$HOSTNAME" == "stratus" && "$EFFECT_ID" ]]; then + # Install the effect if it has a stratusId global declaration + SO_FILE="${STRATUS_EFFECTS_DIR}/${EFFECT_ID}.so" + VER_FILE="${STRATUS_EFFECTS_DIR}/${EFFECT_ID}.txt" + BACKUP_SUFFIX=$(date +%Y-%m-%dT%H-%M-%S) + [[ -f "${SO_FILE}" ]] && cp "$SO_FILE" /tmp/${EFFECT_ID}.so.${BACKUP_SUFFIX} + chown update:sftponly "/tmp/$EFFECT_SO" + cp -p "$EFFECT_SO" "${SO_FILE}" || { echo "failed to install $EFFECT_SO as $SO_FILE"; exit 1; } + echo "Effect $EFFECT_SO installed as $SO_FILE" + if [[ "$STRATUS_VERSION" ]]; then + [[ -f "${VER_FILE}" ]] && cp "$VER_FILE" /$HOME/${EFFECT_ID}.txt.${BACKUP_SUFFIX} + echo -n "$STRATUS_VERSION" > "$VER_FILE" + chown update:sftponly "VER_FILE" + echo "Effect $EFFECT_SO version set to $STRATUS_VERSION" + else + echo "Unable to set version of $SO_FILE - no version declaration found in the DSP file" + fi + else + [[ "$HOSTNAME" == "stratus" ]] && echo "NOT installing effect $EFFECT_SO into Stratus effect folder $STRATUS_EFFECTS_DIR" + fi + echo "$EFFECT_SO successfully built" + return 0 } #------------------------------------------------------------------- @@ -200,10 +200,10 @@ LOCAL_GCCFLAGS="-fPIC -shared -O3" # Supporting various compile platforms - but, obviously, the first is the most important # if [ "$(uname -m)" = armv7l ]; then # for the Stratus - LOCAL_GCCFLAGS=" $STRATUS_GCC_FLAGS" + LOCAL_GCCFLAGS=" $STRATUS_GCC_FLAGS" elif [ "$(uname -s)" = Darwin ]; then # for macOS if [[ $(sysctl -n machdep.cpu.brand_string) =~ "Apple" ]]; then - true + true else # Intel LOCAL_GCCFLAGS+=" -march=native" @@ -219,27 +219,27 @@ fi OPTIONS="-scn FaustDSP -light -nvi" STRATUSCLASS=dsp while [[ "$1" ]]; do - opt=$1 - shift + opt=$1 + shift if [[ "$opt" =~ ^--?"help"$ || $opt == "-h" ]]; then echoHelp - elif [[ "$opt" =~ ^--?"stratusc"$ ]]; then - # Ignore obsolete option - true - elif [[ "$opt" =~ ^--?"stratusinstall"$ ]]; then - STRATUSINSTALL="true" - elif [[ "$opt" =~ ^--?"nocppc"$ ]]; then - CPPCOMPILE="false" - elif [[ "$opt" =~ ^--?"stratusclass"$ ]]; then - STRATUSCLASS=${1:-dsp} - shift - elif [[ "$opt" =~ ^--?"a"$ ]]; then - # - # Used to test other versions of the Stratus arch file! - # - ARCHFILE=${1:-stratus.cpp} - shift - elif [[ -f "$opt" && ${opt: -4} == ".dsp" ]]; then + elif [[ "$opt" =~ ^--?"stratusc"$ ]]; then + # Ignore obsolete option + true + elif [[ "$opt" =~ ^--?"stratusinstall"$ ]]; then + STRATUSINSTALL="true" + elif [[ "$opt" =~ ^--?"nocppc"$ ]]; then + CPPCOMPILE="false" + elif [[ "$opt" =~ ^--?"stratusclass"$ ]]; then + STRATUSCLASS=${1:-dsp} + shift + elif [[ "$opt" =~ ^--?"a"$ ]]; then + # + # Used to test other versions of the Stratus arch file! + # + ARCHFILE=${1:-stratus.cpp} + shift + elif [[ -f "$opt" && ${opt: -4} == ".dsp" ]]; then FILES="$FILES $opt" else OPTIONS="$OPTIONS $opt" @@ -251,50 +251,50 @@ done # MYPWD=$PWD for f in $FILES; do - EFFECT=$(realpath "$f") - - EFFECT_DIR="$(dirname "$EFFECT")" - cd $EFFECT_DIR - EFFECT_FILENAME="$(basename "$EFFECT")" - EFFECT_STEM="${EFFECT_FILENAME%%.*}" - EFFECT_CPP="$EFFECT_DIR/$EFFECT_STEM.cpp" - EFFECT_SO="$EFFECT_DIR/$EFFECT_STEM.so" + EFFECT=$(realpath "$f") + + EFFECT_DIR="$(dirname "$EFFECT")" + cd $EFFECT_DIR + EFFECT_FILENAME="$(basename "$EFFECT")" + EFFECT_STEM="${EFFECT_FILENAME%%.*}" + EFFECT_CPP="$EFFECT_DIR/$EFFECT_STEM.cpp" + EFFECT_SO="$EFFECT_DIR/$EFFECT_STEM.so" - # compile faust to c++ - echo "Building effect $EFFECT:" >&2 - echo " Faust options: -i -a $ARCHFILE $OPTIONS $EFFECT -o $EFFECT_CPP" + # compile faust to c++ + echo "Building effect $EFFECT:" >&2 + echo " Faust options: -i -a $ARCHFILE $OPTIONS $EFFECT -o $EFFECT_CPP" faust -i -a $ARCHFILE $OPTIONS "$EFFECT" -o "$EFFECT_CPP" || exit - if [[ "$CPPCOMPILE" == true ]]; then - - if [[ "$STRATUSINSTALL" == true ]]; then - EFFECT_ID=$(sed -n 's/\s*declare\s\s*stratusId\s\s*"\([0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}\)";/\1/p' "${EFFECT}") - EFFECT_VERSION=$(sed -n 's/\s*declare\s\s*version\s\s*"\([^"]*\)";/\1/p' "${EFFECT}") - fi - - # - # We are supposed to compile - but what is our context? - # - - # - # If we are on the Stratus, or we are NOT supposed to install, then it's simply a local compile - # - if [[ "$HOSTNAME" == "stratus" || "$STRATUSINSTALL" != "true" ]]; then - if [[ "$LOCAL_CPPCOMPILE" == "true" ]]; then - localCompile "$EFFECT_CPP" "$EFFECT_SO" "$EFFECT_ID" "$EFFECT_VERSION" || { echo "Local build failed"; exit 1; } - else - echo "NOT CPP compiling $EFFECT_CPP (no CPP compiler found)" - fi - else - # - # We are not on the Stratus and we are expected to install - so we BUILD on the stratus - # - buildOnStratus "$EFFECT_CPP" "$EFFECT_SO" "$EFFECT_ID" "$EFFECT_VERSION" || { echo "Install to stratus failed"; exit 1; } - fi - else - echo "NOT CPP compiling $EFFECT_CPP (-nocppc specified)" - fi - cd $MYPWD + if [[ "$CPPCOMPILE" == true ]]; then + + if [[ "$STRATUSINSTALL" == true ]]; then + EFFECT_ID=$(sed -n 's/\s*declare\s\s*stratusId\s\s*"\([0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}\)";/\1/p' "${EFFECT}") + EFFECT_VERSION=$(sed -n 's/\s*declare\s\s*version\s\s*"\([^"]*\)";/\1/p' "${EFFECT}") + fi + + # + # We are supposed to compile - but what is our context? + # + + # + # If we are on the Stratus, or we are NOT supposed to install, then it's simply a local compile + # + if [[ "$HOSTNAME" == "stratus" || "$STRATUSINSTALL" != "true" ]]; then + if [[ "$LOCAL_CPPCOMPILE" == "true" ]]; then + localCompile "$EFFECT_CPP" "$EFFECT_SO" "$EFFECT_ID" "$EFFECT_VERSION" || { echo "Local build failed"; exit 1; } + else + echo "NOT CPP compiling $EFFECT_CPP (no CPP compiler found)" + fi + else + # + # We are not on the Stratus and we are expected to install - so we BUILD on the stratus + # + buildOnStratus "$EFFECT_CPP" "$EFFECT_SO" "$EFFECT_ID" "$EFFECT_VERSION" || { echo "Install to stratus failed"; exit 1; } + fi + else + echo "NOT CPP compiling $EFFECT_CPP (-nocppc specified)" + fi + cd $MYPWD done