Closed smojef closed 10 months ago
I can repro... Looks clearly like a bug, I'll investigate.
Ok, floating-point rounding error when computing the increment for the linear interpolation... Fix will be up in 1.0.6 (I upload 1.0.5 wheels today). Simple workaround for the time being is to clip the output of Linseg to the intended range:
lin = Expseg([(0,0), (2,0), (2.1,0.001), (3.9, 0.01), (4,0)], loop=True).play()
linc = Clip(lin, min=0.0, max=0.1)
Thanks @belangeo for looking into this. Here is another test case where I see no obvious workaround. Can you confirm that your fix covers this case?
from pyo import *
sr = 8000
s=Server(sr=sr,nchnls=2,buffersize=100,duplex=0)
s.boot()
segments = [
(0, 100),
(0.99, 100),
(1, 440),
(1.99, 440),
(2, 200),
(2.99, 200),
(3, 820),
(3.99, 820),
(4.0, 100),
]
# Is this the way to have exactly 32000 samples per loop?
ls = Linseg(segments, loop=True).play() # Wrong values
modulo = ls % 100 # Even worse after some math
p = Print(modulo, method=0)
s.start()
s.gui(locals())
Output:
0.000000
0.000000
0.000000
40.000343
40.000343
40.000343
40.000343
0.000119
0.000119
0.000119
0.000119
20.000744
20.000744
20.000744
20.000744
90.999992
90.999992
90.999992
90.999992
31.000328
31.000328
31.000328
31.000328
91.000107
91.000107
91.000107
91.000107
11.000729
11.000729
11.000729
11.000729
90.999992
90.999992
Expected output:
0.000000
0.000000
0.000000
40.000000
40.000000
40.000000
40.000000
0.000000
0.000000
0.000000
0.000000
20.000000
20.000000
20.000000
20.000000
0.000000
0.000000
0.000000
0.000000
40.000000
40.000000
...
Best,
Hi @smojef , it's now fixed in master. Just a note about your last snippet, don't forget that there are a lot of samples in 10 ms (i.e. between 0.99 and 1 sec), it's likely that your Print
will output some intermediary values. If you want to print the stable part of the Linseg
segments, you can slightly delay the input of Print
, like:
p = Print(SDelay(modulo, 0.011), method=0)
With this, I get your expected output.
Hello, I am having a hard time with Linseg because it outputs values out of the supplied range. For instance, the following code:
Outputs:
The first loop is ok, but then it outputs negative values which are clearly not intended.
I was expecting a linear interpolation between segments. Did I missed something? Should I use another object instead?
Thanks,