[LAD] Prototyping algorithms and ideas
Albert Graef
Dr.Graef at t-online.de
Fri Feb 1 05:44:48 UTC 2008
Kjetil S. Matheussen wrote:
> The second problem (besides its lack of interactivity) I have about faust
> is that is purely functional. I have programmed lots of code in purely
> functional style, and I like it very much, so thats not the issue. But, I
> feel that being forced to work in one paradigm gives me less
> possibilities.
Yep, it takes some discipline, but you also get to reap the benefits
(clear semantics, better output code).
> It would be interesting to see how the routine would
> look like in faust, if you have the time. :-)
I don't have the time to really work out all the details of your example
right now, but looking at http://www.notam02.no/~kjetism/sandysth/, the
-1 or 1 decider should be easy to do:
max_add = hslider("Max add", 0, 0, 100, 1);
d(y,f,pc) = e(y,f,pc) ~ _;
e(y,f,pc,d) = select2(abs(y) < 1, -1*sgn(y),
select2(abs(f) <= max_add/100, -1*sgn(f),
select2(pc==1, d, -1*d)));
sgn(x) = (x>0)-(x<0);
process = d;
(Note that Faust's select2 is a bit different from if-then-else, it has
the branches reversed.)
Faust takes a bit of a different mindset. Instead of thinking in terms
of a memory cell to be changed, imagine a signal that changes over time,
then it's actually quite easy. Of course we've all been raised on a von
Neumann diet, so it takes some time to relearn how to do certain things.
But for me this is what makes Faust so much fun to use. :)
Albert
--
Dr. Albert Gr"af
Dept. of Music-Informatics, University of Mainz, Germany
Email: Dr.Graef at t-online.de, ag at muwiinfa.geschichte.uni-mainz.de
WWW: http://www.musikinformatik.uni-mainz.de/ag
More information about the Linux-audio-dev
mailing list