View Issue Details

IDProjectCategoryView StatusLast Update
0001007OpenMPT[All Projects] Generalpublic2017-08-11 12:55
ReporterPiotrAssigned To 
PrioritynormalSeveritytweakReproducibilityalways
Status closedResolutionno change required 
Platformx64OSWindowsOS Version10
Product VersionOpenMPT 1.26.12.00 / libopenmpt 0.2-beta26 (upgrade first) 
Target VersionFixed in Version 
Summary0001007: Nearest Neighbor - wrong result
Description

If I have 2 samples, 1, -1 (8000Hz) and resample it to specific even numbers, such as 14 samples (56000Hz) with nearest neighbor, it gives me
1 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1
with 8 1's and 6 -1's
It's supposed to give me
1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1
with 7 1's and 7 -1's.
This has really bothered me for my custom "Period" frequency scale, where there are pitches 0-31 where their number determines number of 8000Hz samples looped.

Steps To Reproduce

Have 2 samples, 1, -1 (8000Hz) and resample it to specific integer multiple (such as 56000Hz for 14 samples) with no interpolation.

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

Activities

Saga Musix

Saga Musix

2017-08-11 11:01

administrator   ~0003156

Computers are bad at periodic numbers. The ratio of 8/56 (or 1/7) is periodic (0.142857142857142857...) and thus cannot be stored perfectly. As a result, the sampler cannot hit every sampling point precisely and sometimes is of by +/-1. In any other resampling mode than Nearest Neighbour, this is not a problem because they look at the fractional part of the sample position as well, but it's in the definition of Nearest Neighbour that we do not look at fractional sample positions.

Hence, there is nothing we can do here. Resampling by almost three octaves using Nearest Neighbour is a very bad idea anyway. You will have to fix your sample yourself and live with that fact.

Piotr

Piotr

2017-08-11 12:54

reporter   ~0003159

I did not intend to resample. I intended to replace 2 period by 14 period.

Please show me debug log

Saga Musix

Saga Musix

2017-08-11 12:55

administrator   ~0003160

No matter what you wanted to do, you can manually fix the result by using the sample draw feature: Click the pen icon and correct the one offending sample point.

Issue History

Date Modified Username Field Change
2017-08-11 04:36 Piotr New Issue
2017-08-11 11:01 Saga Musix Status new => closed
2017-08-11 11:01 Saga Musix Resolution open => no change required
2017-08-11 11:01 Saga Musix Note Added: 0003156
2017-08-11 12:54 Piotr Status closed => feedback
2017-08-11 12:54 Piotr Resolution no change required => reopened
2017-08-11 12:54 Piotr Note Added: 0003159
2017-08-11 12:55 Saga Musix Status feedback => closed
2017-08-11 12:55 Saga Musix Resolution reopened => no change required
2017-08-11 12:55 Saga Musix Note Added: 0003160