Hi Karl, Yes, the Rust backend has been developed starting in 2017, with very limited experience in Rust at that time, and the generated code is far from optimal. It has been improved a bit recently by Fabian Keller (see https://github.com/bluenote10), but we know (doing some CPU test comparing the generated code with C++) that it has to be improved to reach the C++ level.
Concerning get_num_inputs and get_num_outputs methods, the currently generated code in the Rust backend follows what is currently done in C++ backend and other ones. But we could adapt the -uim option ( --user-interface-macros add user interface macro definitions to the output code) that is used in C++ (you can try to do : faust -uim food.dsp to see what is generated) and make it generated some constant in the Rust backend. Here is the typically what is generated in C++ : #define FAUST_INPUTS 0 #define FAUST_OUTPUTS 1 and we could make it work in Rust. What syntax do you suggest? Note that we can follow the discussion on the Faust Slack channel: https://faustaudio.slack.com Stéphane > Le 11 janv. 2021 à 15:55, Karl Schultheisz via Faudiostream-users > <faudiostream-users@lists.sourceforge.net> a écrit : > > Hello Faust friends, > > I am considering using Faust with Rust in an embedded system in a musical > instrument. I've been using Faust for a few months and have found the > learning curve shallow (I had some prior FP experience). Rust is even newer > to me and has a much steeper learning curve. I am also new to developing > complex designs with microcontrollers, although I do have previous experience > programming them. It is challenging for me to evaluate the feasibility of the > project, given that I may be guided by misconceptions. I expect to learn a > lot. > > The application is a digital sampler combined with an analog > synthesis/processing engine. I wrote a blog post detailing the story behind > the idea: > > https://schultheisz.com/2021/01/08/recursyn-analog-resampling-synthesizer/ > > I've done lots of research for this project already, but let me know of any > pertinent information resources. > > I am now integrating the compiled Faust code with the main Rust code. I chose > not to use an architecture file, as the Rust build system already has a > method of generating code at build time. > > In an embedded system, it is usually preferred to avoid unnecessary heap > allocation. The FaustDsp trait assumed by the Faust compiler provides certain > details at runtime which are known at compile time. Specifically, the numbers > of input and output channels are returned by functions. Upon inspection, the > functions (get_num_inputs and get_num_outputs) return constants. I suspect > that for all Faust programs this is true. > > Faust itself also leverages compile-time checking, so I find this > implementation curious. But given the low volume of Rust posts in the mailing > lists, I guess that the Rust backend isn't used very much and isn't a big > priority. > > If the Faust compiler could be modified to generate this information as > constants, then the Rust compiler would know the input and output buffers > sizes at compile time. That would allow it to check that the compiled Faust > code agrees with the way it is integrated. For instance, the mapping of > channels to I/O peripherals could be checked. > > I'm not sure what it would take to change this behavior, but depending on > that, I might try to contribute such an enhancement if it would be welcome. > > Karl Schultheisz > > > > _______________________________________________ > Faudiostream-users mailing list > Faudiostream-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/faudiostream-users _______________________________________________ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users