introlab / odas

ODAS: Open embeddeD Audition System
MIT License
794 stars 252 forks source link

Change Timestamp #263

Open LePtitMetalleux opened 2 years ago

LePtitMetalleux commented 2 years ago

Hi, I got theses data : { "timeStamp": 520, "src": [ { "x": 0.896, "y": 0.376, "z": 0.235, "E": 0.317 }, { "x": 0.990, "y": 0.073, "z": 0.117, "E": 0.116 }, { "x": 0.758, "y": 0.637, "z": 0.140, "E": 0.088 }, { "x": 0.819, "y": 0.335, "z": 0.465, "E": 0.000 } ] } I would like to know if it's possible to change "timeStamp": 520, to "timeStamp": currentDate,

Thanks in advance

SeanTasker commented 2 months ago

The timestamp is the hop number.

In the code consuming this output you can do the following if you're using JavaScript:

var start = new Date(...); // Source from when you started
...
var timeStampFromStartMS = ( (timestamp * hopSize) / sampleRate ) * 1000 );
var currentTimestamp = new Date( startDateTime.getTime() + timeStampFromStartMS);

This isn't super precise since the start time isn't reported from ODAS in this situation.

Alternatively you could modify https://github.com/introlab/odas/blob/master/src/sink/snk_tracks.c#L348 to do a similar calculation and add it to the Unix epoch, see https://stackoverflow.com/a/10889489