View Issue Details

IDProjectCategoryView StatusLast Update
0001731OpenMPTPlugins / VSTpublic2024-12-11 21:37
Reporter02FD Assigned ToSaga Musix  
PrioritynormalSeveritytweakReproducibilityalways
Status assignedResolutionopen 
Platformarm64OSWindowsOS Version11
Product VersionOpenMPT 1.31.04.00 / libopenmpt 0.7.3 (upgrade first) 
Summary0001731: VST ppq is not updated when the cursor is moved
Description

For VSTs like SNES emulation plugin C700, which read the ppq value for setting the recording positions for hardware exports, this makes getting accurate timings for loops nearly impossible. This might work best as a toggle in the options as this may not be desirable for everyone, but currently, when the module isn't playing, the ppq value is always 0, and if you play next row one by one, the value continues increasing as if the module was playing between rows.

Steps To Reproduce

1) Download C700 VST and load it into OpenMPT

2) Click "Set Recorder"

3) Place cursor anywhere in the song and click "Set" on any of the recording parameters

4) Value is still 0.00

5) Play the next row in the song from that position

6) Click set again

7) Value is not 0.00

8) Click set again

9) Value continues to increase despite the cursor being stationary

TagsNo tags attached.
Has the bug occurred in previous versions?
Tested code revision (in case you know it)

Activities

Saga Musix

Saga Musix

2023-10-03 18:51

administrator   ~0005785

Unfortunately this is technically not really possible at the moment, because the ppq is entirely derived from the number of samples rendered so far, which of course must keep increasing while the paused row is playing. Generally the PPQ generation is not stable at the moment for this very reason too, just changing the tempo in the middle of the song will cause the PPQ to change accordingly. So I'm afraid there is no simple fix for this.

02FD

02FD

2023-10-18 21:07

reporter   ~0005791

Rats. I figured that might be the case.

I have a workaround for my problem that could at least be put in the hidden settings; not sure how you feel about it, though. Would it be possible to have a "default PPQ position" that controls the value outputted when the song is stopped so you can adjust manually until this is sorted out? I understand if my request is unreasonable, this is a very specific issue I'm having. I'm also not sure, given your description, the feasibility of that idea.

Saga Musix

Saga Musix

2023-10-19 17:20

administrator   ~0005792

I don't think that's a good idea. However, looking at the time retrieval code, it appears that OpenMPT pretends that the transport is in playing mode even when it is really paused. Maybe unsetting the kVstTransportPlaying would also make the plugin behave more nicely.

02FD

02FD

2023-10-19 17:46

reporter   ~0005793

Last edited: 2023-10-19 17:48

Wait, hold on... Why is PPQ being calculated based on the samples rendered?
PPQ is not a tempo-dependent measure of time. It's "Parts Per Quarter", as in a Quarter note. This measure should be handled completely independent of the samples rendered.
And this is, in fact, the way C700 reads it when you change the tempo. I've had an inconvenient fix for a while now where I just slow down the tempo until it's so slow that restarting the song over and over from the same point allows you to hit an even 0.0000. You can do the same thing with a point from the middle of the song as well

Saga Musix

Saga Musix

2023-10-19 17:49

administrator   ~0005794

Wait, hold on... Why is PPQ being calculated based on the samples rendered?

Because OpenMPT as a tracker has no concept of PPQ, doesn't keep track of anything even remotely similar to PPQ, so the easiest way of implementing it was an estimation based on the current sample position and tempo - which is accurate if the tempo never changes. As I said, it would definitely make sense to have proper PPQ calculation but that would require nontrivial changes to the playback logic, not a simple workaround.

02FD

02FD

2023-10-19 17:58

reporter   ~0005795

And the number of rows that have played in the song isn't "remotely similar to PPQ"?

I don't question your knowledge; you're much more experienced than I am. I just want clarification.

Saga Musix

Saga Musix

2023-10-19 18:00

administrator   ~0005796

OpenMPT does not keep track of how many rows were played. Even if it did, that would still not help as soon as any time signature changes are involved. You can only keep track of PPQ by actually counting PPQ. Any other proxy metric, be it rows or total samples rendered, will fail at either tempo or time signature changes.

Saga Musix

Saga Musix

2023-10-19 18:10

administrator   ~0005797

FWIW - there would be other interesting use cases for keeping track of PPQ time in OpenMPT, such as sending and receiving MIDI time codes to/from other devices. So that would be one more reason for properly implementing this.

02FD

02FD

2023-10-19 18:23

reporter   ~0005798

I see. I understand you're incredibly busy, so I'm happy hear that there's some interest in this. In general I think OpenMPT has some amazing potential in terms of MIDI support!

Saga Musix

Saga Musix

2024-10-19 21:57

administrator   ~0006114

I had another stab at this and while I now have accurate PPQ reporting working, unfortunately it doesn't really solve your problem. The main issue here is that OpenMPT does not run any plugin processing while playback is paused, so the plugin also doesn't ask back what the current playback position is. It doesn't even do that when pressing the Set button. Essentially the plugin assumes that playback must always always running. That's something that might happen in the long term with OpenMPT to behave more like other VST hosts, but not something that can be fixed simply in the context of this issue here.

Saga Musix

Saga Musix

2024-10-20 16:17

administrator   ~0006136

As of r21901 (OpenMPT 1.32.00.30), PPQ reporting is more accurate now. For modules made with older versions of OpenMPT, you first need to disable the compatibility setting "Report inaccurate PPQ position to VST plugins (like OpenMPT 1.31 and older)" (https://wiki.openmpt.org/Manual:_Compatible_Playback#Playback_Compatibility_Settings).

As mentioned in my previous comment, simply navigating around in the module while playback is stopped will still not give you the correct song position in the plugin (because the plugin doesn't ask for it while playback is stopped). However, if you start playing from the row and immediately go into row play mode, you can press the Set button in the plugin and remove the fractions that have since been added to the PPQ position.

Saga Musix

Saga Musix

2024-10-21 12:48

administrator   ~0006137

r21904 improves the behaviour a bit further, there's one thing I overlooked that kept resetting the PPQ position when stopping playback. That no longer happens now, so you can also just start playback and stop it (instead of going into step mode) to keep the wanted PPQ position.

Saga Musix

Saga Musix

2024-11-25 18:40

administrator   ~0006215

Okay, one more change as of r22309: When playback is paused, plugins are now asked to run for 0 frames after seeking to a new pattern position. This will update the PPQ position C700. THis is a really experimental change because I bet there are plugins out there which will happily crash when being asked to render 0 frames, but time will tell.

02FD

02FD

2024-12-04 14:15

reporter   ~0006248

I would like to apologize for not providing feedback for so long. There are a couple reasons for this:

  1. Apparently all of my email notifications from this project were put in my spam folder, so for around a year I didn't see any of the notes being added. Thanks, Google.
  2. This is more of an excuse, but I've never compiled OpenMPT from source before, so, I've sort of been putting off figuring it out.

Again, apologies. I'm currently figuring out how to compile it to provide feedback as I type this.

Saga Musix

Saga Musix

2024-12-04 14:55

administrator   ~0006249

Precompiled builds are available from https://builds.openmpt.org/builds/

02FD

02FD

2024-12-07 05:56

reporter   ~0006251

I'm impressed that you were able to implement it given the struggles you described; however, there's a specific issue with it that makes it hard to get C700 to set the position properly and I'm not so sure the solution is possible; but hey, I kind of worried about this for the entire feature! When setting the row number in C700's recorder, you typically want it to be easy to set specific PPQ positions (usually rounded to the nearest whole row) so that you can loop the song properly. What would be ideal is, when "follow song" is clicked, if the cursor position could be output as if the module was playing at that position. If that's not possible, pausing the song should probably jump back to the nearest row, since it's going to pick up from that point anyway.

Thank you for your work, as always!

Saga Musix

Saga Musix

2024-12-07 15:47

administrator   ~0006252

The main problem with updating the PPQ position on every cursor navigation is that there is currently no way of caching the position calculations; meaning that OpenMPT would have to through the entire song length calculation for every key press. It might not be very observable on a small tune but once it reaches a few minutes, it can become annoying very quickly when simple cursor navigation is delayed even by just a little bit. Hence OpenMPT currently does these calculations very sparingly. It would be great if these results could be cached for the purpose you describe, but also other purposes (such as live-updating the time display in the status bar), but it does require very deep changes (some of which are definitely planned, others aren't).

I'll see what other temporary solutions there could be to this issue.

Saga Musix

Saga Musix

2024-12-11 21:37

administrator   ~0006259

Found the first plugin that crashes when trying to render 0 samples (Electri-Q)... so to avoid that, OpenMPT now renders one sample instead, and immediately afterwards reports again that the playback position changed, to avoid potential desynchronization by one sample. Let's see what breaks next..

Issue History

Date Modified Username Field Change
2023-09-29 15:04 02FD New Issue
2023-10-03 18:51 Saga Musix Note Added: 0005785
2023-10-18 21:07 02FD Note Added: 0005791
2023-10-19 17:20 Saga Musix Note Added: 0005792
2023-10-19 17:46 02FD Note Added: 0005793
2023-10-19 17:48 02FD Note Edited: 0005793
2023-10-19 17:49 Saga Musix Note Added: 0005794
2023-10-19 17:58 02FD Note Added: 0005795
2023-10-19 18:00 Saga Musix Note Added: 0005796
2023-10-19 18:10 Saga Musix Note Added: 0005797
2023-10-19 18:23 02FD Note Added: 0005798
2024-10-19 21:57 Saga Musix Note Added: 0006114
2024-10-20 16:17 Saga Musix Note Added: 0006136
2024-10-20 16:17 Saga Musix Assigned To => Saga Musix
2024-10-20 16:17 Saga Musix Status new => feedback
2024-10-21 12:48 Saga Musix Note Added: 0006137
2024-11-25 18:40 Saga Musix Note Added: 0006215
2024-12-04 14:15 02FD Note Added: 0006248
2024-12-04 14:15 02FD Status feedback => assigned
2024-12-04 14:55 Saga Musix Note Added: 0006249
2024-12-04 17:49 Saga Musix Status assigned => feedback
2024-12-07 05:56 02FD Note Added: 0006251
2024-12-07 05:56 02FD Status feedback => assigned
2024-12-07 15:47 Saga Musix Note Added: 0006252
2024-12-11 21:37 Saga Musix Note Added: 0006259