grame-cncm / faust

Functional programming language for signal processing and sound synthesis
http://faust.grame.fr
Other
2.56k stars 321 forks source link

Add compiler option to pass parameters to a Faust program through shell invocation #398

Open dariosanfilippo opened 4 years ago

dariosanfilippo commented 4 years ago

In many cases, I need to test my networks just by changing one single constant and see the results for different values of that variable. That implies that I open the Faust file, I edit it, I save it, and then I compile it.

Would it be possible to have a compiler option so that, similarly to Gnuplot 5 and its -c option, parameters can be passed to a Faust program through the shell?

This would be handy for the example that I described above, but it would also be useful when a Faust program is used as a program generator. In my specific case, I am planning on turning a software library of mine into a music software that is piloted through very few essential parameters to generate different standalone audio networks. Hence, it would be great if the user could generate different networks from the shell just by changing such parameters rather than editing a file, saving, and then compiling.

Thank you for your time.

Dario

josmithiii commented 4 years ago

Hi Dario,

Are you aware that you can set Faust GUI parameters on the command line? Example: https://ccrma.stanford.edu/~jos/aspf/Offline_Processing_Soundfiles_FAUST.html

Cheers,

On Wed, Feb 5, 2020 at 5:05 AM Dario Sanfilippo notifications@github.com wrote:

In many cases, I need to test my networks just by changing one single constant and see the results for different values of that variable. That implies that I open the Faust file, I edit it, I save it, and then I compile it.

Would it be possible to have a compiler option so that, similarly to Gnuplot 5 and its -c option, parameters can be passed to a Faust program through the shell?

This would be handy for the example that I described above, but it would also be useful when a Faust program is used as a program generator. In my specific case, I am planning on turning a software library of mine into a music software that is piloted through very few essential parameters to generate different standalone audio networks. Hence, it would be great if the user could generate different networks from the shell just by changing such parameters rather than editing a file, saving, and then compiling.

Thank you for your time.

Dario

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/grame-cncm/faust/issues/398?email_source=notifications&email_token=AAQZKFMBFBQJNQN2XAP5TYDRBK2QHA5CNFSM4KQKYCMKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4ILGM44A, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQZKFJNLRYX4L6EGJNIU53RBK2QHANCNFSM4KQKYCMA .

--

Julius O. Smith III jos@ccrma.stanford.edu Professor of Music and, by courtesy, Electrical Engineering CCRMA, Stanford University http://ccrma.stanford.edu/~jos/

dariosanfilippo commented 4 years ago

Thanks, Julius. I wasn't aware of that.

But could you, for example, change the size of a Hadamard matrix?

Best, Dario

sletz commented 4 years ago

Two remarks here:

josmithiii commented 4 years ago

Yes, for hadamard matrices, I would compile all the sizes I wanted to try (only powers of 2), and switch among them at run time.

On Wed, Feb 5, 2020 at 2:33 PM Stéphane Letz notifications@github.com wrote:

Two remarks here:

  • only some of the faust2xx tools support this command line parameters for now
  • runtime parameters only can possibly be changed this way, not compile time parameters

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/grame-cncm/faust/issues/398?email_source=notifications&email_token=AAQZKFLHLDLPPSJE4JQ5MZLRBM5C3A5CNFSM4KQKYCMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEK5HQCY#issuecomment-582645771, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQZKFK7YZA2HIWX5EFIRP3RBM5C3ANCNFSM4KQKYCMA .

--

Julius O. Smith III jos@ccrma.stanford.edu Professor of Music and, by courtesy, Electrical Engineering CCRMA, Stanford University http://ccrma.stanford.edu/~jos/

josmithiii commented 4 years ago

only some of the faust2xx tools support this command line parameters for now

Is it straightforward to include some Faust architecture header file in your architecture file to give it options support?

On Wed, Feb 5, 2020 at 2:47 PM Julius Smith jos@ccrma.stanford.edu wrote:

Yes, for hadamard matrices, I would compile all the sizes I wanted to try (only powers of 2), and switch among them at run time.

On Wed, Feb 5, 2020 at 2:33 PM Stéphane Letz notifications@github.com wrote:

Two remarks here:

  • only some of the faust2xx tools support this command line parameters for now
  • runtime parameters only can possibly be changed this way, not compile time parameters

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/grame-cncm/faust/issues/398?email_source=notifications&email_token=AAQZKFLHLDLPPSJE4JQ5MZLRBM5C3A5CNFSM4KQKYCMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEK5HQCY#issuecomment-582645771, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQZKFK7YZA2HIWX5EFIRP3RBM5C3ANCNFSM4KQKYCMA .

--

Julius O. Smith III jos@ccrma.stanford.edu Professor of Music and, by courtesy, Electrical Engineering CCRMA, Stanford University http://ccrma.stanford.edu/~jos/

--

Julius O. Smith III jos@ccrma.stanford.edu Professor of Music and, by courtesy, Electrical Engineering CCRMA, Stanford University http://ccrma.stanford.edu/~jos/

sletz commented 4 years ago

Yes something like:

#include "faust/gui/console.h"

and this line in int main(int argc, char* argv[])

CMDUI interface(argc, argv, true);

josmithiii commented 4 years ago

Perfect!

On Wed, Feb 5, 2020 at 2:58 PM Stéphane Letz notifications@github.com wrote:

Yes something like:

include "faust/gui/console.h"

and this line in int main(int argc, char* argv[])

CMDUI interface(argc, argv, true);

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/grame-cncm/faust/issues/398?email_source=notifications&email_token=AAQZKFLW7BFH5PU5GE43IQDRBM77FA5CNFSM4KQKYCMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEK5JL2Q#issuecomment-582653418, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQZKFIVVZYEAMPB5ETM6KDRBM77FANCNFSM4KQKYCMA .

--

Julius O. Smith III jos@ccrma.stanford.edu Professor of Music and, by courtesy, Electrical Engineering CCRMA, Stanford University http://ccrma.stanford.edu/~jos/

dariosanfilippo commented 4 years ago

Yes, for hadamard matrices, I would compile all the sizes I wanted to try (only powers of 2), and switch > among them at run time.

That that would be a solution for small DSP processes, though I often need to change one parameter, say the feedback coefficient, of large networks, hence I wouldn't have enough CPU to switch among several.

I guess that what Stéphane suggests is an ad-hoc fix, though other users would be able to do the same without the modification.

Other than the ease of changing a parameter from the shell, it would make a Faust program more encapsulated following a black-box approach.

For example, using a Faust program to generate Kauffman's Boolean networks: the number of nodes and the topology is fixed, though the function in each node is selected randomly.

The user could enter a seed in the shell to trigger several pseudo-random generators in the .dsp code and flash a different network each time the seed changes.

Similarly to Gnuplot, something like this:

faust2caqt -double -parameter kauffman.dsp 0.0022993

The value after the .dsp would replace a special identifier inside the .dsp file, such as ARG1.

On Wed, Feb 5, 2020 at 2:33 PM Stéphane Letz @.***> wrote: Two remarks here: - only some of the faust2xx tools support this command line parameters for now - runtime parameters only can possibly be changed this way, not compile time parameters — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#398?email_source=notifications&email_token=AAQZKFLHLDLPPSJE4JQ5MZLRBM5C3A5CNFSM4KQKYCMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEK5HQCY#issuecomment-582645771>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQZKFK7YZA2HIWX5EFIRP3RBM5C3ANCNFSM4KQKYCMA . -- --- Julius O. Smith III jos@ccrma.stanford.edu Professor of Music and, by courtesy, Electrical Engineering CCRMA, Stanford University http://ccrma.stanford.edu/~jos/

sletz commented 4 years ago

There is no mechanism right now to easily give compile time arguments to DSP programs. Have you tried the more dynamic approach using the embedded compiler as in faustgen~ either for PureData https://github.com/CICM/pd-faustgen or Max/MSP https://github.com/grame-cncm/faust/releases ?

dariosanfilippo commented 4 years ago

Hi, Stéphane. No, I haven't tried those.

I don't mind opening a file and saving it but, as I said, it would be great if you could separate the user from editing the file completely so that a Faust program can be an autonomous environment used by the user to generate a set of programs.

Please take this feature into account for future developments if you all think is feasible and useful.

Thanks for your time, Dario