Skip to content

Commit

Permalink
Add boxHGroup, boxVGroup, boxTGroup and C versions in libfaust API.
Browse files Browse the repository at this point in the history
  • Loading branch information
sletz committed Oct 19, 2023
1 parent 150d089 commit 2a236c7
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 10 deletions.
27 changes: 27 additions & 0 deletions architecture/faust/dsp/libfaust-box-c.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
27 changes: 27 additions & 0 deletions architecture/faust/dsp/libfaust-box.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
30 changes: 30 additions & 0 deletions compiler/box_signal_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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()
{
Expand Down
6 changes: 3 additions & 3 deletions compiler/boxes/boxes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/boxes/boxes.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion tools/benchmark/box-tester.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 6 additions & 3 deletions tools/benchmark/box-tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit 2a236c7

Please sign in to comment.