How to access data from onset function (using lambda)?

Something like that would be great! Ideally, it would be good to be able to get the index length, the start and finish separately as well as the length of each onset in relation to the whole sample (just in relation to the 0 to 1 length, not the actual duration, although that might be interesting too)

sample_onsets_index :loop_amen #=> returns index length
sample_onsets_start :loop_amen, 3 #=> returns 4th onset start time
sample_onsets_finish :loop_amen, 3 #=> returns 4th onset finish time
sample_onsets_length :loop_amen, 3 #=> returns 4th onset length

Not sure if there would be a less verbose way to write that, but that is the idea.

This all came about because I was trying to make a visual example of how onset works. Here’s what I came up with: