Topic: Pianoteq MIDI recordings are slow

This issue was not noticeable until recently because I'm trying to record longer sessions (30+ minutes).

Basically, the audio will slowly start to drift when I record using the standalone Pianoteq MIDI recorder. I've tested with multiple methods: Different cameras, frame rates (24.00 vs 23.976), phones, and other MIDI recorders (this last one solved my issue). This issue has also been reported by another user before: https://forum.modartt.com/viewtopic.php?id=7394

Anything above 10 minutes will really start to become noticeable. After about an hour it's way off.

My workaround has been to record the MIDI portion using another software (Synthesia), but that has its own limitations (~25 minutes recording time limit and other bugs). I can look into another MIDI recorder, or record using Garage Band which is more resource hungry, slower to export, and has no direct MIDI export that I can find.

In the end, it would be so much easier if I could just do everything in Pianoteq like it was intended.

To clarify, this happens during the recording process of the MIDI. Audio export is not affected. So if you took the same MIDI and exported it with various other programs, the sync issue will not be reproduced. [EDIT: I meant to say that the exported audio files should not drift when compared to each other. I haven't actually exported using another software. I only used my camera's and phone's audio recording as reference. This was my way to eliminate Pianoteq's audio export function as a potential cause].

Thanks for reading.

Last edited by Khoa (30-05-2024 21:00)

Re: Pianoteq MIDI recordings are slow

How much drift do you get ? I assume it is not something like in the original thread you mentioned (1 sec every 10 minutes). So how much is it ? is it something like 0.01 second every 10 minutes ?

Re: Pianoteq MIDI recordings are slow

Khoa wrote:

To clarify, this happens during the recording process of the MIDI. Audio export is not affected. So if you took the same MIDI and exported it with various other programs, the sync issue will not be reproduced.

These statements seem to be in conflict. If it's a MIDI recording problem, one would expect an export from any rendering app to exhibit the same sync error vs. the video. If it's only a problem with standalone Pianoteq exports, it's a rendering issue.

The issue in the other thread turned out to be that Standalone Pianoteq was rendering at a slightly lower tempo due to microsecond-level rounding of the duration of a tick. That issue was reportedly fixed in Pianoteq 6. Are you running the current release?

What's the tempo, and can you reproduce the problem at a tempo that isn't subject to rounding (e.g. 125bpm is exactly 500 us/tick)?

EDIT: I just tested exporting audio from Standalone Pianoteq 8.2.2 vs. rendering the VST3 in Cakewalk Sonar at 125 and 126bpm. There was no tempo drift between either pair of audio files. I then tried recorded MIDI simultaneously into Standalone Pianoteq and Cakewalk Sonar, and the final note events in each file were timestamped identically.

EDIT 2: I think what Julien is getting at is that clock-rate differences between the interface that Pianoteq is referencing and an unsynced video recorder can be on the order of .025% (as I recall) which amounts to about half a second over 30 minutes. If you don't sync the two recorders to a common clock source at the time of recording, you need to use video-editing software that can do it after the fact. I don't work with video much so am not sure if garden-variety editors have this capability built-in, but I would hope so.

Last edited by brundlefly (30-05-2024 20:25)

Re: Pianoteq MIDI recordings are slow

brundlefly wrote:
Khoa wrote:

To clarify, this happens during the recording process of the MIDI. Audio export is not affected. So if you took the same MIDI and exported it with various other programs, the sync issue will not be reproduced.

These statements seem to be in conflict. If it's a MIDI recording problem, one would expect an export from any rendering app to exhibit the same sync error vs. the video. If it's only a problem with standalone Pianoteq exports, it's a rendering issue.

Sorry, I meant to say that audio exports using Pianoteq vs. other softwares from the same MIDI file will not drift when compared to each other. Apologies for the confusion. I use audio from my camera as reference so I haven't tried exporting MIDI recorded with Pianoteq using another software yet. 

I had not experimented with other tempos, I always left it at the default 120bpm. I'm running version 8.2.2 standalone on MacOS.

brundlefly wrote:

I then tried recorded MIDI simultaneously into Standalone Pianoteq and Cakewalk Sonar, and the final note events in each file were timestamped identically.

Interesting, I've done a similar test, recording MIDI simultaneously with standalone and Synthesia, this produced MIDI files that are slightly off. I will try with a few other MIDI recorders later today and see if I can reproduce the issue. Thank you so much for taking the time to test it out yourself!

Re: Pianoteq MIDI recordings are slow

julien wrote:

How much drift do you get ? I assume it is not something like in the original thread you mentioned (1 sec every 10 minutes). So how much is it ? is it something like 0.01 second every 10 minutes ?

I don't have the exact numbers, I will have to redo some tests later to measure. But if both audio are on, I will hear phasing even before the 10 minute mark. After that it becomes more like an echo.

EDIT: I just did a test recording for 13 minutes. After the 10 minute mark, there's a 1 second delay, almost exactly. What's more interesting is phasing happens almost instantly, even when I carefully aligned the first note.

Last edited by Khoa (31-05-2024 00:30)

Re: Pianoteq MIDI recordings are slow

I created a video to better explain this issue:

https://www.youtube.com/watch?v=6dtMR9Bfh-I

I recorded the MIDI performance simultaneously using Synthesia and Pianoteq. Both of of these MIDIs were then exported to .FLAC using Pianoteq's "Export to audio file" function with the exact same settings. Within just one minute, the Pianoteq version is out of sync when overlayed to either the camera or Synthesia's audio. Synthesia and camera audio never drifted from each other.

For your reference, this was created using Pianoteq 8 Pro Version 8.2.2 on an Intel Macbook.

Re: Pianoteq MIDI recordings are slow

Hum yeah that's not a small drift ! Unfortunately, I haven't managed to reproduce it. I've been comparing Pianoteq with Reaper, Logic and Synthesia and they all agree, up to a few hundredth of second per 10 minutes.

When recording MIDI, pianoteq measures the time using the soundcard: when your soundcard is configured to run at 48kHz, pianoteq assumes that each sample is 1/48000 second. So what could happen is that maybe your soundcard says it runs at say 48000 Hz, but in really it runs a slightly different sample rate. I have one that I have measured at 48003 Hz for example.

However, in order to explain a drift of 1 sec / 10 min, the sample rate deviation of your audio device would have to be around 80Hz, so I don't really believe it is the explanation. Still, I suggest you try to use a different soundcard (like the builtin audio of your macbook for example), and see if the result is different.

Re: Pianoteq MIDI recordings are slow

Thanks for testing. So it looks like the problem is caused by some specific configuration or settings that I have with my setup then. But I still think it's related to Pianoteq somehow because Synthesia doesn't have the same problem. Or maybe not...

I don't use an external sound card, only whatever is built in. But I can test it out with my old computers to see.

Fortunately, I have found another workround with no time limit: Change the tempo of the Pianoteq recording to 120.096 exactly (up from 120.00). Then the drift will be very slight, imperceptible without overlaying two audio tracks. It'll work for now until we get to the bottom of this mystery!

Re: Pianoteq MIDI recordings are slow

Re-reading this thread and the older one, it seems Pianoteq's offline (non-real-time) rendering of MIDI to audio may somehow be executing differently in different versions for the different platforms or under different O/S versions or CPUs. There hasn't been much mention of what hardware platform or O/S is involved in the various reports. My testing has been on an Intel system with Win11

Alternatively it seems possibly there is some procedural sequence of events that can cause Pianoteq to mis-read/mis-calculate/mis-store/mis-apply the microseconds/tick value corresponding to the specified tempo similar to the issue reportedly fixed in v 6.7.1.

When I have time, I'll give it another go using 120bpm, specifically.

Also, on the remote chance that it matters, what piano model, preset and rendering quaity are involved?

It would also be useful to know if you get the same slow/long performance when timing a real-time playback of the recorded MIDI.

Last edited by brundlefly (31-05-2024 17:52)

Re: Pianoteq MIDI recordings are slow

brundlefly wrote:

Also, on the remote chance that it matters, what piano model, preset and rendering quaity are involved?

Some more details: Roland HP 508. Petrof Mistral Classical Recording. Rendering at 48,000 Hz, 16 bits, FLAC. High quality settings. Normalized output volume. I play in 48,000 Hz, 64 samples. 128 Polyphony. The MIDI tab is left untouched.

I'm starting to think the problem is my Roland not being fully compatible with Pianoteq somehow because I've just tried the test with 2 other laptops, one is my main M1 Macbook, the other is my old Toshiba running Windows 10. Both produced audio that don't match up. Interestingly, the Toshiba is faster, not slower.

brundlefly wrote:

It would also be useful to know if you get the same slow/long performance when timing a real-time playback of the recorded MIDI.

I've imported the MIDI files into a MIDI sequencer software to see, they do drift as expected. So the cause is for sure not with "Export to audio". Maybe playing with 64 samples is too ambitious, I will try to slow it down to 128 or slower to see.

Re: Pianoteq MIDI recordings are slow

I am still confused over your exact setup but find it curious that 23.976/24.000 is about .999 and 120.00/120.096 is approximately .9992. Is it possible the frame rate has been converted somehow?

Re: Pianoteq MIDI recordings are slow

levinite wrote:

I am still confused over your exact setup but find it curious that 23.976/24.000 is about .999 and 120.00/120.096 is approximately .9992. Is it possible the frame rate has been converted somehow?

I thought so too but I'm pretty sure it's just a coincidence. I make sure to shoot and export in 24.00 fps using DaVinci Resolve. The drift happens at the MIDI stage, though. At least that's how it is for my case.

Re: Pianoteq MIDI recordings are slow

As Julien wrote, Pianoteq is based on the sampling rate of the sound card used (internal or external), so in my opinion that's where you should be looking; if you could borrow an external sound card for a test, that would certainly be interesting.

Re: Pianoteq MIDI recordings are slow

Luc Henrion wrote:

As Julien wrote, Pianoteq is based on the sampling rate of the sound card used (internal or external), so in my opinion that's where you should be looking; if you could borrow an external sound card for a test, that would certainly be interesting.

Yeah, I still need to try out the different sampling rates, it's worth a shot. I'll also do some research on external sound cards. Any good ones you can recommend? Just need to be sufficient for Pianoteq. I've only used internal cards so this is new territory for me.

Re: Pianoteq MIDI recordings are slow

Khoa wrote:
Luc Henrion wrote:

As Julien wrote, Pianoteq is based on the sampling rate of the sound card used (internal or external), so in my opinion that's where you should be looking; if you could borrow an external sound card for a test, that would certainly be interesting.

Yeah, I still need to try out the different sampling rates, it's worth a shot. I'll also do some research on external sound cards. Any good ones you can recommend? Just need to be sufficient for Pianoteq. I've only used internal cards so this is new territory for me.

You have already tried 3 different laptops, i.e. 3 different soundcards. Unless you need one it might be better to wait a bit until more is known about the problem, especially since you have something of a tempo workaround.

Re: Pianoteq MIDI recordings are slow

levinite wrote:
Khoa wrote:
Luc Henrion wrote:

As Julien wrote, Pianoteq is based on the sampling rate of the sound card used (internal or external), so in my opinion that's where you should be looking; if you could borrow an external sound card for a test, that would certainly be interesting.

Yeah, I still need to try out the different sampling rates, it's worth a shot. I'll also do some research on external sound cards. Any good ones you can recommend? Just need to be sufficient for Pianoteq. I've only used internal cards so this is new territory for me.

You have already tried 3 different laptops, i.e. 3 different soundcards. Unless you need one it might be better to wait a bit until more is known about the problem, especially since you have something of a tempo workaround.

Except that they're all internal... I suggested borrowing one for a test, not buying one; even though you can find very cheap cards that give good results - but also very expensive cards that don't!
What intrigues me is that the results can vary: too slow on the Mac, too fast on the Toshiba... very strange.
Have you checked that the Pianoteq sampling rate matches the Mac/Toshiba sampling rate? I suppose you did...

Re: Pianoteq MIDI recordings are slow

Khoa wrote:

I recorded the MIDI performance simultaneously using Synthesia and Pianoteq.

If you save the Pianoteq-recorded performance to MIDI and open each of those files one a time in a DAW, does the DAW take on the same tempo in both cases?

If so, and you drop the Pianoteq-recorded MIDI file back into Pianoteq after restarting it, will it then render the proper tempo?

Re: Pianoteq MIDI recordings are slow

So I tried another test: Using Pianoteq's virtual keyboard, I recorded a 10 minute clip with a few key presses every other minute or so. No drift! So as of now I'm pretty sure the issue is with how Pianoteq records MIDI signal from my specific digital piano (Roland HP-508). This is why no one else is able to reproduce the issue with their own hardware. And also why the issue isn't more widespread.

My current theory: The Roland HP-508 records note-off velocity, an uncommon feature according to Pianoteq (Pianoteq popped a message about it when I first calibrated my velocity curves). Could these extra events somehow be enough to add latency? I will do some more testing and see if I can disable it one way or another. 

EDIT: I'm unable to stop my digital piano from sending note-off data. Flattening the note-off curve in Pianoteq does not eliminate drift.

Luc Henrion wrote:

What intrigues me is that the results can vary: too slow on the Mac, too fast on the Toshiba... very strange.
Have you checked that the Pianoteq sampling rate matches the Mac/Toshiba sampling rate? I suppose you did...

I suspect it's something to do with the slight difference between Mac vs Windows version of Pianoteq, just a hunch. And yes, 48,000 Hz for all.

brundlefly wrote:

If you save the Pianoteq-recorded performance to MIDI and open each of those files one a time in a DAW, does the DAW take on the same tempo in both cases?
If so, and you drop the Pianoteq-recorded MIDI file back into Pianoteq after restarting it, will it then render the proper tempo?

The MIDI will have a tempo of 120.00 if I record it as 120.00 in Pianoteq. Pianoteq will accurately render with whatever tempo the performance set or modified to.

Last edited by Khoa (02-06-2024 23:47)

Re: Pianoteq MIDI recordings are slow

Hopefully, this link* can shed light on this issue.

(Midi Beat Time)
"Within the MIDI data stream are tempo meta-events, which contain a 24-bit value that give the number of microseconds per quarter note."


(Sequencing Time)
"The fractional number of microseconds must be properly accounted for or the MIDI playback will drift away from the correctly synchronized time."



*
https://majicdesigns.github.io/MD_MIDIF...iming.html

Re: Pianoteq MIDI recordings are slow

Khoa wrote:

So I tried another test: Using Pianoteq's virtual keyboard, I recorded a 10 minute clip with a few key presses every other minute or so. No drift! So as of now I'm pretty sure the issue is with how Pianoteq records MIDI signal from my specific digital piano (Roland HP-508). This is why no one else is able to reproduce the issue with their own hardware. And also why the issue isn't more widespread.

My current theory: The Roland HP-508 records note-off velocity, an uncommon feature according to Pianoteq (Pianoteq popped a message about it when I first calibrated my velocity curves). Could these extra events somehow be enough to add latency? I will do some more testing and see if I can disable it one way or another.

Latency will not compound over time to produce drift; If that were the case, you would just get a fixed offset of the whole performance, and generally not more than a few milliseconds. Also, Note Off Velocity is not a separate event; it's just a parameter encoded in the Note Off event that's fixed at a constant value in a keyboard that doesn't support it vs. variable from a keyboard that does. In any case, my Roland RD-700NX sends variable Note-Off Velocity, and I'm not seeing this issue. But it is interesting that you don't see it when playing fewer discrete events.


Khoa wrote:

The MIDI will have a tempo of 120.00 if I record it as 120.00 in Pianoteq. Pianoteq will accurately render with whatever tempo the performance set or modified to.

So is this confirming that Pianoteq will render with correct timing if you save the performance as MIDI and re-import it vs. rendering it immediately after recording?

Re: Pianoteq MIDI recordings are slow

brundlefly wrote:
Khoa wrote:

The MIDI will have a tempo of 120.00 if I record it as 120.00 in Pianoteq. Pianoteq will accurately render with whatever tempo the performance set or modified to.

So is this confirming that Pianoteq will render with correct timing if you save the performance as MIDI and re-import it vs. rendering it immediately after recording?

Unfortunately, no, simply re-importing will not fix the issue. I have to modify the tempo to 120.096 using another program (Sekaiju). But in any case, if your Roland also sends note-off and you're not seeing the issue then that theory is bust... Oh well, I'm moving on for now. My Roland is 10+ years old now so eventually it'll have to be replaced. We'll see then if the issue is still there, lol!

levinite wrote:

Hopefully, this link* can shed light on this issue.
https://majicdesigns.github.io/MD_MIDIF...iming.html

Thanks for sharing. I've considered diving down this rabbit hole to attempt to make my own simple MIDI recorder, but that will take me forever to learn haha... For now I've made my peace with it. I thought the issue was happening to everyone, then it would have been easier for Modartt to diagnose. Whereas here it's only happening to me, and maybe the original poster from a few years ago - so I don't have super high hopes. I'm still going to test the different sample rates later to see if it makes any difference.

Re: Pianoteq MIDI recordings are slow

Khoa wrote:
brundlefly wrote:
Khoa wrote:

The MIDI will have a tempo of 120.00 if I record it as 120.00 in Pianoteq. Pianoteq will accurately render with whatever tempo the performance set or modified to.

So is this confirming that Pianoteq will render with correct timing if you save the performance as MIDI and re-import it vs. rendering it immediately after recording?

Unfortunately, no, simply re-importing will not fix the issue. I have to modify the tempo to 120.096 using another program (Sekaiju). But in any case, if your Roland also sends note-off and you're not seeing the issue then that theory is bust... Oh well, I'm moving on for now. My Roland is 10+ years old now so eventually it'll have to be replaced. We'll see then if the issue is still there, lol!

levinite wrote:

Hopefully, this link* can shed light on this issue.
https://majicdesigns.github.io/MD_MIDIF...iming.html

Thanks for sharing. I've considered diving down this rabbit hole to attempt to make my own simple MIDI recorder, but that will take me forever to learn haha... For now I've made my peace with it. I thought the issue was happening to everyone, then it would have been easier for Modartt to diagnose. Whereas here it's only happening to me, and maybe the original poster from a few years ago - so I don't have super high hopes. I'm still going to test the different sample rates later to see if it makes any difference.

From my reading of the older thread, the problem has never been adequately addressed. The relatively few it affects have found their own work-arounds. I wonder how many other setups would render such a long midi correctly, since we know the clock rounding is so critical. Sound cards are virtualized. As Brundlefly has suggested, it may be more an OS issue.  I did notice that Pianoteq's rendering tempo is affected by Pianoteq's midi "Playback speed" setting (slightly to the left of the midi title). Perhaps, you can use this instead of requiring the tempo modification.

Re: Pianoteq MIDI recordings are slow

levinite wrote:

I did notice that Pianoteq's rendering tempo is affected by Pianoteq's midi "Playback speed" setting (slightly to the left of the midi title). Perhaps, you can use this instead of requiring the tempo modification.

That's a very interesting observation. I've never paid any attention to that setting. I just tried setting it to 120/120.096 = .9992. This caused the UI to display 1.00x intead of 1x. And the resulting render was slow/long by the expected amount.

This made me wonder if that setting might account for the issue in some cases if not this one, but it seems to default back to 1x when you restart Pianoteq.

But it could still be part of the puzzle if it's not always being properly re-initialized internally.

Last edited by brundlefly (04-06-2024 20:31)

Re: Pianoteq MIDI recordings are slow

brundlefly wrote:
levinite wrote:

I did notice that Pianoteq's rendering tempo is affected by Pianoteq's midi "Playback speed" setting (slightly to the left of the midi title). Perhaps, you can use this instead of requiring the tempo modification.

That's a very interesting observation. I've never paid any attention to that setting. I just tried setting it to 120/120.096 = .9992. This caused the UI to display 1.00x intead of 1x. And the resulting render was slow/long by the expected amount.

This made me wonder if that setting might account for the issue in some cases if not this one, but it seems to default back to 1x when you restart Pianoteq.

But it could still be part of the puzzle if it's not always being properly re-initialized internally.

This is a much better fix than having to export to Sekaiju first. Thank you both!

EDIT: I can confirm that making changes to Pianoteq's "Playback speed" will change the render speed even if it does show x1.00. For my most recent test, I achieved good sync with x1.00155 for a 10-minute clip. I can also confirm that it does reset to x1 after automatically (tested by rendering without making changes after a restart), no issues there.

I'm very happy with this solution. Using the 120.096 value I got the other day should have given me 1.0008 but that was from another software on another day so maybe down to user error, or difference in hardware, etc. Anyway, I'm impressed that Pianoteq actually will reliably render the difference between 1.0016 and 1.00155. I did it twice to make sure, it's spot on.

Last edited by Khoa (05-06-2024 06:50)