I search the relation between these times (in seconds) and these timestamps
30 seconds => 1189765120
1 minute => 1198153728
2 minutes => 1206542524
4 minutes => 1214930944
These info come from "Image Line FL Studio" music software.
I try to make a program in Python to manipulate FLP file, and I search without success the function for example:
F(30) = 1189765120
CodePudding user response:
Ok, this time I found the answer (the exponential progression 1/2, 1, 2, 4 minutes of your length, and the counting bits, and the 0 almost always gave me the hint: it looks like floating point representation)
#include <stdio.h>
#include <stdint.h>
int main(){
uint32_t l[]={1189765120, 1198153728, 1206542524, 1214930944};
for(int i=0; i<4; i ){
printf("%f\n", *(float *)(l i));
}
}
gives
30000.000000
60000.000000
120001.468750
240000.000000
So, what you have here, is just float32 representation of time in milliseconds. The information was there after all, and it was indeed a timestamp. With an extra milliseconds and some micro and nanoseconds in the 3rd case to make the reverse engineering harder.
Edit: Since it is flagged python (tho it was more a math puzzle than a coding question) here is how you can do it in python (handling bits is more natural in C, but there is a package in python to do so)
import struct
l=[1189765120, 1198153728, 1206542524, 1214930944]
for x in l:
print(x, '=>', struct.unpack('f', struct.pack('I', x))[0])
2nd Edit: and only now I realize that your question was for F(30)=1189765120, not the other way round (I was too focused on the puzzle), well, it is just the reverse
import struct
def F(sec):
return struct.unpack('I', struct.pack('f', sec*1000))[0]
>>> F(30), F(60), F(120), F(240)
(1189765120, 1198153728, 1206542336, 1214930944)
Note the slight difference for F(120)
from the number you gave. Explained by the extra microseconds