Triggering sah~ only when going reverse

Oct 9, 2011 at 1:29pm

Triggering sah~ only when going reverse

I’m trying to use sah~ to sample a value when I hit 0.001 of a Phasor~ but I only want this to happen when I’m going from 1 to 0 and not 0 to 1.

I tried using delta~ and < ~0 to open a gate~ only when I'm going backwards, but the moment it opens, it triggers the sah~ regardless of what the value is at.

I also tried edge~ but I don’t want to make it to 0.999 going backwards. I want it to stay above 0.

The intended purpose is to keep a phasor~ (in this case groove~) within a certain range (so when it hits 0.001 it jumps up to 0.3 or whatever else).

———-begin_max5_patcher———-
1376.3oc4Zt0aihCEG+4zOEV4kUZUmHeGX09x937YX0nUDvgvrDbD3Lc5LZx
m80WfzzVf3biln8ERMPhO924b96is6OeXxz4xuKpmB9CveClL4mOLYh8VlaL
oo8joqh+dRQbs80llHWsRTpl9n6YJw2U16+Yfrr3YvSwkJfRBTU4YYhJfZo.
TGubK3okhRvmAKyU.3LHDAxj4kYf4wI+6SwUo0yZ+EKxKEIxMk1eVRyMWGqR
Vpe++oRjnblKMLbF7Q.MvbESwlOBXyffuz7cxSsFlb9W+DA19quPVpJiWIrO
5upxiKZeR4lU4kEBkcXh160WDmHd68py+g8dX8X4kuubip8G.Zt4ud3AykGO
SzpVlW2BzZKHEeSi1Jy0ZAP+PQYVblHUeqLMKKD00.4B8aFq9sZvx30qEkZ3
0IgYsDtRTq67XUtrbOJynlQHfPsvF1bYGi6vuvHL22v5QPnAcL3vyvwz5Drc
wU2IT8rIdUGZuQybSXcVrR.Rz1QkrPy94OCREEp3sl2wlKzlCXC8cg6M9rSw
SPBsbkh395InQHatAh3imH3twS7pzgFYDoZIHM2L10TqtS9h6mTnHKaYn8iY
IzdHE+ViT0Ix0hsSOPlLxpTRhv9F+PBoNNXgCxoDvC5gJzNG63K1frT7jted
WzPoLu9ficBKxlIDz8X2YYpmWKbu9z57rRsyzC3fCsoiT6ULrG1PtlQLnKGL
MRZ6X4oPEpS7GGRbZUCQETzQRE7GDU9ys.3k.JTKTZZzCTX36Dn3lq6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8v+osZC9J
———–end_max5_patcher———–

#59222
Oct 9, 2011 at 1:56pm

Hi Rodrigo

there may be a more efficient method (perhaps using [!-~ 1.] to invert your ramp, I dunno), but with a simple change to your patch it seems to work as you require – after [delta~] replace [~ 0.01]: [delta~] gives positive OR negative values, depending on ramp direction.

– Pasted Max Patch, click to expand. –

Brendan

#212750
Oct 9, 2011 at 5:42pm

I tried something similar before (using edge~) but I ran into a couple of problems. First, if I’m understanding it right, using delta/edge tells me when I’ve gone from >0 to <0 (so going from 0.001 to 0.999), which is 'late' in this circumstance.

I also want to try doing it in the signal domain completely rather than using signal to edge/bang, and back to signal.

Lastly, I’m using this in conjunction with minmax~, so going from 0.001 to 0.999 fills minmax~ with the maximum value, breaking it until I reset.

I was hoping to avoid that by going sample accurate so I would capture the value from minmax~ using sah~ and jump up to the highest value minmax~ had read, before hitting 0.

Here is the patch with minmax and the delta/edge method.

———-begin_max5_patcher———-
1571.3oc4ZsziaaCD9r2eED9xtocigHEodzCEnG68hdoInfVl1VIRjFRz6iD
D+au7gjs2rVxzVVB1n.KDWJQINy2L7algze+tQimJdgUNF7af+ALZz2uazHy
sz2XTU+QiyoujjQKMCabhHOmwkiez9LI6Eo49xkok.AO6Uvyhhup+2DF3AJe
FHsjeuDTRyWkw.zjj0ETI6C0efrTNKQrla9JnpatpfUplDpLUv+2BVhzJgjP
7DuGA93XciW0EvmqeKpLYYJewduAJ1LTLwz.sunOduWJclQ7ES+xGwnZgZtf
K4zbl4Q+QQJMq9I704o7Llz.Fv8FdY52LCGhTSw1wJVKqGrm9l+3t6zWdrif
MbBnfQmAn0vZJWJ.SWOeNq.7vRZIP2kAtWOp6A59KYfxW4I.kDADyAKJDhmX
aTFGPISpGNxyyKu7Ceh+INZBXYpDrJi95m391NErmXEkJC3boZNfp2JQvmoG
Mdh4qqG8TZxWAeYc9pRv7BQNvS+gg1gBdv3hn964kTI3OAOS4Ryz8W52tPLM
ikqerBfUfvF0LlvRehUpzxmnYqYZwNJRIl5oqnVR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xMm139CJ9MCZY5rYLyyqEv7zYqDpTRpDBvmOnM6h
JSAmnLgvg5xdvgj8BB+1dvHaSXjs.Ii6d2zDW.WxooHXbrQQp2o3vs85pvhb
UZgClq.xI2Szf5dpO3o8ffCKSHxfJSt.SvSDlTT+JOKeOaYhwda60U7KxEg0
aXsoAtHSQCqL4jQMXPkICq6w78gCquuNQ3iGtXfscndvGudMnpt.xVleSugv
phPmU.2smYW71dcEagtXuQWc7uwmC8aUpIjcc5njF2C4VUIcQ9ll5zm76teo
K4OchjM0hmOT2TAx5Nc0CvknZACa1Sj3qOYJvyEa5vxVG3RFcjgsHn.mX4F1
rjBP8.4ADEWyW38F1Cugf8HXfyepOJssqxTfqrDCbdlGUlvmFyUkuEBV8awD
us2fIsC3ln3fHEdV67fuE3v00Gh6drSm14gAE9PtHRjtjjopyOt6+.TB4FqG
———–end_max5_patcher———–

#212751
Oct 9, 2011 at 9:12pm

sorry i been busy. gonna look into this again soon. in mean time, leave the turning into a float until the last possible moment

– Pasted Max Patch, click to expand. –
#212752
Oct 10, 2011 at 10:55am

I had snapshot at the very end as well and it was filling the float just fine, (though not sample accurate) but the problem is in one of two places.

If I use delta/>0.5 then I’m sampling after it goes 0.01 to 0.99 (as that’s the only time that the delta value would be >0.5) which breaks the use of minmax~ as it then reports the highest value (0.99).

If I use the sah~ 0.001, it seems to sample before it goes to 0.99, but the problem is it does it going both directions.

The version that n00b posted only triggers going backwards but I think it’s doing it at the same time (post 0.99)

I’m starting to wonder if I should just drop the sample accurate part and hack it with control objects (edge/bang a float, then gate the value going to minmax~ or something, so it works over and over).

Or maybe opening the gate to minmax~ only when going forwards (as I don’t care about minmax when going backwards).

#212753
Oct 10, 2011 at 11:11am

Ok, so I tried gating the numbers going to minmax~ based on the direction I was going. So only letting values through when moving forward, as that’s all I care about, the “high water mark”. When going backwards, I want to jump to the highest value set by minmax~, I don’t want minmax~ to report anything at that point.

I tried using delta and >~0 to report when I’m going backwards and it works fine, except that once a cycle, it opens briefly (when going from 0. to 0.9), which breaks minmax~ again.

I then tied the gate to the reverse toggle, and this seems to work except it’s back in the control domain.

I tried using delta and >~0.01 like in n00bs posted version but that got me nowhere. Is it possible to close a gate when going backwards without having it pop only momentarily when the cycle wraps around (which is what delta is doing).

Here’s the patch with delta~/gate~ and toggle/gate~ versions.

– Pasted Max Patch, click to expand. –
#212754
Oct 10, 2011 at 11:22am

And finally here’s a working version (in control domain) of what I want it to do.

It starts playing back the sample, then when you reverse, whatever the highest point you got to, it jumps back up to that on the next play through, and keeps doing that if you go up to a higher number.

– Pasted Max Patch, click to expand. –
#212755
Oct 10, 2011 at 2:06pm

hi rodrigo. sorry about that last patch i posted. was in a rush and it was probably crap.

the last patch you posted above is the best yet and seems to me the way to go. works great and, after all this time in the other thread and in this thread, i think i finally understand what you are trying to do (!!).

i had a couple small points / ideas (e.g., surely you mean to also trigger ‘reset’ on loop point of forwards, too, in case it goes past that?). i commented your patch a small bit and then took the liberty of making a possibly slightly more accurate version (see the subpatch). working very good here for me:

– Pasted Max Patch, click to expand. –

if you want samplerate triggering, investigate a [play~] solution, and / or wait for Max6 !

cheers.

#212756
Oct 10, 2011 at 2:40pm

Yeah it’s difficult trying to communicate something like that, particularly when I’m not great at signal domain control stuff anyways, so I was likely explaining things wrongly anyways.

Yeah I would trigger [reset] more often than that. The actual patch has this wrapped into the recording routine so it would only need to be reset when a new loop is being created (and this whole reversing to max point only happens during that loop creation). It’s all to be able to record forwards and backwards when creating the initial loop.

I know that groove~ isn’t the best, but I have all of my patch built around it at the moment, and don’t want to start it again from scratch completely in the signal domain.

The subpatch you made looks great! I’ll give it a good sit down and wrap my ahead around what’s happening.

Thanks again for your help with this.

#212757
Oct 12, 2011 at 7:26am

Here’s an audio-rate solution (kinda; it might not be exactly what you’re after but it does show that it can be done):

– Pasted Max Patch, click to expand. –

HTH!

Chris

#212758
Oct 12, 2011 at 7:55am

Hmm quite interesting! Thanks

Now if I can only stop getting poke to sound like a crap when I record backwards! (http://cycling74.com/forums/topic.php?id=35533)

#212759

You must be logged in to reply to this topic.