You're right, I will try enhance this doc ! ++
Sam. On Tue, Mar 19, 2013 at 6:09 PM, Rob Canning <[email protected]> wrote: > > ah haaa! (out loud... a number or times...) > this is great - i was so stuck trying to figure out wft was going on - > thanks for that sam! > this isnt mentioned here is it?: > http://savonet.sourceforge.net/doc-svn/language.html > because i stared at the section on "types" for some time scratching my head > thanks again sam - now i can move forward! > rob > > On 19/03/13 13:59, Samuel Mimram wrote: >> Hi Rob, >> >> Quite a subtle question as usual :) There are basically two kinds of >> encoding of floats used in Liquidsoap. The first is for constants (as >> in del=300.) which are simply of type float. The other one is used for >> floats which can vary over time such as those produced by osc.float: >> osc.float("/sc/topoverdel", 300.) has type ()->float which mean that >> it is a function, which takes an empty list of arguments and returns >> the current value of the float. You could define a function of this >> type manually, for instance by >> >> def x() = 300. end >> >> or even >> >> {300.} >> >> the second being a short notation for the first one. There is a little >> trick used in Liquidsoap, which makes that most functions can either >> take a constant float (a float) or a varying float (a ()->float); >> Liquidsoap chooses the right type for you. You can see this in the >> type: >> >> $ ./liquidsoap -h ladspa.bandpass_a_iir >> >> Type: (?id:string,?bandwidth:'a,?center_frequency:'b, >> source(audio='#c,video='#d,midi='#e))-> >> source(audio='#c,video='#d,midi='#e) >> where 'a, 'b is either float or ()->float >> >> * bandwidth : anything that is either float or ()->float (default: >> 295.831787109) >> Bandwidth (Hz) (4.41 <= <code>bandwidth</code> <= 19845). >> >> [...] >> >> This is the meaning of "either float or ()->float" above. However, the >> way you coded this forces deltime to be a float (and not a ()->float) >> because you multiply it by 1.5 and multiplication can only be >> performed between floats (and not ()->float). You can check this by >> >> liquidsoap -i test.liq >> >> pandelay : >> (source(audio=2,video=0,midi=0),float,'a)->source(audio=2,video=0,midi=0) >> where 'a is either float or ()->float >> >> We could extend multiplication for this case to work, but this is not >> done for now. So, if you want a ()->float as deltime, you have to >> handle the function explicitly, i.e. the following should be fine: >> >> def pandelay (z,deltime,f) >> z = ladspa.lcrdelay(id="", dry_wet_level=1., l_level=50., >> c_level=50., r_level=50., l_delay=deltime, delay={deltime()*1.5}, >> r_delay={deltime()*1.25}, low_damp=0., high_damp=0., >> feedback=90.,spread=50., z) >> z=ladspa.tap_autopan(frequency=f, depth=80., z) >> z >> end >> >> I hope this helps! >> >> Cheers, >> >> Sam. >> >> PS : thanks for the typo on infer_r_ed, its now corrected! >> >> On Tue, Mar 19, 2013 at 1:37 PM, Rob Canning <[email protected]> wrote: >>> hi, >>> maybe i didn't give enough information... >>> perhaps it is something the way types need to be defined in function >>> arguments? >>> or i somehow need to evaluate the <fun> before passing it as an argument?? >>> >>> On 15/03/13 15:34, Rob Canning wrote: >>>> hi! >>>> >>>> not sure why the value del here causes an error when uncommented while >>>> freqx work fine >>>> del is being passed on one function further but not sure why this causes >>>> a problem as its fine when i hardcode it with del=300. >>>> >>>> del=300. >>>> #del=osc.float("/sc/topoverdel", 300.) >>>> freqx=osc.float("/sc/topoverfreq", 11110.) >>>> >>>> topover = >>>> pandelay(ladspa.bandpass_a_iir(center_frequency=freqx,bandwidth=50., >>>> topover), del, 0.3) >>> my function is like this: >>> >>> def pandelay (z,deltime,f) >>> z = ladspa.lcrdelay(id="", dry_wet_level=1., >>> l_level=50.,c_level=50.,r_level=50., >>> l_delay=deltime, c_delay=deltime*1.5,r_delay=deltime*1.25, >>> low_damp=0.,high_damp=0., feedback=90.,spread=50., >>> z) >>> z=ladspa.tap_autopan(frequency=f, depth=80., z) >>> z >>> end >>> >>> the message from osc is created the exact same way as freqx so is >>> definitely a float >>> >>> any ideas? >>> >>> thanks, >>> >>> rob >>>> thanks >>>> >>>> rob >>>> >>>> At line 71, char 93: >>>> this value has type >>>> ()->_ (infered at line 60, char 14-37) >>>> but it should be a subtype of (the type of the value at line 10, char >>>> 24) >>>> float (infered at line 18, char 19-21) >>>> >>>> >>>> btw. inferred is spelt inferred not infered >>>> >>>> >>> >>> ------------------------------------------------------------------------------ >>> Everyone hates slow websites. So do we. >>> Make your web apps faster with AppDynamics >>> Download AppDynamics Lite for free today: >>> http://p.sf.net/sfu/appdyn_d2d_mar >>> _______________________________________________ >>> Savonet-users mailing list >>> [email protected] >>> https://lists.sourceforge.net/lists/listinfo/savonet-users >> ------------------------------------------------------------------------------ >> Everyone hates slow websites. So do we. >> Make your web apps faster with AppDynamics >> Download AppDynamics Lite for free today: >> http://p.sf.net/sfu/appdyn_d2d_mar >> _______________________________________________ >> Savonet-users mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/savonet-users > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_mar > _______________________________________________ > Savonet-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/savonet-users ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar _______________________________________________ Savonet-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/savonet-users
