From 2a236c73f6b8907db84e0facbdcc26ad30a5aaad Mon Sep 17 00:00:00 2001 From: Stephane Letz Date: Thu, 19 Oct 2023 21:30:23 +0200 Subject: [PATCH] Add boxHGroup, boxVGroup, boxTGroup and C versions in libfaust API. --- architecture/faust/dsp/libfaust-box-c.h | 27 ++++++++++++++++++++++ architecture/faust/dsp/libfaust-box.h | 27 ++++++++++++++++++++++ compiler/box_signal_api.cpp | 30 +++++++++++++++++++++++++ compiler/boxes/boxes.cpp | 6 ++--- compiler/boxes/boxes.hh | 6 ++--- tools/benchmark/box-tester.c | 3 ++- tools/benchmark/box-tester.cpp | 9 +++++--- 7 files changed, 98 insertions(+), 10 deletions(-) diff --git a/architecture/faust/dsp/libfaust-box-c.h b/architecture/faust/dsp/libfaust-box-c.h index 5e525809dd..acc3a202f2 100644 --- a/architecture/faust/dsp/libfaust-box-c.h +++ b/architecture/faust/dsp/libfaust-box-c.h @@ -617,6 +617,33 @@ extern "C" */ LIBFAUST_API Box CboxHBargraphAux(const char* label, Box min, Box max, Box x); + /** + * Create a vertical group box. + * @param label - the label definition (see [2]) + * @param group - the group to be added + * + * @return the vertical group box. + */ + LIBFAUST_API Box CboxVGroup(const char* label, Box group); + + /** + * Create a horizontal group box. + * @param label - the label definition (see [2]) + * @param group - the group to be added + * + * @return the horizontal group box. + */ + LIBFAUST_API Box CboxHGroup(const char* label, Box group); + + /** + * Create a tab group box. + * @param label - the label definition (see [2]) + * @param group - the group to be added + * + * @return the tab group box. + */ + LIBFAUST_API Box CboxTGroup(const char* label, Box group); + /** * Create an attach box. * diff --git a/architecture/faust/dsp/libfaust-box.h b/architecture/faust/dsp/libfaust-box.h index b4b57c3a2c..4209052097 100644 --- a/architecture/faust/dsp/libfaust-box.h +++ b/architecture/faust/dsp/libfaust-box.h @@ -663,6 +663,33 @@ LIBFAUST_API Box boxHBargraph(const std::string& label, Box min, Box max); */ LIBFAUST_API Box boxHBargraph(const std::string& label, Box min, Box max, Box x); +/** + * Create a vertical group box. + * @param label - the label definition (see [2]) + * @param group - the group to be added + * + * @return the vertical group box. + */ +LIBFAUST_API Box boxVGroup(const std::string& label, Box group); + +/** + * Create a horizontal group box. + * @param label - the label definition (see [2]) + * @param group - the group to be added + * + * @return the horizontal group box. + */ +LIBFAUST_API Box boxHGroup(const std::string& label, Box group); + +/** + * Create a tab group box. + * @param label - the label definition (see [2]) + * @param group - the group to be added + * + * @return the tab group box. + */ +LIBFAUST_API Box boxTGroup(const std::string& label, Box group); + /** * Create an attach box. * diff --git a/compiler/box_signal_api.cpp b/compiler/box_signal_api.cpp index 4072dd5845..7186c5cf31 100644 --- a/compiler/box_signal_api.cpp +++ b/compiler/box_signal_api.cpp @@ -1415,6 +1415,21 @@ LIBFAUST_API Tree boxHBargraph(const string& label, Tree min, Tree max) return boxHBargraph(tree(label), min, max); } +LIBFAUST_API Tree boxVGroup(const std::string& label, Tree group) +{ + return boxVGroup(tree(label), group); +} + +LIBFAUST_API Tree boxHGroup(const std::string& label, Tree group) +{ + return boxHGroup(tree(label), group); +} + +LIBFAUST_API Tree boxTGroup(const std::string& label, Tree group) +{ + return boxTGroup(tree(label), group); +} + LIBFAUST_API Tree boxAttach() { return boxPrim2(sigAttach); @@ -2061,6 +2076,21 @@ LIBFAUST_API Tree CboxHBargraph(const char* label, Tree min, Tree max) { return boxHBargraph(label, min, max); } + +LIBFAUST_API Tree CboxVGroup(const char* label, Tree group) +{ + return boxVGroup(label, group); +} + +LIBFAUST_API Tree CboxHGroup(const char* label, Tree group) +{ + return boxHGroup(label, group); +} + +LIBFAUST_API Tree CboxTGroup(const char* label, Tree group) +{ + return boxTGroup(label, group); +} LIBFAUST_API Tree CboxAttach() { diff --git a/compiler/boxes/boxes.cpp b/compiler/boxes/boxes.cpp index 82314a30e7..ac4ad40b1b 100644 --- a/compiler/boxes/boxes.cpp +++ b/compiler/boxes/boxes.cpp @@ -804,7 +804,7 @@ LIBFAUST_API bool isBoxNumEntry(Tree s, Tree& lbl, Tree& cur, Tree& min, Tree& m } } -Tree boxHGroup(Tree lbl, Tree x) +LIBFAUST_API Tree boxHGroup(Tree lbl, Tree x) { return tree(gGlobal->BOXHGROUP, lbl, x); } @@ -818,7 +818,7 @@ LIBFAUST_API bool isBoxHGroup(Tree s, Tree& lbl, Tree& x) return isTree(s, gGlobal->BOXHGROUP, lbl, x); } -Tree boxVGroup(Tree lbl, Tree x) +LIBFAUST_API Tree boxVGroup(Tree lbl, Tree x) { return tree(gGlobal->BOXVGROUP, lbl, x); } @@ -832,7 +832,7 @@ LIBFAUST_API bool isBoxVGroup(Tree s, Tree& lbl, Tree& x) return isTree(s, gGlobal->BOXVGROUP, lbl, x); } -Tree boxTGroup(Tree lbl, Tree x) +LIBFAUST_API Tree boxTGroup(Tree lbl, Tree x) { return tree(gGlobal->BOXTGROUP, lbl, x); } diff --git a/compiler/boxes/boxes.hh b/compiler/boxes/boxes.hh index 1768f5ab1a..9d9c1da717 100644 --- a/compiler/boxes/boxes.hh +++ b/compiler/boxes/boxes.hh @@ -299,15 +299,15 @@ LIBFAUST_API bool isBoxHBargraph(Tree s); LIBFAUST_API bool isBoxHBargraph(Tree s, Tree& label, Tree& min, Tree& max); // Groups -Tree boxVGroup(Tree label, Tree x); +LIBFAUST_API Tree boxVGroup(Tree label, Tree x); LIBFAUST_API bool isBoxVGroup(Tree s); LIBFAUST_API bool isBoxVGroup(Tree s, Tree& label, Tree& x); -Tree boxHGroup(Tree label, Tree x); +LIBFAUST_API Tree boxHGroup(Tree label, Tree x); LIBFAUST_API bool isBoxHGroup(Tree s); LIBFAUST_API bool isBoxHGroup(Tree s, Tree& label, Tree& x); -Tree boxTGroup(Tree label, Tree x); +LIBFAUST_API Tree boxTGroup(Tree label, Tree x); LIBFAUST_API bool isBoxTGroup(Tree s); LIBFAUST_API bool isBoxTGroup(Tree s, Tree& label, Tree& x); diff --git a/tools/benchmark/box-tester.c b/tools/benchmark/box-tester.c index 5b19e970d1..3df06598ca 100644 --- a/tools/benchmark/box-tester.c +++ b/tools/benchmark/box-tester.c @@ -252,7 +252,8 @@ static void test4() // Create the filter parameters and connect Box cutoff = CboxHSlider("cutoff", CboxReal(300), CboxReal(100), CboxReal(2000), CboxReal(0.01)); Box cutoffAndInput = CboxPar(cutoff, CboxWire()); - Box filteredInput = CboxSeq(cutoffAndInput, filter); + Box group = CboxSeq(cutoffAndInput, filter); + Box filteredInput = CboxHGroup("test4", group); CgetBoxType(filteredInput, &inputs, &outputs); printf("CgetBoxType inputs: %d outputs: %d\n", inputs, outputs); diff --git a/tools/benchmark/box-tester.cpp b/tools/benchmark/box-tester.cpp index 3936ee9ce3..8202ee3966 100644 --- a/tools/benchmark/box-tester.cpp +++ b/tools/benchmark/box-tester.cpp @@ -414,7 +414,8 @@ static void test21(int argc, const char* argv[]) { Box sl1 = boxVSlider("h:Oscillator/Freq1", boxReal(300), boxReal(100), boxReal(2000), boxReal(0.01)); Box sl2 = boxVSlider("h:Oscillator/Freq2", boxReal(300), boxReal(100), boxReal(2000), boxReal(0.01)); - Box box = boxPar(osc(sl1), osc(sl2)); + Box group = boxPar(osc(sl1), osc(sl2)); + Box box = boxVGroup("test21", group); string error_msg; llvm_dsp_factory* factory = createDSPFactoryFromBoxes("FaustDSP", box, 0, nullptr, "", error_msg); @@ -456,7 +457,8 @@ static void test22(int argc, const char* argv[]) { Box sl1 = boxHSlider("v:Oscillator/Freq1", boxReal(300), boxReal(100), boxReal(2000), boxReal(0.01)); Box sl2 = boxHSlider("v:Oscillator/Freq2", boxReal(300), boxReal(100), boxReal(2000), boxReal(0.01)); - Box box = boxPar(osc(sl1), osc(sl2)); + Box group = boxPar(osc(sl1), osc(sl2)); + Box box = boxHGroup("test22", group); string error_msg; interpreter_dsp_factory* factory = createInterpreterDSPFactoryFromBoxes("FaustDSP", box, 0, nullptr, error_msg); @@ -503,7 +505,8 @@ static void test23(int argc, const char* argv[]) boxReal(100), boxReal(2000), boxReal(0.01)); Box sl2 = boxHSlider("v:Oscillator/Freq2", boxReal(300), boxReal(100), boxReal(2000), boxReal(0.01)); - Box box = boxPar(osc(sl1), osc(sl2)); + Box group = boxPar(osc(sl1), osc(sl2)); + Box box = boxTGroup("test23", group); // Print the box cout << "Print the box\n";