grame-cncm / faust

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

ffunction : underscore in file name breaks parser #246

Open giuliomoro opened 5 years ago

giuliomoro commented 5 years ago

Line 14 of file echo.dsp is:

fastpow2 = ffunction(float pow2 (float), <math_neon.h>, "");

if I run

faust -i -cn effect -a minimal-effect.cpp ./../effects/effects.dsp -o virtualAnalog/effect.h

I get: echo.dsp : 14 : ERROR : syntax error, unexpected LT, expecting STRING or FSTRING

However, no error is produced by

fastpow2 = ffunction(float pow2 (float), <mathneon.h>, "");
giuliomoro commented 5 years ago

any luck with this one? thanks

josmithiii commented 5 years ago

Hi Guilio,

On the latest master-dev, I cannot reproduce this:

jos@josimp:/l/fd/examples/SAM/virtualAnalog faust -i -cn effect -a minimal-effect.cpp ../effects/effects.dsp -o effect.h jos@josimp:/l/fd/examples/SAM/virtualAnalog head effect.h / ------------------------------------------------------------ name: "effects" Code generated with Faust 2.13.15 (https://faust.grame.fr) Compilation options: cpp, -scal -ftz 0 ------------------------------------------------------------ /

ifndef __effect_H__

define __effect_H__

/**** ...

What version are you using?

On Fri, Jan 11, 2019 at 3:46 PM giuliomoro notifications@github.com wrote:

any luck with this one? thanks

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

--

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

giuliomoro commented 5 years ago

Hi Julius, thanks for looking into this. I think this is an error with the parser. You may have missed that I have modified line 14 of examples/effects/echo.dsp to

fastpow2 = ffunction(float pow2 (float), <math_neon.h>, "");

so the filename has angled brackets and an underscore in the name (btw, this is needed for the platform I am using).

So here's the full steps to reproduce (on current master-dev fd6b49596aa50f383f9866ebf1fc73fdfa18deae):

josmithiii commented 5 years ago

Ah, ok, I see. I guess Faust requires a string for that argument. Maybe the compiler (preprocessor?) can replace "<>" by <> in the output?

Here is what I would do in the meantime:

faust -i -cn effect -a minimal-effect.cpp ../effects/effects.dsp | perl -ne '(m/#include "<(.+)>"/ ? print "#include <$1>\n" : print $_);'

and then of course the source looks like

fastpow2 = ffunction(float fastpow2(float), "", "");

On Mon, Jan 14, 2019 at 12:37 PM giuliomoro notifications@github.com wrote:

Hi Julius, thanks for looking into this. I think this is an error with the parser. You may have missed that I have modified line 14 of examples/effects/echo.dsp to

fastpow2 = ffunction(float pow2 (float), , "");

so the filename has angled brackets and an underscore in the name (btw, this is needed for the platform I am using).

So here's the full steps to reproduce (on current master-dev fd6b495):

apply this patch:

diff --git a/examples/SAM/effects/echo.dsp b/examples/SAM/effects/echo.dsp index e3cbe0ebf..ac314d216 100644 --- a/examples/SAM/effects/echo.dsp +++ b/examples/SAM/effects/echo.dsp @@ -11,7 +11,7 @@ dmax = 32768; // one and done dmaxs = float(dmax)/44100.0;

Nnines = 1.8; // Increase until you get the desired maximum amount of smoothing when fbs==1 -fastpow2 = ffunction(float fastpow2(float), "fast_pow2.h", ""); +fastpow2 = ffunction(float fastpow2(float), , ""); fbspr(fbs) = 1.0 - fastpow2(-3.33219Nninesfbs); // pole radius of feedback smoother inputSelect(gi) = _,0 : select2(gi); echo_mono(dmax,curdel,tapdel,fb,fbspr,gi) = inputSelect(gi) : (+:si.smooth(fbspr)

cd faust/examples/SAM faust -i -cn effect -a minimal-effect.cpp ./effects/effects.dsp -o virtualAnalog/effect.h gives echo.dsp : 14 : ERROR : syntax error, unexpected LT, expecting STRING or FSTRING

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

--

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 5 years ago

I think this is a better perl one-liner:

faust -i -cn effect -a minimal-effect.cpp ../effects/effects.dsp | perl -pe 's/"<(.+)>"/<$1>/' > ! effect.h

(Note to self: Stop playing with perl and get back to work!) :-)

On Mon, Jan 14, 2019 at 1:17 PM Julius Smith jos@ccrma.stanford.edu wrote:

Ah, ok, I see. I guess Faust requires a string for that argument. Maybe the compiler (preprocessor?) can replace "<>" by <> in the output?

Here is what I would do in the meantime:

faust -i -cn effect -a minimal-effect.cpp ../effects/effects.dsp | perl -ne '(m/#include "<(.+)>"/ ? print "#include <$1>\n" : print $_);'

and then of course the source looks like

fastpow2 = ffunction(float fastpow2(float), "", "");

  • Julius

On Mon, Jan 14, 2019 at 12:37 PM giuliomoro notifications@github.com wrote:

Hi Julius, thanks for looking into this. I think this is an error with the parser. You may have missed that I have modified line 14 of examples/effects/echo.dsp to

fastpow2 = ffunction(float pow2 (float), , "");

so the filename has angled brackets and an underscore in the name (btw, this is needed for the platform I am using).

So here's the full steps to reproduce (on current master-dev fd6b495):

apply this patch:

diff --git a/examples/SAM/effects/echo.dsp b/examples/SAM/effects/echo.dsp index e3cbe0ebf..ac314d216 100644 --- a/examples/SAM/effects/echo.dsp +++ b/examples/SAM/effects/echo.dsp @@ -11,7 +11,7 @@ dmax = 32768; // one and done dmaxs = float(dmax)/44100.0;

Nnines = 1.8; // Increase until you get the desired maximum amount of smoothing when fbs==1 -fastpow2 = ffunction(float fastpow2(float), "fast_pow2.h", ""); +fastpow2 = ffunction(float fastpow2(float), , ""); fbspr(fbs) = 1.0 - fastpow2(-3.33219Nninesfbs); // pole radius of feedback smoother inputSelect(gi) = _,0 : select2(gi); echo_mono(dmax,curdel,tapdel,fb,fbspr,gi) = inputSelect(gi) : (+:si.smooth(fbspr)

cd faust/examples/SAM faust -i -cn effect -a minimal-effect.cpp ./effects/effects.dsp -o virtualAnalog/effect.h gives echo.dsp : 14 : ERROR : syntax error, unexpected LT, expecting STRING or FSTRING

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

--

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/

giuliomoro commented 5 years ago

Yeah that would work for now, thanks.

UPDATE: When angled brackets are used (without quotes), then _ or numbers will break. There must be something wrong in the parser. Examples:

fastpow2 = ffunction(float fastpow2(float), <fastpow.h>, "");

works fine ;

fastpow2 = ffunction(float fastpow2(float), <fastpow2.h>, "");

fails ./effects/echo.dsp : 14 : ERROR : syntax error, unexpected LT, expecting STRING or FSTRING;

fastpow2 = ffunction(float fastpow2(float), <fast_pow.h>, "");

fails ./effects/echo.dsp : 14 : ERROR : syntax error, unexpected LT, expecting STRING or FSTRING;