Artefacts with phasor~ and poke~

gavspav's icon

I must be making an obvious mistake here but I am getting artefacts when recording into a buffer driven by a phasor~ that I do not get with count~.

Can anyone show me what I'm doing wrong?

Max Patch
Copy patch and select New From Clipboard in Max.

Thanks

pdelges's icon

Try to insert a +~ 0.5 after your *~ 176400..

gavspav's icon

Thanks yeah I forgot about that.

+~0.5 and trunc~ sorts it out.

Next question, can anyone explain why this works and what it does?

I guess it must mean that the sample index I am passing to poke increases by 1 each time but I don't really understand why or how?

Peter Castine's icon

When Max converts a float to an int, it does not round. It truncates.

Repeat the above sentence as many times as it takes to understand it. It is absolutely fundamental to how Max works.

If you want to round positive float values, you need to add 0.5 before truncation. If you need to, try it with a couple of values like 0.01, 0.25, 0.499, 0.5, 0.501, and maybe 0.999 to see why it works.

BTW, you need to *subtract* 0.5 before truncation to correctly round negative floats.

julienrobert's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Hi, I try to do the same thing; recording in a buffer~ using poke~ and a phasor~. I put a ~+ 0.5 after the conversion to sample but it still have artefact. Did I miss something?

cheers