Am 13.04.2016 um 09:23 schrieb Simon Staudenmayer:
> Hello Faust-Team,
>
> I have a problem getting a simple source selector to work.
> The faust code is the following:
>
> switcher(channels,1) =_ , par(i, channels-1,!);
> switcher(channels, channels) = par(i, channels-1,!),_;
> switcher(channels, pos)=par(i, pos-1, !), _ , par(i, channels-pos, !);
>
> srces = 3;
> position = 2
>
> process= par(i,srces_): switcher(srces,position);
>
> This works, however, if I want to control the position with a slider, 
> e.g. like
>
> process = ...switcher(srces, sel_osci);
>
> it fails with "the node of the tree is not an int nor a float": I 
> tried already the following things, but all were unsuccessful:
>
> sel_osci = 1:*(hslider("oscisrc [style:knob]", 1 , 1, 3 , 1));
> sel_osci = 1:*(hslider("oscisrc [style:knob]", 1 , 1, 3 , 1)): int;
> sel_osci = 1:*(hslider("oscisrc [style:knob]", 1 , 1, 3 , 1)): int;
> sel_osci = int(hslider("oscisrc [style:knob]", 1 , 1, 3 , 1)));
>
>
> Another method, though no ideal (because of the merging :>), I tried was
>
> switch(k, srces) = *(k == pos);
> switcher(srces, position) = par(i, srces, _) : par(i, srces, switch(i, 
> position)):>_;
>
> This worked, but I got weird some audio artefacts (sometimes two 
> oscillators could be heard at once or the knob was very sensitive to 
> slight movements, and e.g. no giving me the first src at exactly 
> position 1 but at a small "off-1"-position).
> Is there a simple way to get the first example to work or an easy 
> alternative?
>
> Thanks in advance!
>
> Simon


here is how I've implemented a source switcher for 4 channels (first 
channel is a simple pass):

import("music.lib");
import("math.lib");

ch1 = *(0.5);
ch2 = *(1.5);
ch3 = *(2.0);

sel(n) = environment {

      a = min(2, max(0,n));
      b = min(2, max(0,n-1));
      c = min(2, max(0,n-2));
};

selfilter(n)  = _<: a <: b <: c :>_ with {
   a = select3(sel(n).a,_,ch1,_);
   b = select3(sel(n).b,_,ch2,_);
   c = select3(sel(n).c,_,ch3,_);
};


sl       = hslider("select channel",0,0,3,1);

process      =  selfilter(sl);

regards
hermann

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Faudiostream-users mailing list
Faudiostream-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/faudiostream-users

Reply via email to