diff -Nru faust-2.50.6+ds0/appveyor.yml faust-2.54.9+ds0/appveyor.yml
--- faust-2.50.6+ds0/appveyor.yml 2022-10-02 14:11:18.000000000 +0000
+++ faust-2.54.9+ds0/appveyor.yml 2022-12-17 10:41:42.000000000 +0000
@@ -7,7 +7,7 @@
- cd build
- mkdir win64
- cd win64
- - cmake -C ../backends/regular.cmake -C ../targets/regular.cmake .. -G "Visual Studio 15 2017 Win64"
+ - cmake -C ../backends/regular.cmake -C ../targets/regular.cmake .. -G "Visual Studio 16 2019" -A x64
- cmake --build . --config Release
- ls -l ../bin/Release
diff -Nru faust-2.50.6+ds0/architecture/android/app/build.gradle faust-2.54.9+ds0/architecture/android/app/build.gradle
--- faust-2.50.6+ds0/architecture/android/app/build.gradle 2022-10-02 14:11:18.000000000 +0000
+++ faust-2.54.9+ds0/architecture/android/app/build.gradle 2022-12-17 10:41:42.000000000 +0000
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 30
+ compileSdkVersion 33
defaultConfig {
applicationId "com.faust"
minSdkVersion 16
- targetSdkVersion 30
- versionCode 1
- versionName "1.0"
+ targetSdkVersion 33
+ versionCode 205
+ versionName "1.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
diff -Nru faust-2.50.6+ds0/architecture/android/app/src/main/AndroidManifest.xml faust-2.54.9+ds0/architecture/android/app/src/main/AndroidManifest.xml
--- faust-2.50.6+ds0/architecture/android/app/src/main/AndroidManifest.xml 2022-10-02 14:11:18.000000000 +0000
+++ faust-2.54.9+ds0/architecture/android/app/src/main/AndroidManifest.xml 2022-12-17 10:41:42.000000000 +0000
@@ -18,16 +18,17 @@
-
getNumTouches() > 0)
- val = sensor->compoundTouchLocation();
+ if (fSensor && fSensor->getNumTouches() > 0)
+ val = fSensor->compoundTouchLocation();
*fZone = fMin + fRange * val;
break;
@@ -680,8 +782,8 @@
case kBAR_LVL_5:
case kBAR_LVL_6:
case kBAR_LVL_7:
- if (sensor && sensor->getNumTouches() > 0)
- val = sensor->compoundTouchSize();
+ if (fSensor && fSensor->getNumTouches() > 0)
+ val = fSensor->compoundTouchSize();
*fZone = fMin + fRange * val;
break;
@@ -693,9 +795,9 @@
case kBAR_TOUCH_5:
case kBAR_TOUCH_6:
case kBAR_TOUCH_7:
- if (sensor)
- val = sensor->getNumTouches();
- *fZone = max(fRange,val);
+ if (fSensor)
+ val = fSensor->getNumTouches();
+ *fZone = min(fRange,val);
break;
case kSQUARE_XPOS_0:
@@ -706,8 +808,8 @@
case kSQUARE_XPOS_5:
case kSQUARE_XPOS_6:
case kSQUARE_XPOS_7:
- if (sensor && sensor->getNumTouches() > 0)
- val = sensor->compoundTouchHorizontalLocation();
+ if (fSensor && fSensor->getNumTouches() > 0)
+ val = fSensor->compoundTouchHorizontalLocation();
*fZone = fMin + fRange * val;
break;
@@ -719,8 +821,8 @@
case kSQUARE_YPOS_5:
case kSQUARE_YPOS_6:
case kSQUARE_YPOS_7:
- if (sensor && sensor->getNumTouches() > 0)
- val = sensor->compoundTouchLocation();
+ if (fSensor && fSensor->getNumTouches() > 0)
+ val = fSensor->compoundTouchLocation();
*fZone = fMin + fRange * val;
break;
@@ -732,8 +834,8 @@
case kSQUARE_LVL_5:
case kSQUARE_LVL_6:
case kSQUARE_LVL_7:
- if (sensor && sensor->getNumTouches() > 0)
- val = sensor->compoundTouchSize();
+ if (fSensor && fSensor->getNumTouches() > 0)
+ val = fSensor->compoundTouchSize();
*fZone = fMin + fRange * val;
break;
@@ -745,9 +847,9 @@
case kSQUARE_TOUCH_5:
case kSQUARE_TOUCH_6:
case kSQUARE_TOUCH_7:
- if (sensor)
- val = sensor->getNumTouches();
- *fZone = max(fRange,val);
+ if (fSensor)
+ val = fSensor->getNumTouches();
+ *fZone = min(fRange,val);
break;
default:
@@ -755,17 +857,16 @@
};
}
- Trill::Device getType() { return type; }
+ Trill::Device getType() { return fType; }
- Trill* getSensor() { return sensor; }
+ Trill* getSensor() { return fSensor; }
};
/**************************************************************************************
-
TrillCraftWidget : object used by BelaUI to ensures the connection between a Trill Craft sensors values
and a Faust widget.
-
***************************************************************************************/
+
typedef struct {
int note;
double state;
@@ -775,15 +876,15 @@
{
protected:
- int lopin;
- int hipin;
- string mode;
- int prescaler;
- double threshold;
-
- vector Keyboard; // list of keys in the trillkeyboard (polyphony mode)
- int start_note;
- vector Scale; // in semitone
+ int fLopin;
+ int fHipin;
+ string fMode;
+ int fPrescaler;
+ double fThreshold;
+
+ vector fKeyboard; // list of keys in the trillkeyboard (polyphony mode)
+ int fStartNote;
+ vector fScale; // in semitone
int noteToMidiNumber(const string& note, int octave) // return the midi number of the note at the octave defined
{
@@ -805,48 +906,52 @@
TrillCraftWidget():TrillWidget()
{
- sensor = NULL;
- type = Trill::CRAFT;
- lopin = -1;
- hipin = -1;
- mode = "PIN";
- prescaler = 2;
- threshold = 0.10;
- start_note = 0;
+ fSensor = NULL;
+ fType = Trill::CRAFT;
+ fLopin = -1;
+ fHipin = -1;
+ fMode = "PIN";
+ fPrescaler = 2;
+ fThreshold = 0.10;
+ fStartNote = 0;
+ fScale.push_back(1); // default chromatic scale
}
TrillCraftWidget(const TrillCraftWidget& w):TrillWidget((TrillWidget)w)
{
- sensor = NULL;
- type = Trill::CRAFT;
- lopin = -1;
- hipin = -1;
- mode = "PIN";
- prescaler = 2;
- threshold = 0.10;
- start_note = 0;
+ fSensor = NULL;
+ fType = Trill::CRAFT;
+ fLopin = -1;
+ fHipin = -1;
+ fMode = "PIN";
+ fPrescaler = 2;
+ fThreshold = 0.10;
+ fStartNote = 0;
+ fScale.push_back(1); // default chromatic scale
}
- TrillCraftWidget(EInOutPin pin, FAUSTFLOAT* z, const char* l, FAUSTFLOAT lo, FAUSTFLOAT hi)
+ TrillCraftWidget(EInOutPin pin, FAUSTFLOAT* z, const char* l, FAUSTFLOAT lo, FAUSTFLOAT hi, FAUSTFLOAT step)
{
fBelaPin = pin;
fZone = z; // zone
fLabel = l; // label
fMin = lo; // minimal value
fRange = hi;
- sensor = NULL;
- type = Trill::CRAFT;
- lopin = -1;
- hipin = -1;
- mode = "PIN";
- prescaler = 2;
- threshold = 0.10;
- start_note = 0;
+ fStep = step;
+ fSensor = NULL;
+ fType = Trill::CRAFT;
+ fLopin = -1;
+ fHipin = -1;
+ fMode = "PIN";
+ fPrescaler = 2;
+ fThreshold = 0.10;
+ fStartNote = 0;
+ fScale.push_back(1); //default chromatic scale
}
virtual ~TrillCraftWidget()
{
- for (auto t : Keyboard) {
+ for (auto t : fKeyboard) {
delete t;
}
}
@@ -854,9 +959,9 @@
virtual void setSensor(Trill* nSensor)
{
TrillWidget::setSensor(nSensor);
- if (sensor) {
- sensor->setPrescaler(prescaler);
- sensor->setNoiseThreshold(threshold);
+ if (fSensor) {
+ fSensor->setPrescaler(fPrescaler);
+ fSensor->setNoiseThreshold(fThreshold);
}
}
@@ -864,133 +969,194 @@
{
if (parameters && !TrillWidget::setParameters(parameters)) {
if (parseWord(parameters, "PIN")) {
- mode = "PIN";
+ fMode = "PIN";
} else if (parseWord(parameters, "UP")) {
- mode = "UP";
+ fMode = "UP";
} else if (parseWord(parameters, "DOWN")) {
- mode = "DOWN";
+ fMode = "DOWN";
+ } else if (parseWord(parameters, "SLIDER")) {
+ fMode = "SLIDER";
}
double tmpval = 0.;
if (parameters && parseDouble(parameters, tmpval)) {
- lopin = (int)tmpval;
+ fLopin = (int)tmpval;
} else {
- lopin = -1;
+ fLopin = -1;
}
if (parameters && parseChar(parameters, '-') && parseDouble(parameters, tmpval)) {
- hipin = (int)tmpval;
+ fHipin = (int)tmpval;
} else {
- hipin = -1;
+ fHipin = -1;
}
}
return true;
}
-
- virtual void setParameter(const string& name, double value)
+
+ virtual void setParameter(const string& name, const double value)
{
- TrillWidget::setParameter(name, value);
- if (name == "prescaler") prescaler = (int)value;
- else if (name == "threshold") threshold = (int)value;
- else if (name == "start_pin") lopin = (int)value;
- else if (name == "end_pin") hipin = (int)value;
+ TrillWidget::setParameter(name,value);
+ if (name == "fPrescaler") fPrescaler = (int)value;
+ else if (name == "fThreshold") fThreshold = (int)value;
+ else if (name == "start_pin") fLopin = (int)value;
+ else if (name == "end_pin") fHipin = (int)value;
}
virtual void setParameter(const string& name, const string& value)
{
- const char* tmpval = value.c_str();
+ const char* tmpval=value.c_str();
if (name == "start_note") {
vector names;
vector values;
- if (parseMenuList(tmpval, names, values) && names.size() > 0) {
- start_note = noteToMidiNumber(names[0], (int)values[0]);
+ if (parseMenuList(tmpval,names,values) && names.size() > 0) {
+ fStartNote = noteToMidiNumber(names[0],(int) values[0]);
}
} else if (name == "scale") {
vector values;
- if (parseListDouble(tmpval, values) && values.size() > 0) {
- for (int i = 0; i < values.size(); i++) {
- Scale.push_back((int)(values[i]*2));
- }
+ if (parseListDouble(tmpval,values) && values.size() > 0) {
+ fScale.clear();
+ for (int i = 0 ; i= 0)
+ if (fSensor && fLopin >= 0)
{
float val = -1.f;
- if (mode == "PIN") {
- val = sensor->rawData[lopin];
- *fZone = fMin + fRange * val;
+ if (fMode == "PIN") {
+ *fZone = fMin + fRange * fSensor->rawData[fLopin];
}
- else if (mode == "UP") {
+ else if (fMode == "UP") {
float sval = 0.f;
- for (int i = hipin; i >= lopin; i--)
+ for (int i = fHipin; i >= fLopin; i--)
{
- sval = sensor->rawData[i];
+ sval = fSensor->rawData[i];
if (sval > 0.f)
{
- val = i-lopin;
+ val = i-fLopin;
break;
}
}
*fZone = val;
}
- else if (mode == "DOWN") {
+ else if (fMode == "DOWN") {
float sval = 0.f;
- for (int i = lopin; i <= hipin; i++)
+ for (int i = fLopin; i <= fHipin; i++)
{
- sval = sensor->rawData[i];
+ sval = fSensor->rawData[i];
if (sval > 0.f)
{
- val = i-lopin;
+ val = i-fLopin;
break;
}
}
*fZone = val;
- } else if (mode == "KEYBOARD") {
- mydsp_poly* TmpDsp = (mydsp_poly*)gDSP;
- for (int i = lopin; i <= hipin; i++) {
- TrillNote* CurKey = Keyboard[i-lopin];
- double sval = sensor->rawData[i];
+ } else if (fMode == "KEYBOARD") {
+ mydsp_poly* TmpDsp = (mydsp_poly*) gDSP;
+ for (int i = fLopin ; i <= fHipin ; i++) { //Call all keyOff
+ TrillNote* CurKey = fKeyboard[i-fLopin];
+ double sval = fSensor->rawData[i];
if (sval == 0 && CurKey->state > 0) {
TmpDsp->keyOff(0,CurKey->note);
- CurKey->state = 0;
- } else if (sval > 0 && CurKey->state == 0) {
- TmpDsp->keyOn(0,CurKey->note, (int) (sval*127));
- CurKey->state = sval;
+ CurKey->state=0;
}
}
+ for (int i = fLopin ; i <= fHipin ; i++) { //Call all keyOn
+ TrillNote* CurKey = fKeyboard[i-fLopin];
+ double sval = fSensor->rawData[i];
+ if (sval > 0 && CurKey->state == 0) {
+ TmpDsp->keyOn(0,CurKey->note, (int) (sval*127));
+ CurKey->state=sval;
+ }
+ }
}
}
}
void setMode(const string& mo)
{
- mode = mo;
- if (mode == "KEYBOARD" && lopin >= 0 && hipin >= lopin && start_note > 0) { // create the array of trill keyboard
- double curnote = start_note;
+ fMode = mo;
+ if (fMode == "KEYBOARD" && fLopin >= 0 && fHipin >= fLopin && fStartNote > 0) { // create the array of trill keyboard
+ double curnote = fStartNote;
int scalecounter = 0;
- for (int i = lopin ; i <= hipin ; i++) {
+ for (int i = fLopin ; i <= fHipin ; i++) {
TrillNote* newkey = new TrillNote;
newkey->note = curnote;
newkey->state = 0;
- Keyboard.push_back(newkey);
- if (Scale.size() > 0) { //configure the custom scale
- if (scalecounter >= Scale.size()) {
- scalecounter = 0;
- }
- curnote = curnote + Scale[scalecounter];
- scalecounter++;
- } else {
- curnote = curnote + 1; // configure default scale (chromatic)
+ fKeyboard.push_back(newkey);
+ if (scalecounter >= fScale.size()) {
+ scalecounter = 0;
}
+ curnote = curnote + fScale[scalecounter];
+ scalecounter++;
}
}
}
- void setLopin(int pin) { lopin = pin; }
+ void setLopin(int pin) { fLopin = pin; }
- void setHipin(int pin) { hipin = pin; }
+ void setHipin(int pin) { fHipin = pin; }
+};
+
+class TrillCraftWidgetCheckBox : public TrillCraftWidget
+{
+ protected:
+ CheckBoxLogic fChkBoxSystem;
+
+ public:
+
+ TrillCraftWidgetCheckBox(): TrillCraftWidget() {}
+
+ TrillCraftWidgetCheckBox(const TrillCraftWidgetCheckBox& w): TrillCraftWidget((TrillCraftWidget) w) {}
+
+ TrillCraftWidgetCheckBox(EInOutPin pin, FAUSTFLOAT* z, const char* l, FAUSTFLOAT lo, FAUSTFLOAT hi, FAUSTFLOAT step): TrillCraftWidget(pin, z, l, lo, hi, step) {}
+
+ virtual ~TrillCraftWidgetCheckBox() {}
+
+ virtual void update(BelaContext* context)
+ {
+ if (fSensor && fLopin >= 0 && fMode == "PIN")
+ {
+ double value = fSensor->rawData[fLopin];
+ bool value_state = fChkBoxSystem.getOutState((bool) value);
+ *fZone = fMin + fRange * value_state;
+ }
+ }
+};
+
+class TrillCraftWidgetSlider : public TrillCraftWidget
+{
+ protected:
+ UpDownKeyLogic fSliderSystem;
+
+ public:
+
+ TrillCraftWidgetSlider(): TrillCraftWidget() {}
+
+ TrillCraftWidgetSlider(const TrillCraftWidgetCheckBox& w): TrillCraftWidget((TrillCraftWidget) w) {}
+
+ TrillCraftWidgetSlider(EInOutPin pin, FAUSTFLOAT* z, const char* l, FAUSTFLOAT lo, FAUSTFLOAT hi, FAUSTFLOAT step ): TrillCraftWidget(pin, z, l, lo, hi, step) {
+
+ }
+
+ virtual ~TrillCraftWidgetSlider() {}
+
+ virtual void update(BelaContext* context)
+ {
+ if (fSensor && fLopin >= 0 && fMode == "SLIDER")
+ {
+ double downKey = fSensor->rawData[fLopin];
+ double upKey = fSensor->rawData[fHipin];
+ double value_state = (double) fSliderSystem.getOutState(downKey, upKey);
+ double tmpval = *fZone + fStep * value_state;
+ if (tmpval >= fMin && tmpval <= (fRange+fMin)) {
+ *fZone=tmpval;
+ }
+ }
+ }
};
/**************************************************************************************
@@ -1008,6 +1174,7 @@
#define MAXBELAWIDGETS 16
// Max number of trill sensors parameters mapped.
+
// max of 8 BAR sensors with 3 parameters (Position,Pressure,Touch), 8 SQUARE sensors with 4 parameters
// (Position X, Position Y, Pressure, Touch), 8 CRAFT sensors with 1 parameter
#define MAXTRILLWIDGETS 64
@@ -1028,29 +1195,81 @@
vector fTouchSensors; // list of Trill sensors
// Check if the widget is linked to a Bela parameter and, if so, add the corresponding BelaWidget
- void addBelaWidget(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT lo, FAUSTFLOAT hi)
+ void addBelaWidget(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT lo, FAUSTFLOAT hi, FAUSTFLOAT step)
+ {
+ if (fBelaPin != kNoPin && (fIndex < MAXBELAWIDGETS)) {
+ fTable[fIndex] = BelaWidget(fBelaPin, zone, label, lo, hi, step);
+ fIndex++;
+ }
+ fBelaPin = kNoPin;
+ }
+ void addBelaWidgetCheckBox(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT lo, FAUSTFLOAT hi)
{
if (fBelaPin != kNoPin && (fIndex < MAXBELAWIDGETS)) {
- fTable[fIndex] = BelaWidget(fBelaPin, zone, label, lo, hi);
+ fTable[fIndex] = BelaWidgetCheckBox(fBelaPin, zone, label, lo, hi, 0);
fIndex++;
}
fBelaPin = kNoPin;
}
- void addTrillWidget(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT lo, FAUSTFLOAT hi)
+ void addTrillWidget(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT lo, FAUSTFLOAT hi, FAUSTFLOAT step)
+ {
+ if (fTrillPin != kNoPin) {
+
+ if (strstr(pinNamesStrings[fTrillPin], "CRAFT"))
+ {
+ TrillCraftWidget* newcraft = new TrillCraftWidget(fTrillPin, zone, label, lo, hi, step);
+ newcraft->setParameters(fTrillParams);
+ fTrillTable.push_back(newcraft);
+ }
+ else
+ {
+ TrillWidget* newtrill = new TrillWidget(fTrillPin, zone, label, lo, hi, step);
+ newtrill->setParameters(fTrillParams);
+ fTrillTable.push_back(newtrill);
+ }
+
+ }
+ fTrillPin = kNoPin;
+ fTrillParams = NULL;
+ }
+
+ void addTrillWidgetCheckBox(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT lo, FAUSTFLOAT hi)
{
- if (fTrillPin != kNoPin && (fTrillTable.size() < MAXTRILLWIDGETS)) {
+ if (fTrillPin != kNoPin) {
if (strstr(pinNamesStrings[fTrillPin], "CRAFT"))
{
- TrillCraftWidget* newcraft = new TrillCraftWidget(fTrillPin, zone, label, lo, hi);
- newcraft->setParameters(fTrillParams);
+ TrillCraftWidgetCheckBox* newcraft = new TrillCraftWidgetCheckBox(fTrillPin, zone, label, lo, hi, 0);
+ newcraft->setParameters(fTrillParams);
+ fTrillTable.push_back(newcraft);
+ }
+ }
+ fTrillPin = kNoPin;
+ fTrillParams = NULL;
+ }
+
+ void addTrillWidgetSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT lo, FAUSTFLOAT hi, FAUSTFLOAT step)
+ {
+ if (fTrillPin != kNoPin) {
+
+ TrillCraftWidget* newcraft;
+ if (strstr(pinNamesStrings[fTrillPin], "CRAFT"))
+ {
+ if (strstr(fTrillParams, "SLIDER")) {
+ TrillCraftWidgetSlider* newcraftslider = new TrillCraftWidgetSlider(fTrillPin, zone, label, lo, hi, step);
+ newcraft = (TrillCraftWidget*) newcraftslider;
+ } else {
+ TrillCraftWidget* newcraftsensor = new TrillCraftWidget(fTrillPin, zone, label, lo, hi, step);
+ newcraft = newcraftsensor;
+ }
+ newcraft->setParameters(fTrillParams);
fTrillTable.push_back(newcraft);
}
else
{
- TrillWidget* newtrill = new TrillWidget(fTrillPin, zone, label, lo, hi);
- newtrill->setParameters(fTrillParams);
+ TrillWidget* newtrill = new TrillWidget(fTrillPin, zone, label, lo, hi, step);
+ newtrill->setParameters(fTrillParams);
fTrillTable.push_back(newtrill);
}
@@ -1111,48 +1330,48 @@
virtual void addButton(const char* label, FAUSTFLOAT* zone)
{
if (fBelaPin != kNoPin)
- addBelaWidget(label, zone, FAUSTFLOAT(0), FAUSTFLOAT(1));
+ addBelaWidget(label, zone, FAUSTFLOAT(0), FAUSTFLOAT(1),0);
else
- addTrillWidget(label, zone, FAUSTFLOAT(0), FAUSTFLOAT(1));
+ addTrillWidget(label, zone, FAUSTFLOAT(0), FAUSTFLOAT(1),0);
}
virtual void addCheckButton(const char* label, FAUSTFLOAT* zone)
{
if (fBelaPin != kNoPin)
- addBelaWidget(label, zone, FAUSTFLOAT(0), FAUSTFLOAT(1));
+ addBelaWidgetCheckBox(label, zone, FAUSTFLOAT(0), FAUSTFLOAT(1));
else
- addTrillWidget(label, zone, FAUSTFLOAT(0), FAUSTFLOAT(1));
+ addTrillWidgetCheckBox(label, zone, FAUSTFLOAT(0), FAUSTFLOAT(1));
}
virtual void addVerticalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT lo, FAUSTFLOAT hi, FAUSTFLOAT step)
{
if (fBelaPin != kNoPin)
- addBelaWidget(label, zone, lo, hi);
+ addBelaWidget(label, zone, lo, hi, step);
else
- addTrillWidget(label, zone, lo, hi);
+ addTrillWidgetSlider(label, zone, lo, hi, step);
}
virtual void addHorizontalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT lo, FAUSTFLOAT hi, FAUSTFLOAT step)
{
if (fBelaPin != kNoPin)
- addBelaWidget(label, zone, lo, hi);
+ addBelaWidget(label, zone, lo, hi, step);
else
- addTrillWidget(label, zone, lo, hi);
+ addTrillWidgetSlider(label, zone, lo, hi, step);
}
virtual void addNumEntry(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT lo, FAUSTFLOAT hi, FAUSTFLOAT step)
{
if (fBelaPin != kNoPin)
- addBelaWidget(label, zone, lo, hi);
+ addBelaWidget(label, zone, lo, hi, step);
else
- addTrillWidget(label, zone, lo, hi);
+ addTrillWidget(label, zone, lo, hi, step);
}
// -- passive widgets
virtual void addHorizontalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT lo, FAUSTFLOAT hi)
- { addBelaWidget(label, zone, lo, hi); }
+ { addBelaWidget(label, zone, lo, hi, 0); }
virtual void addVerticalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT lo, FAUSTFLOAT hi)
- { addBelaWidget(label, zone, lo, hi); }
+ { addBelaWidget(label, zone, lo, hi, 0); }
// -- metadata declarations
virtual void declare(FAUSTFLOAT* z, const char* k, const char* id)
@@ -1201,9 +1420,9 @@
for (int i = 0; i values;
if (parseMenuListMenu(id, names, values)) {
for (int i = 0; isetParameters(values[i].c_str());
newcraft->setMode("KEYBOARD");
fTrillTable.push_back(newcraft);
@@ -1478,4 +1697,3 @@
}
/******************** END bela.cpp ****************/
-
diff -Nru faust-2.50.6+ds0/architecture/cmajor/cmajor-faust-editor.cpp faust-2.54.9+ds0/architecture/cmajor/cmajor-faust-editor.cpp
--- faust-2.50.6+ds0/architecture/cmajor/cmajor-faust-editor.cpp 1970-01-01 00:00:00.000000000 +0000
+++ faust-2.54.9+ds0/architecture/cmajor/cmajor-faust-editor.cpp 2022-12-17 10:41:42.000000000 +0000
@@ -0,0 +1,146 @@
+/************************************************************************
+ FAUST Architecture File
+ Copyright (C) 2021-2022 GRAME, Centre National de Creation Musicale
+ ---------------------------------------------------------------------
+ This Architecture section is free software; you can redistribute it
+ and/or modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 3 of
+ the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; If not, see .
+
+ EXCEPTION : As a special exception, you may create a larger work
+ that contains this FAUST architecture section and distribute
+ that work under terms of your choice, so long as this FAUST
+ architecture section is not modified.
+ ************************************************************************/
+
+#include
+#include
+#include
+#include
+#include
+
+#include "cmajor-tools.h"
+#include "faust/dsp/llvm-dsp.h"
+#include "faust/misc.h"
+
+using namespace std;
+
+static bool endWith(const string& str, const string& suffix)
+{
+ size_t i = str.rfind(suffix);
+ return (i != string::npos) && (i == (str.length() - suffix.length()));
+}
+
+struct HybridEditor {
+
+ string fInFilename;
+ string fOutFilename;
+ int fArgc1;
+ const char** fArgv1;
+ efsw_watcher fEfsw;
+
+ HybridEditor(const string& in_filename,
+ const string& out_filename,
+ int argc1,
+ const char* argv1[])
+ :fInFilename(in_filename), fOutFilename(out_filename), fArgc1(argc1), fArgv1(argv1)
+ {
+ char temp[PATH_MAX + 1];
+ char* path = realpath(in_filename.c_str(), temp);
+ std::string dir = dirname(path);
+
+ fEfsw = efsw_create(false);
+ efsw_addwatch(fEfsw, dir.c_str(), watchCallback, false, this);
+ efsw_watch(fEfsw);
+
+ compilePatch();
+
+ cout << "Type 'q' to Quit\n";
+ char c;
+ while ((c = getchar()) && (c != 'q')) {}
+ }
+
+ virtual ~HybridEditor()
+ {
+ efsw_release(fEfsw);
+ }
+
+ void compilePatch()
+ {
+ cout << "compilePatch : '" << fInFilename << "' to '" << fOutFilename << "' and '" << fOutFilename + "patch'" << endl;
+ // We have a pure Cmajor file or a Faust/Cmajor file, parse it, compile the Faust part to Cmajor, generate the Cmajor result
+ faust_cmajor_parser parser;
+ if (!parser.parseCmajorFile(fInFilename, fOutFilename, fArgc1, fArgv1)) {
+ cerr << "ERROR : file '" << fInFilename << "' cannot be opened or compiled!\n";
+ return;
+ }
+
+ // Generate "cmajorpatch" file
+ parser.createCmajorPatch(fOutFilename);
+ }
+
+ static void watchCallback(efsw_watcher watcher,
+ efsw_watchid watchid,
+ const char* dir,
+ const char* filename,
+ enum efsw_action action,
+ const char* old_filename,
+ void* param)
+ {
+ HybridEditor* editor = (HybridEditor*)param;
+ if (action == EFSW_ADD
+ || action == EFSW_DELETE
+ || action == EFSW_MODIFIED
+ || action == EFSW_MOVED) {
+ // Check filename
+ if (string(filename) == editor->fInFilename) {
+ editor->compilePatch();
+ }
+ }
+ }
+
+};
+
+int main(int argc, char* argv[])
+{
+ if (isopt(argv, "-h") || isopt(argv, "-help")) {
+ cout << "Copyright (c) 2021-2022 Grame, version 0.2" << endl;
+ cout << "Usage: cmajor-faust-editor [Faust options : any option (e.g. -ftz 1...)] -o " << endl;
+ exit(-1);
+ }
+
+ string in_filename;
+ string out_filename = "hybrid.cmajor";
+ int argc1 = 0;
+ const char* argv1[64];
+ for (int i = 1; i < argc; i++) {
+ if (endWith(string(argv[i]), ".cmajor")) {
+ in_filename = argv[i];
+ continue;
+ } else if (string(argv[i]) == "-o") {
+ out_filename = argv[i+1];
+ i++;
+ continue;
+ }
+ argv1[argc1++] = argv[i];
+ }
+
+ cout << "Libfaust version : " << getCLibFaustVersion() << endl;
+
+ if (endWith(in_filename, "cmajor")) {
+ HybridEditor editor(in_filename, out_filename, argc1, argv1);
+ } else {
+ cout << "ERROR : incorrect file type" << endl;
+ exit(-1);
+ }
+
+ return 0;
+}
diff -Nru faust-2.50.6+ds0/architecture/cmajor/cmajor-faust-player.cpp faust-2.54.9+ds0/architecture/cmajor/cmajor-faust-player.cpp
--- faust-2.50.6+ds0/architecture/cmajor/cmajor-faust-player.cpp 1970-01-01 00:00:00.000000000 +0000
+++ faust-2.54.9+ds0/architecture/cmajor/cmajor-faust-player.cpp 2022-12-17 10:41:42.000000000 +0000
@@ -0,0 +1,141 @@
+/************************************************************************
+ FAUST Architecture File
+ Copyright (C) 2019-2022 GRAME, Centre National de Creation Musicale
+ ---------------------------------------------------------------------
+ This Architecture section is free software; you can redistribute it
+ and/or modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 3 of
+ the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; If not, see .
+
+ EXCEPTION : As a special exception, you may create a larger work
+ that contains this FAUST architecture section and distribute
+ that work under terms of your choice, so long as this FAUST
+ architecture section is not modified.
+ ************************************************************************/
+
+#include
+#include
+
+#include "faust/gui/GTKUI.h"
+#include "faust/audio/jack-dsp.h"
+#include "faust/dsp/cmajorpatch-dsp.h"
+#include "cmajor-tools.h"
+#include "faust/dsp/libfaust.h"
+#include "faust/misc.h"
+#include "faust/midi/rt-midi.h"
+#include "faust/midi/RtMidi.cpp"
+#include
+
+using namespace std;
+
+list GUI::fGuiList;
+ztimedmap GUI::gTimedZoneMap;
+
+#define FAUST_FILE "faust.cmajor"
+#define FAUST_PATCH_FILE "faust.cmajorpatch"
+
+#define HYBRID_FILE "hybrid.cmajor"
+#define HYBRID_PATCH_FILE "hybrid.cmajorpatch"
+
+inline bool endWith(const string& str, const string& suffix)
+{
+ size_t i = str.rfind(suffix);
+ return (i != string::npos) && (i == (str.length() - suffix.length()));
+}
+
+int main(int argc, char* argv[])
+{
+ if (isopt(argv, "-h") || isopt(argv, "-help")) {
+ cout << "cmajor-faust-player (pure Faust code), (pure Cmajor patch) or (pure Cmajor code or Faust/Cmajor hybrid code)" << endl;
+ exit(-1);
+ }
+
+ char* filename = argv[argc-1];
+ string real_file;
+
+ int argc1 = 0;
+ const char* argv1[64];
+ for (int i = 1; i < argc-1; i++) {
+ argv1[argc1++] = argv[i];
+ }
+
+ if (endWith(filename, ".dsp")) {
+
+ // We have a pure Faust file, compile it to Cmajor
+ faust_cmajor_parser parser;
+ if (!parser.generateCmajorFile(filename, FAUST_FILE, argc1, argv1)) {
+ cerr << "ERROR : file '" << filename << "' cannot be opened or compiled!\n";
+ exit(-1);
+ }
+
+ // Generate "cmajorpatch" file
+ parser.createCmajorPatch(FAUST_FILE);
+ real_file = FAUST_FILE;
+
+ } else if (endWith(filename, ".cmajor")) {
+
+ // We have a pure Cmajor file or a Faust/Cmajor file, parse it, compile the Faust part to Cmajor, generate the Cmajor result
+ faust_cmajor_parser parser;
+ if (!parser.parseCmajorFile(filename, HYBRID_FILE, argc1, argv1)) {
+ cerr << "ERROR : file '" << filename << "' cannot be opened or compiled!\n";
+ exit(-1);
+ }
+
+ // Generate "cmajorpatch" file
+ parser.createCmajorPatch(HYBRID_FILE);
+ real_file = HYBRID_FILE;
+
+ } else {
+ cerr << "Unsupported file extension" << endl;
+ exit(1);
+ }
+
+ try {
+ string error_msg;
+ cmajor_dsp_factory* factory = createCmajorDSPFactoryFromFile(real_file, argc, (const char**)argv, error_msg);
+ if (!factory) {
+ cerr << "Cannot create factory : " << error_msg;
+ exit(1);
+ }
+ cmajorpatch_dsp* DSP = factory->createDSPInstance();
+
+ cout << "getNumInputs " << DSP->getNumInputs() << endl;
+ cout << "getNumOutputs " << DSP->getNumOutputs() << endl;
+
+ jackaudio audio;
+ audio.init(filename, DSP);
+
+ // Has to be done after init
+ GTKUI interface(filename, &argc, &argv);
+ DSP->buildUserInterface(&interface);
+
+ // MIDI handling
+ rt_midi midi_handler(filename, false, true);
+ DSP->setMidiHandler(&midi_handler);
+
+ midi_handler.startMidi();
+ audio.start();
+
+ interface.run();
+
+ midi_handler.stopMidi();
+ audio.stop();
+
+ // Cleanup
+ delete DSP;
+ delete factory;
+ } catch (...) {
+ cerr << "ERROR : cannot allocate cmajorpatch_dsp\n";
+ exit(-1);
+ }
+
+ return 0;
+}
diff -Nru faust-2.50.6+ds0/architecture/cmajor/cmajor-faust-tester.cpp faust-2.54.9+ds0/architecture/cmajor/cmajor-faust-tester.cpp
--- faust-2.50.6+ds0/architecture/cmajor/cmajor-faust-tester.cpp 1970-01-01 00:00:00.000000000 +0000
+++ faust-2.54.9+ds0/architecture/cmajor/cmajor-faust-tester.cpp 2022-12-17 10:41:42.000000000 +0000
@@ -0,0 +1,142 @@
+/************************************************************************
+ FAUST Architecture File
+ Copyright (C) 2019-2022 GRAME, Centre National de Creation Musicale
+ ---------------------------------------------------------------------
+ This Architecture section is free software; you can redistribute it
+ and/or modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 3 of
+ the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; If not, see .
+
+ EXCEPTION : As a special exception, you may create a larger work
+ that contains this FAUST architecture section and distribute
+ that work under terms of your choice, so long as this FAUST
+ architecture section is not modified.
+ ************************************************************************/
+
+#include
+#include
+
+#include "faust/dsp/cmajorpatch-dsp.h"
+#include "cmajor-tools.h"
+#include "faust/dsp/dsp-optimizer.h"
+#include "faust/misc.h"
+#include "faust/dsp/interpreter-dsp.h"
+
+#define FAUST_FILE "faust.cmajor"
+#define FAUST_PATCH_FILE "faust.cmajorpatch"
+
+//#define INTERP
+
+using namespace std;
+
+static int buffer_size = 512;
+static bool is_control = false;
+
+static bool endWith(const string& str, const string& suffix)
+{
+ size_t i = str.rfind(suffix);
+ return (i != string::npos) && (i == (str.length() - suffix.length()));
+}
+
+static void measureDSP(const string& filename, dsp* DSP)
+{
+ // Buffer_size and duration in sec of measure, no trace and activated control
+ measure_dsp mes(DSP, buffer_size, 5., false, is_control);
+ mes.measure();
+ pair res = mes.getStats();
+ cout << filename << " : " << res.first << " MBytes/sec (DSP CPU % : " << (mes.getCPULoad() * 100) << " at 44100 Hz)" << endl;
+ FAUSTBENCH_LOG(res.first);
+}
+
+static void testFaust(const string& filename, int argc1, const char* argv1[])
+{
+ // Faust compilation and test
+ string error_msg;
+#ifdef INTERP
+ dsp_factory* factory = createInterpreterDSPFactoryFromFile(filename, argc1, argv1, error_msg);
+#else
+ dsp_factory* factory = createDSPFactoryFromFile(filename, argc1, argv1, "", error_msg, -1);
+#endif
+ if (!factory) {
+ cerr << "ERROR : file '" << filename << "' cannot be opened with " << error_msg << "\n";
+ exit(-1);
+ }
+ measureDSP(filename, factory->createDSPInstance());
+#ifdef INTERP
+ deleteInterpreterDSPFactory(static_cast(factory));
+#else
+ deleteDSPFactory(static_cast(factory));
+#endif
+}
+
+static void testCmajorPatch(const string& filename, int argc1, const char* argv1[])
+{
+ // Cmajor compilation and test
+ string error_msg;
+ cmajor_dsp_factory* factory = createCmajorDSPFactoryFromFile(filename, argc1, argv1, error_msg);
+ if (!factory) {
+ cerr << "ERROR : file '" << filename << "' : " << error_msg << "\n";
+ exit(-1);
+ }
+
+ measureDSP(filename, factory->createDSPInstance());
+ delete factory;
+}
+
+static void testCmajor(const string& filename, int argc1, const char* argv1[])
+{
+ // Faust => Cmajor compilation
+ faust_cmajor_parser parser;
+ if (!parser.generateCmajorFile(filename, FAUST_FILE, argc1, argv1)) {
+ cerr << "ERROR : file '" << filename << "' cannot be opened or compiled! \n";
+ exit(-1);
+ }
+
+ // Generate "cmajorpatch" file
+ parser.createCmajorPatch(FAUST_FILE);
+ testCmajorPatch(FAUST_FILE, argc1, argv1);
+}
+
+int main(int argc, char* argv[])
+{
+ if (isopt(argv, "-h") || isopt(argv, "-help")) {
+ cout << "cmajor-faust-tester [-bs ] [-control] [Faust options : any option (e.g. -vec -vs 8...)] foo.dsp|foo.cmajorpatch" << endl;
+ cout << "Use '-bs ' to set the maximum buffer-size in frames\n";
+ cout << "Use '-control' to update all controllers with random values at each cycle\n";
+ exit(-1);
+ }
+
+ buffer_size = lopt(argv, "-bs", 512);
+ is_control = isopt(argv, "-control");
+ cout << "buffer_size = " << buffer_size << endl;
+
+ char* filename = argv[argc-1];
+ int argc1 = 0;
+ const char* argv1[64];
+ for (int i = 1; i < argc-1; i++) {
+ if (string(argv[i]) == "-control") {
+ continue;
+ } else if (string(argv[i]) == "-bs") {
+ i++;
+ continue;
+ }
+ argv1[argc1++] = argv[i];
+ }
+
+ if (endWith(filename, "cmajor")) {
+ testCmajorPatch(filename, argc1, argv1);
+ } else {
+ testFaust(filename, argc1, argv1);
+ testCmajor(filename, argc1, argv1);
+ }
+
+ return 0;
+}
diff -Nru faust-2.50.6+ds0/architecture/cmajor/cmajor-tools.h faust-2.54.9+ds0/architecture/cmajor/cmajor-tools.h
--- faust-2.50.6+ds0/architecture/cmajor/cmajor-tools.h 1970-01-01 00:00:00.000000000 +0000
+++ faust-2.54.9+ds0/architecture/cmajor/cmajor-tools.h 2022-12-17 10:41:42.000000000 +0000
@@ -0,0 +1,204 @@
+/************************** BEGIN cmajor-tools.h *************************
+FAUST Architecture File
+Copyright (C) 2003-2022 GRAME, Centre National de Creation Musicale
+---------------------------------------------------------------------
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+EXCEPTION : As a special exception, you may create a larger work
+that contains this FAUST architecture section and distribute
+that work under terms of your choice, so long as this FAUST
+architecture section is not modified.
+***************************************************************************/
+
+#ifndef __cmajortools_dsp__
+#define __cmajortools_dsp__
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include