GithubHelp home page GithubHelp logo

Issue with Linseg output about pyo HOT 4 CLOSED

smojef avatar smojef commented on June 9, 2024
Issue with Linseg output

from pyo.

Comments (4)

belangeo avatar belangeo commented on June 9, 2024

I can repro... Looks clearly like a bug, I'll investigate.

from pyo.

belangeo avatar belangeo commented on June 9, 2024

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)

from pyo.

smojef avatar smojef commented on June 9, 2024

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,

from pyo.

belangeo avatar belangeo commented on June 9, 2024

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.

from pyo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.