Hi,
I have a question about Timer CHOP scripting functionality. Currently I have a Table DAT feeding a Timer CHOP’s segments. Wonderful for playlist-type functionality.
What I would like to do is have the option for any given segment to ‘loop’ infinitely, when told to via python. This is different than a simple “pause”. Lets consider the following:
Segment / Length
1 / 6sec
2 / 1sec
3 / 4sec
4 / 5sec
A 15 second playlist. After 8 seconds, we will have gone through segment 1 and 2. We will be 1 second into segment 3. At this moment, I would like to be able to set some kind of boolean type condition that will continue to play the next 3 seconds of segment 3, and at the end of the segment, starts at the start of segment 3 again.
When the boolean is set to false, segment 3 will continue to play. When that segment ends, it will continue onto 4 as normal.
What I have tried is coding the timer CHOP callbacks. Inside of onSegmentEnter(), I used op(‘timer1’).goToPrevSegment(). This works… mostly. It seems like every once in a while I catch it slipping for a (fraction of a) second. If there is system lag or something, I might see the actual next segment appear as the current one before immediately going back to the segment I want to loop. It is a brief moment, but it could potentially mess with system messaging for things that I want to be critical. I’m sure this is only more likely when throwing loading times and stress on the system.
Then as an alternative I went into whileTimerActive() and setup a conditional that checks to see if the index fraction for the segment is over .9999, to then pulse the cue. This wasn’t working reliably, until I lowered it to .99, at which point it seems to be more stable but is obviously cutting out the last 1% of an given timer segment entry. Not ideal, especially for longer time periods.
Has anyone approached this concept with a more proper and robust solution? Any insight is appreciated. Thanks!
If you look in the OP snippets, there is an example of a looping timer, using segments. It will only release once you trigger a specific button. You might end up having to link a few timers together to get the desired function you are looking for but what you are saying is very do-able with minimal coding. Not sure if the callbacks are necessary. But I havent looked to deep into what you are doing. Good luck.
derivative.ca/wiki088/index … Timer_CHOP
The parameter is under ‘Exit Segment at End of Cycle’, just requires a pulse!
In short, looks like I might have to do multiple timers like you suggested. Thanks for the tip on the timer snippets. Yes, that is essentially the exact functionality I’m looking for.
The reason I was focused on doing it via scripting and callbacks is because I’m trying to hack an existing example. Elburz made an amazing component called playlist creator:
github.com/nVoid/TouchDesigner-Playlist-Creator
It is driven by a timer CHOP called “timer1” inside the first level of the COMP. What I am trying to implement is an extra column of checkbox buttons in the playlist section that will ‘loop’ the given playing entry. Loop at the end when the box is checked, go to the next entry at the end when unchecked. Manually clicking ‘next’ breaks you out of the infinite loop.
I was about to start throwing around extra timers and associated scripts, but I wanted to check if there was something that was a little more ‘python-y’ and/or elegant that would change less about the original COMP. Doesn’t look like that is the case for the moment, so I’ll start getting some other timers in on this.
I’ll make sure to share my work once I have something polished. If anyone has any other approaches, I would love to learn more about what might be ‘best practices’ in this situation.
You ever wind up finding your solution immediately after you post onto a forum? 
Turning “cycle” on in the timer seems to do what I want. I think I was a little unclear about the definition of cycles vs segments, as I was assuming that turning on cycle loops the entire timer and not just the segment. But that doesn’t seem to be the case…?
Anyways, got it to work! Thanks again.