Forums > MaxMSP

snap to zero crossing

November 23, 2007 | 3:27 pm

Hello all.

I have been searching the max list about this, but haven’t found anything that answers my question:

Is there any way to find the "nearest zero crossing" point in a buffer without using waveform~ or tap.buffer.snap~?

I am using both in a Poly~ and the CPU hit is dearer than I’d like….

At the moment I am simply feeding a Wave~ a start and endpoint, and using waveform~ to snap to the nearest zero crossing to prevent clickiness.

Any other way to do this I have missed?

All the best, Jeremy


November 23, 2007 | 6:00 pm

Jeremy Keenan schrieb:
> I am using both in a Poly~ and the CPU hit is dearer than I’d
> like….

I can’t imagine that an abstraction would do it more effective than
tap.buffer.snap~, but just count on to the next zero crossing left and
right and take the shorter one…

You might want to limit the range, as it is well possible that the next
zero crossing is two hours awy from your starting point… ;-)

See if thats faster than the others…

Stefan

#P button 380 289 15 0;
#P window setfont "Sans Serif" 9.;
#P number 268 126 48 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 377 399 118 196617 +;
#P newex 485 377 23 196617 – 1;
#P newex 412 210 24 196617 !-;
#P button 177 83 15 0;
#P message 69 117 50 196617 replace;
#P number 226 213 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 69 205 68 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 177 111 53 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 298 458 97 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 243 436 65 196617 sampstoms~;
#P message 412 329 34 196617 break;
#P newex 377 377 87 196617 < 0.;
#P newex 454 357 35 196617 abs 0.;
#P newex 454 328 29 196617 float;
#P newex 377 328 29 196617 float;
#P newex 377 357 35 196617 abs 0.;
#P newex 412 281 32 196617 > 0.;
#P newex 412 303 40 196617 togedge;
#P newex 412 256 76 196617 peek~ mysound;
#P newex 351 377 23 196617 – 1;
#P newex 278 209 36 196617 +;
#P message 278 329 34 196617 break;
#P number 318 130 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 263 71 98 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 263 92 65 196617 mstosamps~;
#P newex 232 160 204 196617 t b 0 i;
#P newex 232 183 56 196617 uzi 4410 0;
#P newex 243 399 118 196617 +;
#P newex 243 377 87 196617 < 0.;
#P newex 320 357 35 196617 abs 0.;
#P newex 320 328 29 196617 float;
#P newex 243 328 29 196617 float;
#P newex 243 357 35 196617 abs 0.;
#P newex 278 281 32 196617 > 0.;
#P newex 278 303 40 196617 togedge;
#P newex 177 138 65 196617 mstosamps~;
#P newex 278 256 76 196617 peek~ mysound;
#P window linecount 3;
#P newex 69 153 67 196617 buffer~ mysound drumLoop.aif;
#P window linecount 1;
#P comment 265 50 45 196617 range;
#P window linecount 2;
#P comment 173 50 44 196617 starting point;
#P connect 4 1 14 0;
#P connect 4 1 40 0;
#P fasten 14 2 19 1 431 184 309 184;
#P connect 14 2 37 1;
#P connect 14 1 19 0;
#P connect 14 1 37 0;
#P fasten 18 0 13 0 283 320 218 320 218 180 237 180;
#P fasten 29 0 13 0 417 320 218 320 218 180 237 180;
#P fasten 17 0 13 1 323 150 283 150;
#P connect 14 0 13 0;
#P fasten 13 2 37 0 283 205 417 205;
#P connect 13 2 19 0;
#P connect 13 2 34 0;
#P fasten 39 0 30 0 382 420 248 420;
#P connect 12 0 30 0;
#P fasten 22 0 25 0 417 323 382 323;
#P connect 22 0 41 0;
#P connect 22 0 29 0;
#P fasten 22 0 26 0 417 323 459 323;
#P fasten 22 1 25 0 447 323 382 323;
#P connect 22 1 29 0;
#P fasten 22 1 26 0 447 323 459 323;
#P connect 37 0 21 0;
#P fasten 37 0 38 0 417 233 490 233;
#P connect 26 0 27 0;
#P connect 25 0 24 0;
#P fasten 21 0 25 1 417 277 401 277;
#P connect 21 0 23 0;
#P fasten 21 0 26 1 417 277 478 277;
#P connect 19 0 3 0;
#P fasten 19 0 20 0 283 249 356 249;
#P connect 38 0 39 1;
#P connect 28 0 39 0;
#P connect 20 0 12 1;
#P connect 9 0 10 0;
#P connect 8 0 7 0;
#P fasten 5 1 8 0 313 323 248 323;
#P connect 5 1 18 0;
#P fasten 5 1 9 0 313 323 325 323;
#P fasten 5 0 8 0 283 323 248 323;
#P connect 5 0 18 0;
#P fasten 5 0 9 0 283 323 325 323;
#P fasten 3 0 8 1 283 277 267 277;
#P connect 3 0 6 0;
#P fasten 3 0 9 1 283 277 344 277;
#P connect 36 0 32 0;
#P connect 35 0 2 0;
#P connect 32 0 4 0;
#P connect 23 0 22 0;
#P connect 6 0 5 0;
#P connect 2 0 33 0;
#P connect 7 0 11 0;
#P connect 11 0 12 0;
#P connect 16 0 15 0;
#P connect 30 1 31 0;
#P connect 15 1 17 0;
#P connect 10 0 11 1;
#P connect 24 0 28 0;
#P connect 27 0 28 1;
#P window clipboard copycount 42;


Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
– _|_)—-|—–()————–
———-()——–www.ccmix.com


November 23, 2007 | 6:44 pm

pre-analyzing the buffer content and building a second lookup buffer might also be a strategy to consider. i am doing this quite a lot in java, there it is quite easy (and fast) to precalculate some kind of offset lookup buffer (with equal size of the original one) that stores at each index the position of the nearest zerocrossing.

micha


Viewing 3 posts - 1 through 3 (of 3 total)