Use round_to_sample and higher precision to remove round errors #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains minimal modifications to remove unnecessary quantizations in the generated JSONs.
The old time stamps have 2 decimals. Two decimals have a resolution of 160 samples. So the quantization error can be in the worst case 159 samples also when the synchronization is perfect.
Workaround:
First round the float values (time in seconds) such that they represent a sample value (i.e. the number times the sampling rate is an integer).
Second, the written numbers use 7 decimals. This is necessary to keep the resolution.
My personal suggestion would be to use integers (samples) instead of floats (seconds) to save the time stamps. This makes it easier and more precise to work with them. Especially in the case when a synchronization is used. It prevents all rounding errors. For example, when in the JSON the number is saved with 7 decimals it is not guaranteed that the reader code considers 7 decimals.