Keeping a phasor within a certain range (when toggling direction)?

    Sep 27 2011 | 11:15 pm
    I'm working on a looper type thing that I want to be able to change directions while recording, but have it wrap around to the highest point I've gone to, rather than the end of the buffer.
    I'm using a rather large (30sec) buffer, and rarely use all of it. So if I start recording a loop, then 3 seconds in, go reverse for 2seconds, then forward one second, everything works fine, but if I reverse past 'zero' then it starts writing at the very end of the buffer, which is useless once I start playing back.
    What I want is for the highest number I've gone to to act as the 'loop end' (even though I may go past it later on), so if I reverse past zero, it would jump to, and start writing from that loop end (which I can then go forward and write past that too).
    I'm using minmax~ to keep track of my highest point (this also determines the maximum loop point for repetition). I can't figure out how to determine when I've gone from above 0. to 0.99 I've tried select, thresh~, and edge~ (something else which I forgot) and nothing reports the 0. to .99 change. Actually I don't want the 0.99 change to happen, so I want to know when I hit 0. so I can jump to whatever the highest point I was at.
    Any suggestions on what object(s) to use?

    • Sep 28 2011 | 2:50 pm
      Here's some code which demonstrates how I was testing.
    • Sep 29 2011 | 10:08 am
    • Sep 29 2011 | 4:22 pm
      Hmm not sure how to incorporate that.
      The output of edge is just banging depending on the signal direction, which doesn't seem to help as I know the direction I'm going from the reverse toggle. Both bang seemingly at the same time when I cross zero though.
      Not sure what to do with the sah~ there either in this context.
      Basically I want to jump up to a predetermined point in the sync output when I get to 0. (or 0.00001 or whatever). I never want to make it to 0.9x specifically, I want to bang/jump to somewhere else (while still going backwards).
      Here is an updated version which incorporates the bit you posted.
    • Sep 29 2011 | 9:06 pm
      sorry, i maybe misunderstood you. in fact it is very likely that i did. i am not entirely sure what you are wanting final result to be, but, if you want to sample accurate exactly detect ramp start of a groove~ sync or a phasor~ or whatever, regardless of direction, this is how you do it [your patch annotated]:
      hth at least!
      p.s. - you might also look at [%~] and [pong~] and [clip~] etc etc.
    • Sep 29 2011 | 11:22 pm
      (love this new collapsing code thing)
      That does what I was looking for! I haven't done much control type stuff in the signal domain so knowing the objects to use is very handy!
      I incorporated the minmax bit of code and am triggering it using the edge~ but this isn't sample accurate, and it only works one time at the moment.
      To further clarify what I'm trying to do.
      I have an 8sec buffer, I want to start writing to that buffer (using ipoke, but that isn't integral to this problem so it' been left out). I'm using minmax~ driven by the sync output with some supporting logic to set the loop length. So if after 1sec I stop recording, I set groove's max loop point to 1000ms. Where this 'zero' thing comes in to play is that I want to be able to change direction while creating the initial loop. So I can start creating a loop, when I get to 1000ms, I go reverse, when I get to zero, I then want to jump to 1000ms and keep writing from there, but then if I change direction (and go forward again) and write until 1500ms, then reverse past zero again, it would jump to 1500ms and write from there. So basically I can change direction as much as I want while creating the initial loop, and have it keep wrapping back to the highest point I've written to in the buffer.
      So what I'm pasting below does that, but in the control domain so I'm likely losing samples here and there, and minmax~ seems to break once I hit zero too (so it only works the first time I go up to zero). Or rather, I guess I'm very briefly hitting 0.99999, as minmax gets set to the maximum value once I jump back.
    • Sep 30 2011 | 4:49 pm
      ok, sure. i getting a bit confused as you are talking about recording but the patch here not featuring ipoke but just about playback. you will have to (and should) sync recording and playback eventually.
      ultimately though, you cannot control groove~ sample rate, which is part of your current problem, so you will probably have to shift over to play~. it is a real shame about groove~. and a shame that play~ is not as good interpolation on output as groove~. lots of tradeoffs here.
      i'm going to see if i have time to put a small example together and also tackle this looping problem. it is interesting.
      good luck till then.
    • Oct 01 2011 | 12:46 am
      The actual patch has ipoke driven by the sync output of groove so they are locked together (so i can do varispeed stuff). The main reason i didn't add it as I'm using a slightly modified version of ipoke that isn't available that lets you dynamically select how much of the buffer you are using (and handles the interpolation accordingly). ipoke breaks if you only play part of the buffer (as the min/max points).
      Either way that part works pretty much fine. I have it set so on the first bang, it resets (to the maximum value) the buffer, groove, and minmax objects, then starts recording (with a fade in) and a second bang uses the minmax value to set the maximum point for groove and ipoke, and then fades out the audio input.
      So the example I posted last simulates the functional part of that with minmax, except you have to manually press 'reset' to start anew.
      It's been surprisingly complicated and difficult to figure out the looper thing in general, incorporating dynamic resizing, overdubbing, and varispeed (while recording). Very tricky indeed. This toggling direction while recording is almost an 'icing on the cake' kind of functionality.
    • Oct 03 2011 | 10:37 pm
      I've been messing with this a bit more and for the life of me I can't get anything to fire right when I reverse into 0.0 (other than edge sending a 'bang') so that I can jump to an arbitrary position (0.5 for example) without actually making it to 0.9999
      I'm assuming it has to happen in the signal domain as the control domain is probably slow enough to allow the phasor to wrap back around to 0.99 even though I may send a bang at 0.0.
    • Oct 05 2011 | 2:51 pm
      For good measure here's the looper code I'm using but adapted to use regular poke~ for simplicities sake. It's also annotated with what's happening (and not happening)
      Any help on this would be very much appreciated!