ok so I’m trying to figure out a thing but my brain is somehow fried.
I want to do this:
for a set of audio files with varying length, I want to calculate padding between them to create sample chains for the Rytm.
Now, I don’t want the individual slices to all be the same length, but I want them to be the minimum length which would fit into the 120-division start/end parameters.
simple example without padding:
file 1 = 100 samples
file 2 = 200 samples
file 3 = 300 samples
file 1 start = 0
file 1 end = 20
file 2 start = 20
file 2 end = 60
file 3 start = 60
file 3 end = 120
it’s easy as long as the original files already fit into the grid, as with the example above.
but lets change the example to this:
file 1 = 97 samples
file 2 = 199 samples
file 3 = 298 samples
we now have 594 samples in total. each individual slice length doesn’t fit into the 120 grid, so they have to be padded with silence.
again, it would be trivial to pad them all to the same length, such as 298, and then have an even 1/3 division on the start/end parameters, but it’s not what I want to do.
I need to find a formula to pad each individual slice such that each slice is addressable by the 120 resolution. In the above example, intuitively the solution is to pad file 1 by 3 bytes, file 2 by 1 byte, file 3 by 2 bytes. we would then end up with the first example.
another more extreme example:
file 1 = 10 samples
file 2 = 99999 samples
a relatively short vs long slice, with a ratio of 10:99999.
we want the start/end parameters like this:
file 1 sta = 0
file 1 end = 1
file 2 sta = 1
file 2 end = 120
so we need to pad these two files such that the ratio between them is 1:119.
it’s kind of embarrassing but I feel kind of out of my depth on how to do this properly, especially if there are many files. each time I tried to implement a solution, I realized there was some major error.