< Back to IRCAM Forum

Om-sample problem

Hi forum,
I found an issue trying to sample a list and a bpf (both with length=11).
om-sample gives me different list lengths if I use sample-rate=27
Please, see attached picture for a better explanation.
Let me know if someone has the same problem. Thanks in advance!

OM 6.8_r4
MacOSX 10.6.8

Best regards,
RC

om-sample-thing.png

Yep, it happens. With 14 samples (samples 4), then with 27 (samples 26)… I can only expect it to sample it wrongly many more times as number of samples goes up.

Anyway, you should consider adding a preventive patch of code. Perhaps with an if testing whether the right amount of samples is being output. You would then add one more sample: perhaps a mean value between any two adjacent values. If you don’t want the if, just sample more than you want (I’d say just one more sample) and then use first-n with the correct number of samples you want.

Hope this helps.

OM-sample.png

Sampling two times also seems to work.

Here it goes.

OM-sample-two-times.png

…After more inspection, it seems the problem is really with sampling a BPF on its first output (self). If you sample two times by using the self output of OM-SAMPLE, the same error recurs. If you sample the list of Y-values (third output), it works OK.

Hello,

Using the y-list is ok as long as you don’t need to x-positions of the points (or when they are evenly placed like here).

The general case (with BPF) fails in some particular cases due to floating point approximations.
I think the attached fix will solve it in this particular case. It uses double-float precision intead of single float.
(put the lisp file in OM 6.8/patches/)

[Here, we want 27 points between 0 an 1000, the “step” of the result is 1000/26 = 38.46154 (in single float approx.) The 27th point (26x38.46154=1000.00007) is then > 1000 and not included in the result. In double float precision, the step would be 38.46153846153846 and the 27th point is 1000.]

om-sample-double-precsision.lisp (2.24 KB)

1 Like

Hi Gato, hi Jean,
Thank you very much for your answers and solution, now it works! :slight_smile:
best,
rc