I had another look and using floats is still problematic in single-precision; pulses won't take place at the exact BPM for low BPM values.
The problem with the current ba.beat implementation is that it checks against 0: if we decrease the second operand of the % operation, there is no guarantee that the output will go through 0 when wrapping around. What we could do is to check if the first difference is negative to cover the more general case of wrapping around: import("stdfaust.lib"); bpm = en.ar(20,10,1) * 2000; beat(t) = (diff(ba.period(ba.tempo(t))) < 0) + impulse with { diff(x) = x <: _ - _'; impulse = 1 - 1'; }; process = beat(bpm) , beat(bpm); Ciao, Dr Dario Sanfilippo http://dariosanfilippo.com On Sun, 1 Aug 2021 at 16:12, Dario Sanfilippo <sanfilippo.da...@gmail.com> wrote: > Hi, Henrik. > > It could be due to some integer overflow in the ba.beat function; you > could try that in double precision to see if it works better. > > Otherwise, here's another way that appears to be more robust: > > import("stdfaust.lib"); > imp = beat(en.ar(20,10,1) * 2000); > beat(t) = diff(os.phasor(1, t / 60.0)) < 0 > with { > diff(x) = x <: _ - _'; > }; > env = en.ar(0.00001, 0.05, imp); > snare = no.noise * env * 0.1; > process = snare , snare; > > Ciao, > Dr Dario Sanfilippo > http://dariosanfilippo.com > > > On Tue, 22 Jun 2021 at 21:05, Henrik Frisk <fris...@gmail.com> wrote: > >> Hi, >> >> When I run the snippet below it's as if there are hickups in the stream >> of pulses. These come at random but most commonly in the beginning of the >> envelope. I have tried it compiled to SC code and to jack stand alone code >> on both Linux and OSX as well as in the online compiler with the same >> result. >> >> Is there a better way to achieve a smotth accelerando of pulses? >> >> imp = ba.beat(en.ar(20,10,1) * 2000); >> env = en.ar(0.00001, 0.05, imp); >> snare = no.multinoise(8) : par(i, 8, _ * env * 0.1); >> process = snare; >> >> Thanks! >> /Henrik >> _______________________________________________ >> Faudiostream-users mailing list >> Faudiostream-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/faudiostream-users >> >
_______________________________________________ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users