Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Bug Reports

Thread Tools Display Modes
Old 09-06-2017, 11:57 AM   #1
Human being with feelings
Join Date: Jul 2009
Posts: 1,555
Default If using large PPQ, note position and length change by thousands of ticks when gluing

This bug report is a spin-off from two other reports:

Merge MIDI-items and
MIDI Item Glue 'BUG'.

When gluing, notes positions and lengths can be expected to change slightly in order to align the notes with MIDI ticks, as counted from the start of the glued item.

However, these "quantize to tick" shifts should never amount to more than one tick, since the MIDI events are supposed to remain as close as possible to their original positions.

When I tested gluing of MIDI items in the test projects discussed in these bug reports, I noticed that if I use large PPQs, note positions and lengths change by much more than one tick during gluing. The higher the PPQ, the greater the number of ticks changed: If I use the a PPQ of 32767 (=2^15-1), notes shift by about one tick. If I use a PPQ of 2147483647 (=2^31-1, which is apparently REAPER's maximum PPQ**), notes shift by thousands of ticks.

The following test project was provided in the above-mentioned threads:

Glue test 2.RPP

Originally Posted by juliansader View Post
I noticed something else that is disconcerting, and which happens even in older versions such as v5.40:

Some other DAWs such as Digital Performer and Samplitude avoid these issues by using huge PPQs internally, which practically have the same resolution as time-based positions.

I therefore re-tested the gluing with large PPQs and discovered that the note -- and other notes that I draw myself -- shift away from their original grid positions by several dozen ticks, and also lengthen by variable numbers of ticks. For example, when using a PPQ of 1536000, the note position shifts to 24 ticks before the beat, and lengthens by 60 ticks.

These changes happen even when gluing each of the two items separately.

These changes amount to a mere few microseconds, but are still undesirable: Surely any quantize-to-tick shifts during gluing should never be more than a single tick?

** If I try any higher PPQs, REAPER misinterprets the values, sometimes even using a PPQ of "1".

However, while 2147483647 works for gluing, it is incompatible with other MIDI functions such as MIDI_Get/SetAllEvts.

Last edited by juliansader; 09-08-2017 at 02:22 AM.
juliansader is offline   Reply With Quote
Old 09-09-2017, 01:13 PM   #2
Human being with feelings
Join Date: Jul 2016
Posts: 204

Is this happening in 5.50 RC22? Will try on this end as well.
Klangfarben is offline   Reply With Quote
Old 10-15-2017, 11:47 AM   #3
Human being with feelings
Join Date: Jul 2009
Posts: 1,555

I have just discovered something surprising: the amount of "drift" away from the grid position depends on the project sample rate.

Glueing MIDI items is in fact rendering-in-place, and somehow (I don't know why?) the audio sample rate affects the resolution of MIDI events too.

For example, when I use a high PPQ of 960000 together with a low sample rate of 8000, notes moves away from the grid by as much as 196 ticks. When the sample rate is 192kHz, the drift is 11 samples; and when the sample rate is 1MHz, there is no drift.

When I use the highest allowable PPQ of 2147483647 (= 32 bit signed integer) together with the highest possible sample rate of 100MHz, the notes are slightly off, but unnoticeable even at highest zoom.

The results may therefore suggest a way to fix this bug: under the hood, REAPER should perhaps always glue MIDI items at a sufficiently high sample rate relative to the PPQ?

Last edited by juliansader; 10-15-2017 at 12:04 PM.
juliansader is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -7. The time now is 10:34 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.