Skip to content

Box API Examples

Design sketches showing different ways the Faust Box API can be used in cyfaust.

Note: the Faust interpreter does not support vectorization, parallel code, or scheduler code.

Example 1

Original C++:

Box box = boxPar(boxInt(7), boxReal(3.14));

Functional (snake_case):

box = box_par(box_int(7), box_real(3.14))

Object-oriented:

box = Box(7).par(Box(3.14))

Hybrid:

box = box_par(Box(7), Box(3.14))

With auto-boxing of numeric literals (not yet implemented):

box = box_par(7, 3.14)

Example 2

Original C++:

Box box = boxSeq(boxPar(boxWire(), boxReal(3.14)), boxAdd());

Functional:

box = box_seq(box_par(box_wire(), box_real(3.14)), box_add_op())

Object-oriented:

box = Box().par(Box(3.14)).seq(box_add_op())

Hybrid:

box = box_seq(Box().par(Box(3.14)), box_add_op())