View Issue Details

IDCategoryLast Update
0007947bugs2020-06-01 14:30
ReporterchaotAssigned Topaul 
Reproducibilityrandom 
Status assignedResolutionopen 
PlatformSome Other LinuxOSArch LinuxOS Versionunknown
Product Version6.0-pre1 
Fixed in Version 
Summary0007947: Midi note micro-shifted on region resize
DescriptionSee the attached video. It should be self-explanatory.
TagsNo tags attached.

Relationships

related to 0008128 new First note of MIDI clip not visible in UI 

Activities

chaot

2020-03-27 23:14

reporter   ~0021063

Upload file...

chaot

2020-03-27 23:20

reporter   ~0021064

The file upload here somehow doesn't work for me. So, here a temporary upload somewhere else:

https://www.file-upload.net/download-13967146/midi_note_move_bug.mkv.html

chaot

2020-03-28 10:51

reporter   ~0021068

Sorry for the brief description. I had a long version of this report but it got lost due to reload. So, here's a bit more info.

* This issue does not happen always, but I cannot predict when it happens and when it does not.
* This micro-shift forward of the midi note happens when resizing the region at the front.
* This might be connected to some snapping issues that I observed, but I still try to figure out when/why those happen.

chaot

2020-03-28 11:43

reporter   ~0021070

I think I have a deterministic way to reproduce it:

1) Create a new session and add a midi track
2) Create a midi region at bar 41
3) Resize it such that the end is at bar 42
4) Add a note (quarter) at the beginning (i.e., bar 41)
5) Move region to start at bar 42
6) Resize the beginning of the region to start at bar 41
7) Resize it back to start at bar 42

Now the note was shifted very slightly to the front and thus disappears in 7).

paul

2020-03-28 17:36

administrator   ~0021076

After moving the region start earlier, the beat ends up with a start at 0|1|1919 .... 1 ppqn before beat 2 (within the region). Now when you move the region start back, the note start ends up 1 ppqn *before* the new region start.

Not sure yet if this is a logic error or a rounding error.

paul

2020-03-28 18:17

administrator   ~0021077

OK, it's a rounding error. During the "trim" that moves the start back to bar 41, the region's start gets computed (in beats) as -3.99995 rather than -4.0 earlier in time.

paul

2020-03-28 21:04

administrator   ~0021080

Here are some notes from debugging.

The region is ending up 1 sample to early. When dragging from bar 41 to bar 42 @ 441kHz and 120bpm 4/4 it should end up at 3616200 but finishes at 3616199

Here's some debug output from the drag:

pointer sample = 3552746 unsnapped, region pos = 3528304 lp 3528000
motion, xdelta = 0 pending pos 3528000
 qn delta 0
Dragging region(s) from 1 different track(s), max dist: 0
pointer sample = 3553962 unsnapped, region pos = 3529520 lp 3528000
motion, xdelta = 0 pending pos 3528000
 qn delta 0
pointer sample = 3554874 unsnapped, region pos = 3530432 lp 3528000
motion, xdelta = 0 pending pos 3528000
 qn delta 0
pointer sample = 3563082 unsnapped, region pos = 3538640 lp 3528000
pixels since last 35 total = 35
total samples 10640 vs 10640 @ 304
 offset = 3538640
motion, xdelta = 35 pending pos 3538640
 qn delta 0.48254
pointer sample = 3569162 unsnapped, region pos = 3544720 lp 3538640
pixels since last 37.5329 total = 72.5329
total samples 22050 vs 22050 @ 304
 offset = 3550050
motion, xdelta = 37.5329 pending pos 3550050
 qn delta 0.51746
pointer sample = 3582234 unsnapped, region pos = 3557792 lp 3550050
pixels since last 25.4671 total = 98
total samples 29792 vs 29792 @ 304
 offset = 3557792
motion, xdelta = 25.4671 pending pos 3557792
 qn delta 0.351111
pointer sample = 3592874 unsnapped, region pos = 3568432 lp 3557792
pixels since last 47.0658 total = 145.066
total samples 44100 vs 44100 @ 304
 offset = 3572100
motion, xdelta = 47.0658 pending pos 3572100
 qn delta 0.648889
pointer sample = 3607162 unsnapped, region pos = 3582720 lp 3572100
pixels since last 34.9342 total = 180
total samples 54720 vs 54720 @ 304
 offset = 3582720
motion, xdelta = 34.9342 pending pos 3582720
 qn delta 0.481633
pointer sample = 3610810 unsnapped, region pos = 3586368 lp 3582720
pixels since last 12 total = 192
total samples 58368 vs 58368 @ 304
 offset = 3586368
motion, xdelta = 12 pending pos 3586368
 qn delta 0.165442
pointer sample = 3619018 unsnapped, region pos = 3594576 lp 3586368
pixels since last 25.5987 total = 217.599
total samples 66150 vs 66150 @ 304
 offset = 3594150
motion, xdelta = 25.5987 pending pos 3594150
 qn delta 0.352925
pointer sample = 3619930 unsnapped, region pos = 3595488 lp 3594150
motion, xdelta = 0 pending pos 3594150
 qn delta 0
pointer sample = 3622666 unsnapped, region pos = 3598224 lp 3594150
motion, xdelta = 0 pending pos 3594150
 qn delta 0
pointer sample = 3623274 unsnapped, region pos = 3598832 lp 3594150
motion, xdelta = 0 pending pos 3594150
 qn delta 0
pointer sample = 3623578 unsnapped, region pos = 3599136 lp 3594150
motion, xdelta = 0 pending pos 3594150
 qn delta 0
pointer sample = 3624186 unsnapped, region pos = 3599744 lp 3594150
motion, xdelta = 0 pending pos 3594150
 qn delta 0
pointer sample = 3624490 unsnapped, region pos = 3600048 lp 3594150
motion, xdelta = 0 pending pos 3594150
 qn delta 0
pointer sample = 3624794 unsnapped, region pos = 3600352 lp 3594150
motion, xdelta = 0 pending pos 3594150
 qn delta 0
pointer sample = 3625098 unsnapped, region pos = 3600656 lp 3594150
motion, xdelta = 0 pending pos 3594150
 qn delta 0
pointer sample = 3625402 unsnapped, region pos = 3600960 lp 3594150
motion, xdelta = 0 pending pos 3594150
 qn delta 0
pointer sample = 3625706 unsnapped, region pos = 3601264 lp 3594150
motion, xdelta = 0 pending pos 3594150
 qn delta 0
pointer sample = 3626922 unsnapped, region pos = 3602480 lp 3594150
pixels since last 27.4013 total = 245
total samples 74480 vs 74480 @ 304
 offset = 3602480
motion, xdelta = 27.4013 pending pos 3602480
 qn delta 0.377778
pointer sample = 3627530 unsnapped, region pos = 3603088 lp 3602480
pixels since last 2 total = 247
total samples 75088 vs 75088 @ 304
 offset = 3603088
motion, xdelta = 2 pending pos 3603088
 qn delta 0.0275737
pointer sample = 3629050 unsnapped, region pos = 3604608 lp 3603088
pixels since last 5 total = 252
total samples 76608 vs 76608 @ 304
 offset = 3604608
motion, xdelta = 5 pending pos 3604608
 qn delta 0.0689342
pointer sample = 3629658 unsnapped, region pos = 3605216 lp 3604608
pixels since last 2 total = 254
total samples 77216 vs 77216 @ 304
 offset = 3605216
motion, xdelta = 2 pending pos 3605216
 qn delta 0.0275737
pointer sample = 3630266 unsnapped, region pos = 3605824 lp 3605216
pixels since last 2 total = 256
total samples 77824 vs 77824 @ 304
 offset = 3605824
motion, xdelta = 2 pending pos 3605824
 qn delta 0.0275737
pointer sample = 3631482 unsnapped, region pos = 3607040 lp 3605824
pixels since last 4 total = 260
total samples 79040 vs 79040 @ 304
 offset = 3607040
motion, xdelta = 4 pending pos 3607040
 qn delta 0.0551474
pointer sample = 3631786 unsnapped, region pos = 3607344 lp 3607040
pixels since last 1 total = 261
total samples 79344 vs 79344 @ 304
 offset = 3607344
motion, xdelta = 1 pending pos 3607344
 qn delta 0.0137868
pointer sample = 3632090 unsnapped, region pos = 3607648 lp 3607344
pixels since last 1 total = 262
total samples 79648 vs 79648 @ 304
 offset = 3607648
motion, xdelta = 1 pending pos 3607648
 qn delta 0.0137868
pointer sample = 3632698 unsnapped, region pos = 3608256 lp 3607648
pixels since last 2 total = 264
total samples 80256 vs 80256 @ 304
 offset = 3608256
motion, xdelta = 2 pending pos 3608256
 qn delta 0.0275737
pointer sample = 3633002 unsnapped, region pos = 3608560 lp 3608256
pixels since last 1 total = 265
total samples 80560 vs 80560 @ 304
 offset = 3608560
motion, xdelta = 1 pending pos 3608560
 qn delta 0.0137868
pointer sample = 3633610 unsnapped, region pos = 3609168 lp 3608560
pixels since last 25.1283 total = 290.128
total samples 88199 vs 88199 @ 304
 offset = 3616199
motion, xdelta = 25.1283 pending pos 3616199
 qn delta 0.34644
pointer sample = 3633914 unsnapped, region pos = 3609472 lp 3616199
motion, xdelta = 0 pending pos 3616199
 qn delta 0
pointer sample = 3634522 unsnapped, region pos = 3610080 lp 3616199
motion, xdelta = 0 pending pos 3616199
 qn delta 0
pointer sample = 3634826 unsnapped, region pos = 3610384 lp 3616199
motion, xdelta = 0 pending pos 3616199
 qn delta 0
pointer sample = 3635130 unsnapped, region pos = 3610688 lp 3616199
motion, xdelta = 0 pending pos 3616199
 qn delta 0
pointer sample = 3635738 unsnapped, region pos = 3611296 lp 3616199
motion, xdelta = 0 pending pos 3616199
 qn delta 0
pointer sample = 3636042 unsnapped, region pos = 3611600 lp 3616199
motion, xdelta = 0 pending pos 3616199
 qn delta 0
MIDI-25 SP to 3616199 allow bbt 0

If there was 1 more pixel of recorded motion, we'd be in the right place.

I find that dragging the region later then earlier again frequently (always) moves it to the right location.

ngeiswei

2020-03-28 21:22

reporter   ~0021084

Paul, Chaot, do you think the following branch fixes the problem

https://github.com/ngeiswei/ardour/tree/fix-beats-operators-no-test

?

This is a rebased version of https://github.com/Ardour/ardour/pull/328 minus some operator refactoring and test units.

paul

2020-03-28 22:46

administrator   ~0021088

It will not fix the problem.

Also, master already contains the "ticktime" work (ie. Temporal::Beats is now fundamentally a fixed point class, with the double representation being used only for particular situations.

paul

2020-03-29 22:23

administrator   ~0021104

while running today, i realized that there is a different angle on this problem. given that we are moving between snapped positions, there's no possible excuse for how the start of the region can end up 1 sample off the snap position. i'll look into how that happens ... there may be a fix from that approach.

paul

2020-03-30 23:34

administrator   ~0021115

Current master should contain a fix for this.

It turned out that rounding was not the heart of the problem here. Ardour builds a cache of region positions (start, end) for use as snap positions during drags (optional) and for alignment operations. This cache used the last sample of a region. If a region is 1 bar long, its last sample is 1 sample before the bar next bar position. During the trim drag, we ended snapping to this position, and that led to the arithmetic "errors" that ultimately compute the start fo the note as "before" the start of the region. Now, the boundary cache uses the "end" of the region - the sample after its last sample. I believe this should fix the problem.

chaot

2020-03-31 22:20

reporter   ~0021118

I checked with 1aae553daec91a777656bb2cef687556c79b44c6 (which is master at the time of writing) and the problem seems to occur significantly less, especially, I cannot reproduce it anymore with the recipe I stated above. However, I could still trigger the same behavior. Maybe this remaining bug is due to rounding errors? Should I try to find a recipe for reproducing this bug? Or should I enable debug output and paste the output for you, when the bug happens?

paul

2020-03-31 22:47

administrator   ~0021119

A recipe is more useful - the amount of debug output that I had to add to track this down was immense. The existing -D foobar stuff isn't close to adequate.

paul

2020-03-31 22:48

administrator   ~0021120

One "known" recipe will be if you perform the drag with snap disabled. That could lead to the region being positioned in a way that the rounding errors show up and hide the note againl.

PeterSutton

2020-05-28 09:17

reporter   ~0024290

Can confirm this happens regularly in both A5 and A6 (final release). I've had to stop using Ardour for work. My workflow involves lots of small MIDI regions, each of which has their first note hidden and muted.

Issue History

Date Modified Username Field Change
2020-03-27 23:12 chaot New Issue
2020-03-27 23:14 chaot Note Added: 0021063
2020-03-27 23:20 chaot Note Added: 0021064
2020-03-28 10:51 chaot Note Added: 0021068
2020-03-28 11:43 chaot Note Added: 0021070
2020-03-28 17:01 paul Assigned To => paul
2020-03-28 17:22 paul Assigned To paul =>
2020-03-28 17:36 paul Note Added: 0021076
2020-03-28 18:17 paul Note Added: 0021077
2020-03-28 21:04 paul Note Added: 0021080
2020-03-28 21:22 ngeiswei Note Added: 0021084
2020-03-28 22:46 paul Note Added: 0021088
2020-03-29 02:16 paul Assigned To => paul
2020-03-29 22:23 paul Note Added: 0021104
2020-03-30 23:34 paul Note Added: 0021115
2020-03-31 00:17 paul Status new => feedback
2020-03-31 22:20 chaot Note Added: 0021118
2020-03-31 22:20 chaot Status feedback => assigned
2020-03-31 22:47 paul Note Added: 0021119
2020-03-31 22:48 paul Note Added: 0021120
2020-05-27 01:57 paul Relationship added related to 0008128
2020-05-28 09:17 PeterSutton Note Added: 0024290