cache select precision

hello there,

I’m trying to use cache TOP and cache select TOP to have multiple instances of movies, each one in a different index: -16, -32, -48. I really want to know when the cache select loops, so I can change its position on another composition.

I’m attaching here a working example using a default TD movie.

It´s working!

The problem happens when I change to other movie files. I’ve tested with both HAP and Animation codec. None of them are in sync.

Do I have to export with a correct codec and framerate to have this precise index?

Thanks in advance

Marlus
cache-select.toe (5.21 KB)

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)

So I just re-read your post one last time, and I realized I didn’t say anything about changing your movie file in asset… which is a little more complicated.

If I were going to wrestle with this, I’d want two movie file in TOPs and a switch to move between the two. I’d also need to do some logic to determine which movie should be playing at any given point. Let’s look at the scripting for moviein1. Looking at the index_fraction from the info chop we can CHOP execute:

[code]def valueChange(channel, sampleIndex, val, prev):

# conditional test for the end of the file
if val >= 0.99:
	
	# stop playing movie 1
	op( 'moviein1' ).par.play = 0

	# start playing movie 2
	op( 'moviein2' ).par.play = 1

	# change the index of the switch so you're caching the second
	# movie file TOP
	op( 'switch1' ).par.index = 1

	# set the cache step paramter to match movie 2
	op( 'cache1' ).par.step = int( op( 'moviein2' ).rate / 60 )

	# this is where you should change the file movie 1

	# reload the movie 1 - since you just changed the file
	op( 'moviein1' ).par.reloadpulse.pulse()

	# debugging statement to confirm that you've switched
	print( 'change to movie 2' )
	

return[/code]

We do the same thing for moviein2 with the operators switched to the appropriate targets.

This seems to be working pretty well, but we also need to change our eval DATs to check that our index values are synced between the two systems. We can use a conditional one line expression for this:

op( 'info1' )[ 'index' ] + op( 'cacheselect' + str( me.digits )).par.index if op( 'switch1' ).par.index == 0 else op( 'info2' )[ 'index' ] + op( 'cacheselect' + str( me.digits )).par.index

The next step would be to build a table (or any data structure really) as a playlist so you could determine which file you were switching to as your system loops.

Does that get you any closer?
cacheSelect.tox (1.98 KB)

Yes, its close to what I’m trying to achieve.
thanks for the explanation and examples @raganmd
best
marlus