Open OlivierSohn opened 6 years ago
In portmidi.h, this:
/*
PmTimestamp is used to represent a millisecond clock with arbitrary
start time. The type is used for all MIDI timestampes and clocks.
*/
typedef long PmTimestamp;
would then be replaced by:
/*
PmTimestamp is used to represent a nanosecond clock with arbitrary
start time. The type is used for all MIDI timestampes and clocks.
*/
typedef unsigned long long PmTimestamp;
For alsa, snd_seq_ev_schedule_real
(with absolute timestamp) would replace snd_seq_ev_schedule_tick
which only has millisecond relative precision
Platform dependent behaviors are tricky to implement or test. But if you think the change is worth the effort, I've no problem with added precision.
Initially I was ready to do the implementation, but now, I think I can live with a millisecond precision :)
The
Timestamp
(type Timestamp = CULong
) precision is currently milliseconds, which is enough to introduce midi-jitter of up-to one millisecond. I guess that in some applications, it could be audible, and some platforms (OSX for example) provide nanosecond precision for MIDI timestamps, so we could rewrite portmidi to take advantage of the full resolution, where it is available.I'd like to propose a PR where the full precision is kept.(After looking at it a bit more, it looks like it's a big task... and we would need some unit tests to make sure nothing is broken.)Since it's a breaking change, to avoid undetected bugs when upgrading, I think the type should be changed, I propose
newtype NanoTimestamp = CULLong
.What do you think?