Osc float type value

Hi,

i met a problem with sonic pi 3.2 receiving float value with one decimal sent via open-sound-control.

As you can see the sender sends the good value but spi keeps the whole float number.
Is it a bug or not .
Cheers

I don’t know where this is coming from but as far as I can see you can handle this in SP via:

msg.round(2) # 0.20
msg.round(1) # 0.2 
1 Like

This isn’t a problem with Sonic Pi specifically it’s a problem with floats. They are not precise and are always subject to strange precision errors like this - especially when being converted between systems.

If you want reliable symbolic numbers, you have to use integers. You could use one integer for the whole numbers and another for the 0.1s and another for the 0.01s etc.

1 Like

While working with external devices and/or software (Midi and OSC) I also noticed this. But I think it is more a problem of representation (a value with 10 decimal places might be difficult to read or confusing) than of audible precision (I am sure you won’t be able to hear any of that). That is why round did solve the issue for me.

1 Like

Even rounding to 4 decimals will be fine. Even so I doubt you’ll need to worry about the noise in the lower end of the number. It is more than 8 places after the decimal comma, it is basically nothing.

1 Like

ok thank you for all these precisions. In reality i don’t need to round the value for the script to work into spi.