evenly dividing up a stream of floats
OK, I’m having a brain freeze today. I know I will slap my forehead on this one when someone gives me a clue!
I have a stream of floats going from 0.0 to 1.0 (which represents a quarter note duration). I would like to send a bang at specific, evenly divided points within that stream. For example, just at 1.0 (quarter note), or just at 0.5 and 1.0 (eighth notes), or just at 0.25, 0.5, 0.75 and 1.0 (sixteenth notes).
How do I cleanly do this? It seems like it should be a one or two object operation, but for the life of me I can’t figure it out today!
Have a look at [%] although be careful as dealing with floating point numbers can cause problems, you might want to scale it up by multiplying by a power of ten, depending on the resolution you want.
----------begin_max5_patcher---------- 419.3ocyUEsSCBCE8Y3qn1DeCw1tga3a9cXVLEnaqFncAJwoK6eWZAbtkAT0 MhuzFt8x8dNmdto6bcfQxsrBH3Qvy.GmctNNlP5.NMe6.ynaiSoElzfQkJkT .8pOZCUEulKV8RNKVUWlfY9HO.9gI5MBpcErn4WDkYbQJSYJG9PPYo5zn7DS KkQudGgz1x57TuugU2OXDUrBBVnOcuqqdwyRtHXuUU61BqXaMT.VvRAH+go3 TrdaRncTboTnDzLCpgOkyoovyRdxYHOpex6AfvuZttOE7OLIfI9negtrLUVg ogE.rg5Anqt.fC6T.pvJUoUfFavkSE5vcby8.belCLdtVOlEXLGD+f9zFxOT aNyjANX.s4hpIkYQr7gYevjwxYLsS1yEWGegkSG0FfwPBH+eFNts+YiZkIzr Ne.k4RLZf50bXidXxAlxEm9Jogc53GKRExx731lzd6.NPwDVghKnJd0aneKI zQIslmjvLmiZhjwS1HqvbCH530NqwTfsXBOdXBYClBGUchXClHjw8tKzFLMx 9oo1b2E7GvT0G6c+D.2fwwO -----------end_max5_patcher-----------
Yup, that’s it! My forehead is nice and sore right now!!
Thanks a million.
OK, so I spoke too soon. What I’m really trying to do is to take ReWire timing info via hostsync~, and to be able to fire off bangs at eigth, sixteenth, etc.. intervals.
The patch below, although I think technically correct, yields extremely poor timing:
----------begin_max5_patcher---------- 576.3ocuVssabBCD8Y3qv0R8kJ5Va.Cr8s9cTEUwEmccEXuBLpaZT52dsMPx tq.CIgvKFXvdly4vLCyitNvLwYZCD7cvOANNO553XLoM3z+rCrJ8bdYZiYaP o3vgRJzq6UmRk4GY7C+pllK6biOgrC4A1qW7QCqf65OAushwKoRi2vuXTzJu 0ZmI4CmncdFx3pXL3HVgAOhre+Uen1zStt5EuERjrVoTvsPDLlri3Avw9e.T IKkeXTtPvuExnhZFs1FYPXMYRvZVDDpWwIywk6EbYC6uFLi07eLJ5a6qkmEl hwIvKBDOsxbR3OpYokuIQf9GkeG7ojd1vc3WTXGsadsgDXzlX6Zi+qQal7y+ 8khzwyk26uIhxm9FHDgrIJjjKRXh1BQYpx63sQRZnk.zB5GDZxPB7MOrNRhu 01Dphnw0E75pKsUTdqMAHLvTmX5dPPqXOjfAxIoU8+MJTwZOE0S5uhidNNS0 oYRgJxlPMjFnbWenA2sdIUeFfWPJkVFW4TpWcUVHdSpxNJZj4p.TKJ+m0oHB 0hQnYVhHxJlqgFY9AzlQ8lG3413cDtqGigvg3Uj2XzLkOWeo6OTpaJYMWa34 a524vFlJwJXgpq4rJuwucfTiLosesj2HZqyG3P2XfdfWTpBZijwSkL0PdWrG zUa5HqnfxuLsnhUbRnnh8dAKER5NO.7LXJ1eSwT7RzovqA9GMlLgaNLEi2Vc ZIXhrsXZ+R91YFrdCA0swyRF01AJcWGPvLXZ+6oxS8vSt+W9Q5WV -----------end_max5_patcher-----------
I took your advice and scaled up by 100 and using ints instead. Overdrive is on.
Have you tried hooking that outlet of [hostsync~] straight into a [print] object? It might be that the timing resolution here is causing the problem. If it is skipping a lot of numbers then you will never hit exactly on your divisions and the bangs won’t get triggered. If this is what is causing the issue then you might be able to use [line] to send out all the numbers in between the values at a rate determined by the tempo of the track to keep it smooth. It’s just a thought but good luck!
You’re right! Here’s a sample of the output:
I’ll think about the line approach you suggest, or perhaps I’ll have to use the raw ticks or sample count output instead…
I’ve never used hostsync~ before, but as far as I can tell, hostphasor~ would be much better for your purposes. It basically outputs the same thing, but as a signal which you can treat exactly like a phasor~. You will almost certainly get better timing this way. For example:
----------begin_max5_patcher---------- 587.3ocyVEriaBCD8L4qvqk5sTpMfIPUuTo9WTUUY.mDuBrofoMcWs4auXCj ktMgBrIzdYr7fY3MuYdC9wUVvH4AVID7dvmAVVOtxxx3R6vpcuELidHNkVZN FLVlkwDJ35lmoXGTF+9HPTdVm6sRgRPyXlG8wBNMs6IhpLtHkoLQC+rSYkpy Kp0aNUEumK180BVrpAiXBwFsFrwX8wZqCxFA9R6qvSLeQYz8uEi5ClR9CFvf crQZuOsZk1r9Ul0eh+cdIWJ.xsfuUQKTrBfPpX2ZdvwuGCfIngHhfqHOvdHg Fe7r4fyTyAeuFvaV7Hc1ykB9vYf0ZfDwJtJUBm+ZkHXi1NbgfboBQq6lOn5m 4rlPC45NN.LhJ1AOEvZvxypxLu6LXknJkRJlPtiGRM1n.8LKaB6rmK4cgWJK aSu4TgY+nNz+gnLeOsTVbDfmXs2Yl4OF4ZDidCNNZpE+R9NQMPulDycuCfrI 2bVIzwvJ9AFIAYHVwaxZhsoRp5pxJe33hvJs8JglE+gGTP9OnYgkric7VO8r aBBt2OAtHqDLUVwLYY8MXBSsPBaey6XZ+AoqQG0XuH2D9uWG8liKkFx22vHN CwH9nqgFxDYXJW7xKIaPm1+uySkxph3t.1N1G7L9RXkJtfppuwXuyngZuCsm mjvD8u7TFOIWVeYfVLbgh1XgDYDPxiLMH4rwylnuLWXSMAeZ2B.Vcy+b.qqY HLdi6ocuVvFLBz5tnEauQQf5CgWtFvvwJJVPLMJdJXQqcuXtv.0t4ho5MOs5 WXDCoVI -----------end_max5_patcher-----------
That’s a good suggestion, thanks!
Forums > MaxMSP