How do timestamps work?
First thanks for ex-portmidi, I'm starting to use it to play around with my synth & Elixir. I successfully managed to record sequences of events while playing the synth, which is already great :smile:
If I call PortMidi.write with a timestamp, it seems like the note is played right away, is it expected?
Here is a concrete example:
PortMidi.write(output, [
{{144, 36, 55}, 13771},
{{128, 36, 68}, 13919},
{{144, 48, 64}, 14310},
{{128, 48, 75}, 14453},
])
(in that case the 2 notes will stack up immediately).
I looked a bit inside the code and in the portmidi documentation, and read here:
timestamps are ignored if the stream was opened with latency = 0
This makes me wonder how timestamps work when called from ex-portmidi.
Did you manage to get them working on your side?
Thanks!
Hey there, thank you for trying out ex-portmidi, glad it's working (mostly!) for you 😀
Good catch there, I had totally missed that bit from the documentation, and just put latency at 0 by default when opening an output device. I'm now adding the option to set your own latency on open.
Will let you know when you can upgrade! 👌
@thbar done! 🎉
Feel free to pull the new version 5.1.0 from Hex. I have added a third optional argument to PortMidi.open/2,3 for latency, defaulting to 0. I've given it a try, and it seems to work okay! Check out the updated documentation if you need to.
Let me know how it goes! 👋
PS: I've mentioned you in the changelog for spotting the issue, I hope you don't mind! 😀
Thanks a bunch @lucidstack! I'll test this out and will report back & close here.
Happy to be in the changelog, no problem. Thanks again!