File: Faust-complement.lib

package info (click to toggle)
faust 2.14.4~repack2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 276,136 kB
  • sloc: cpp: 231,578; ansic: 15,403; sh: 10,871; java: 6,917; objc: 4,085; makefile: 3,002; cs: 1,077; ruby: 951; python: 885; xml: 550; yacc: 516; lex: 233; lisp: 201
file content (47 lines) | stat: -rw-r--r-- 2,036 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
////////////////////////////////////////////////////////////////////////////////////////////////////
// SCANNER = passing smoothly between 'n' input to 1 output. ///////////////////////////////////////

// Version for a maximum of 4 inputs :
scanner4(nb, position) = -(_,soustraction) : *(_,coef) : cos : max(0)
    with {
        coef = 3.14159 * ((nb-1)*0.5);
        soustraction = select2( position>0, 0, (position/(nb-1)) );
    };

// Version for more than 4 inputs.
scanner(nb, position) = _ <: (_ , scan) : compare
    with {
        coef = 3.14159 * ((nb-1)*0.5);
        soustraction = select2( position>0, 0, (position/(nb-1)) );

        minimum = ((1/(nb-1))*(position-1)); //
        maximum = ((1/(nb-1))*(position+1)); //
        compare(in, sig) = select2(in>minimum, 0, sig) : select2(in<maximum, 0, _);

        scan = _ : (-(_,soustraction) : *(_,coef) : cos);// : max(0)
    };

////////////////////////////////////////////////////////////////////////////////////////////////////
// Wavetable generator, for waveshapping or wavetable synthesis ////////////////////////////////////

WF(tablesize, rang) = abs((fmod ((1+(float(ba.time)*rang)/float(tablesize)), 4.0))-2) -1.;

////////////////////////////////////////////////////////////////////////////////////////////////////
// RS latch (Reset-Set) ////////////////////////////////////////////////////////////////////////////

RSLatch(S, R) = latch(S,R)
    with {
        trig = _<:_,mem: >;
        latch(S,R) = _~(ba.if(S>0.5,1,_) : ba.if(R>0.5, 0, _));
    };

////////////////////////////////////////////////////////////////////////////////////////////////////
// Count until a number, then wait until Reset to re-start /////////////////////////////////////////

counterUpReset(nb, in, reset) = (in:trig), reset : (routage : memo2,_)~_
    with {
        trig = _<:_,mem: >;
        memo2(a, b)	= (ba.if(b>0.5, 0, _))~(+(a));
        compare(value) = ba.if(value>nb, 1, 0); // :trig;
        routage(d,e,f) = e, (f, compare(d) : RSLatch : +(f) <: _,_);
    };