Part of your problem might be that in your CHOP execute you’re not differentiating between the val that is associated with index and the val that’s associated with length.
The Channel parameter in your CHOP execute is set to ‘*’ which will look at all channels in the target CHOP. Consequently, when you change media, the length (unless all of your assets are the same length) causes the execute to fire and val now carries the value associated with length.
You can limit this by using an if statement to first check if you’re incoming channel name matches ‘index’ (which is what it looks like your for loop is mostly using). Alternatively, you could also limit the scope of your execute by only selecting the channel “index” as your target chop execute channel.
Probably the bigger challenge here is sample rate, and how those are cached. I like using a texture 3d set to 2D texture array when thinking about these challenges - the frames are displayed in a single top, making it a little easier to see each stored slice.
There are a couple of ways you might tackle this - standardizing your input assets would be a sure fire way to make sure that you’re always starting on a level playing field… if that’s not the case, you might consider a conditional expression in your cache to change the step size based on the sample rate of your selected movie file. Something like:
1 if op( 'info1' )[ 'sample_rate' ] == 60 else 2
I think this will do the trick… it requires a little more stress testing, but it should move you in the right direction. I’ll attach an example based on all of this.
I’ve ditched your for loop in favor of three evaluate DATs with the expression:
op( 'info1' )[ 'index' ] + op( 'cacheselect' + str( me.digits )).par.index
Your comparison value + the corresponding cache select parameter of the index offset (adding them as your cache select index is a negative value). This along with the printed index position in the frame should help you debug sync.
I’m sure there are other ways to come at this problem, this is just the first one that comes to mind.
Cheers,
M
Additionally, using a text TOP and adding in the index value is another way to bake your index onto the frame while you’re debugging.
cacheSelect.tox (1.12 KB)