Need help improving my logic, creating Dynamic Overlay from JSON file

 

I'm building a dynamic overlay so our fitness instructors can see the timings of the workout (rounds) during recording. This is displayed on a TV behind the camera. I've exported a Google Sheet with all the info to a JSON file that contains rows, each row (round) contains information about that part, for example it has a value for an active part in seconds and a rest part in seconds.

I'm new to arrays, but I've successfully made one, so the round time (= active+rest in sec) is stored in an Array Vector Concat. This works well.




Next, I've got a sequencer with a Music Mix for the whole workout, and I want to compare the position in the sequencer with the total value for each round. So for example, if the position in the sequencer is less than the duration of the first round, you're in round 1 (obviously). I then made the logic that I keep 'adding' the previous round duration combined, and compare that with the position in the sequencer. So I can again know in which round I am. 


So essentially I am creating virtual or soft 'markers' in the sequencer opposed to actual markers, as my position in the sequencer determines the current round. This is 'fed' into a Switch Integer and with the 'selected' output of this Switch, I retrieve the relevant information of the active round from the JSON file which I can display on-screen for the instructor. 

(hope you're still with me here)


My Issue:

The array itself very clean and doing its work, but the part after that (where I determine which round should be active) feels illogic, it works, but I can't think of anything else. My gut feeling is saying I can improve it by making it smarter. But I''m stuck.

The Transmit module (Time_Strength) is actually the played time of the Sequencer with the Music.

Hope you can help me improving this. As now I have to define every round. 



   cm-aximmetry

 
Profile Image
Eifert@Aximmetry
  -  

Hi,

You could simplify a bit by using one Vector Slice Multi module instead of the 15 Vector Item modules.
But for the Add and the Greater modules, you would need an array, where you get values from the previous items of the array.
You can actually do that with Transmit modules.

Here, I add together the current index value of the vector and the value of the previous index using the Transmit modules and their Subtunnel pin:

And if that value is greater than your Time_Strength, then I add 1 to the final output. This way, the final output will be equal to the index of the vector where Time_Strength's value is less than it.
And of course, you could put all this into your existing array compound. Also, you are not limited to 16 values cause you won't need the Switch Integer module.

Warmest regards,