double step increment errors

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

Nowhk wrote:
mystran wrote: For something like MSEG, you could just count the actual samples in a double. That will always be exact (until you have like 2^53 samples), because the sample count is an integer. Then you can convert the segment end-points from wall-clock times to samples (rather than converting the sample length to wall-clock time and accumulating those) and do the comparisons and evaluations in samples. Everything except the counting is still inexact, but you avoid the error accumulation.
What do you mean with wall-clock? Can you give to me a fancy pseudo-code?
By "wall-clock" I mean seconds, minutes, whatever. The point is.. if you can keep the accumulation in samples (ie. integers) and only perform inexact computations with the result in a "one-shot" (rather than accumulated) fashion, then you avoid most of the error accumulation problems.

Post

mystran wrote:
Nowhk wrote:
mystran wrote: For something like MSEG, you could just count the actual samples in a double. That will always be exact (until you have like 2^53 samples), because the sample count is an integer. Then you can convert the segment end-points from wall-clock times to samples (rather than converting the sample length to wall-clock time and accumulating those) and do the comparisons and evaluations in samples. Everything except the counting is still inexact, but you avoid the error accumulation.
What do you mean with wall-clock? Can you give to me a fancy pseudo-code?
By "wall-clock" I mean seconds, minutes, whatever. The point is.. if you can keep the accumulation in samples (ie. integers) and only perform inexact computations with the result in a "one-shot" (rather than accumulated) fashion, then you avoid most of the error accumulation problems.
I still need (alongside integer) a part of fractional part, which still accumulate at each iteration. Thus, it still accumulate errors. I don't get it :)

Taking the aciddose code, with a speed of 0.1 Hz:

Code: Select all

float delta = 0.1f;
v.fraction += delta;
if (std::abs(v.fraction) >= 1.0f) {
 int whole_delta = std::trunc(v.fraction);
 v.whole += whole_delta;
 v.fraction -= whole_delta;
}
It does the same: fp accumulation + fmod at some points. There is "still" accumulation in the v.fraction part, thus errors introduced by many sum.

Yeah, it does less accumulations indeed: if before with 44.100 samples length, 0.1 hz, 1.000 loops I do 441.000.000 accumulations, now I do 44.100.000. But they are still a lot, with lots of errors.
Once I'll loop 10.000 times, I come back to the same problem.

I think I'm missing your suggestion hehe

Post

Nowhk wrote:
earlevel wrote:None of the steps sizes were perfectly accurate, but all were within the tolerance of the measuring system, and the last step got you to the end precisely. Not saying that is the solution, saying thinking about it differently gives the solution.
I don't see any way of going well in this scenario, sorry maybe I'm a bit monkey hehe.
Even if I quantize in "integer" with correct steps, I need to considerate that I can "divide" for INF; and that I also need to implement a dynamic ratio/speed (i.e. automatable).

Let say I reason with integer...

But what if I need 0.3 hz?...
Let me put it another way. Again, my point is to avoid using floating point for something it's poorly suited to. That doesn't mean avoid using it, just pay attention to how it works.

Pick pick a number that's not exact. Accumulate it x times. Compare it to the same number multiplier by x.

Code: Select all

#include <iostream>
using namespace std;
int main(int argc, char *argv[]) {
	float numer = 7;
	float denom = 13;
	float val = numer / denom;
	float mult = 1000000;
	float multVal = val * mult;

	float sum = 0;
	for (int idx = 0; idx < mult; idx++)
		sum += val;

	cout.precision(25);
	cout << "7/13: " << val << endl;
	cout << "sum:  " << sum << endl;
	cout << "mult: " << multVal << endl;
}

7/13: 0.53846156597137451171875
sum:  533647.125
mult: 538461.5625

Using float for less precision, 7/13 times 1000000. Summing is off by about 4815.4135. Multiplication is off by 0.02403845, a factor of 200280 smaller error. On modern processors multiplication is as fast as addition.

My point is that it's easy to know quite accurately which sample the millionth or billionth iteration should start on. There is no reason to drift.
My audio DSP blog: earlevel.com

Post

Nowhk wrote:
Aleksey Vaneev wrote:
Nowhk wrote:But what if I need 0.3 hz? 1/3 its not somethings I can express with integer.
Even if I rescale to 4410000 and I increment of 33, the error is bigger than using double :D
Just use the code block 2 I've posted, and forget about problems you are having. You can change Step at any time.
Uhm... that "InCounter > 500*Step": let say I've a step (speed) of 1.0 (hz), 400° samples, and I change step at 0,1, it become 50, and loop immediately.
That's not a problem. "InCounter > 500*Step" is *out* of "sample loop". If you reset it earlier, it will simply affect overall precision a bit. Usually sound is processed in sample blocks. 10%-1000% Step variation is fine with such approach.
Last edited by Aleksey Vaneev on Sat Sep 08, 2018 5:57 pm, edited 1 time in total.
Image

Post

PS—If you want to understand what I meant in a previous message about the floating point errors of adding small to big, try my code from the last message, but change the number of iterations. Add another cout for sum - multVal. One million iterations is off by about 4815, as I said. Try a tenth the number of iterations, 100000. The error is not off by 482, a tenth, but 37. That's because as the accumulation gets bigger, the error of each iteration becomes greater (eventually 100%). Try 10 million!
My audio DSP blog: earlevel.com

Post

Here's a much better solution I've just found:

Code: Select all

#include <stdio.h>
#include <stdint.h>

int main()
{
	const double SrcSampleRate = 44100.0;
	const double DstSampleRate = 48000.0;
	const double Step = SrcSampleRate / DstSampleRate;
	int64_t PosInt = 0; // Current integer offset
	double PosFrac = 0.0; // Current fractional offset
	int64_t i;

	for( i = 0; i < 1LL << 34; i++ )
	{
		PosFrac += Step;
		int PosIncr = (int) PosFrac;
		PosInt += PosIncr;
		PosFrac -= PosIncr;

		if(( i & (( 1LL << 28 ) - 1 )) == 0 )
		{
			printf( "%lli %.10f %.10f\n", PosInt, PosFrac,
				( i + 1 ) * SrcSampleRate / DstSampleRate );
		}
	}
}

Image

Post

To have a linear increment in the FP range requires the addends be within 2^(mantissa_bits+1) range of each other. For a single precision float, this means it's possible to increment from 1, by 1, to the value 16777216 with exact precision. The number of unique FP values that were skipped is 184549377. The total number of unique values in that range is 201326593

That's only ~8.3% of the number line that's representable by the FP.

Post

earlevel wrote: My point is that it's easy to know quite accurately which sample the millionth or billionth iteration should start on. There is no reason to drift.
Of course its better 1 multiplication than 10000 sums :) But how do you deal with variable speed?

Example. Let say you have 10000 samples, start from 0. Speed 0.1 till some points (4500° sample), than 0.3.
For what do you multiply after the 4500° sample? You can't do incIntCount * 0.3...

I don't think I can keep history of each Speed change...

Post

Nowhk wrote:
earlevel wrote: My point is that it's easy to know quite accurately which sample the millionth or billionth iteration should start on. There is no reason to drift.
Of course its better 1 multiplication than 10000 sums :) But how do you deal with variable speed?

Example. Let say you have 10000 samples, start from 0. Speed 0.1 till some points (4500° sample), than 0.3.
For what do you multiply after the 4500° sample? You can't do incIntCount * 0.3...

I don't think I can keep history of each Speed change...
OK, I may not understand exactly what you want to do, and don't have time to read the thread carefully, so I'm reluctant to be specific, but...

You can start over on speed changes. Since you're concerned with synchronization over the long term, I suppose the speed changes might be tempo changes. Great, at a tempo change, it's a new reference point. If you're concerned with constant speed changes, then I'm not sure what you're trying to stay in sync with or how the listener will know you're off.

But maybe I just don't understand your aim here, so maybe I'd better shut up :wink:

Mainly, I just wanted to make sure you understood the problem with relying on floating point for long-term accumulation.
My audio DSP blog: earlevel.com

Post

With regards to tempo sync: if you want to avoid drift, then always derive your timing from the PPQ position you get from the host. Otherwise some drift is guaranteed and it's almost certainly going to vary from host to host, depending on how the host actually calculates it's internal timing... and that's before you even start with tempo changes.

Post

Nowhk wrote:And whats the purpose of "v.whole"? You never use it :P
You've misread the code. It is used as the upper int32_t word of a int64_t in union: "f.whole : f.fraction" union with "fractional".

What you're saying is like:

inc eax

"what is the point of ah? you've never used it."

Yes it is used. It's part of the eax register!
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

Regarding normalization:

Yes definitely a good idea. Generally you'd want to identify roughly where precision makes an unacceptable jump and normalize before you reach that point.

For example if you need 1e-5 precision and error accumulates at 1e-8 per step this provides for 1000 steps. So you normalize each 1000 steps like so:

normalize_at = 1000;
outer loop {
for (i = 0; i < normalize_at; i++) {
process(offset + i);
}
coefficients = recompute_exactly_for(offset + normalize_at);
offset += normalize_at;
}

This is standard stuff. Computing the result via multiplication directly avoids error because generally the multiplicands are whole integers in part. So the exact offset in time is based upon some exact integer fraction and the fraction can be recomputed as needed exactly.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

earlevel wrote:You can start over on speed changes. Since you're concerned with synchronization over the long term, I suppose the speed changes might be tempo changes. Great, at a tempo change, it's a new reference point.
But once you "reset", you need to sum previous (passed) samples to the remaining one * new speed.
Length of 1000 samples. I process the first 813 at 1.0hz. Than in the middle I switch speed to 0.1.

After the 813° sample, I need to sum samplePos * 0.1 + the previous 813*1.

i.e. since I'll switch rates in the middle the length, I can't retrieve "the real position where I am" simple by Xsample * speed, since there's speeds history. And this will introduce "sum" anyway, right?
earlevel wrote:Mainly, I just wanted to make sure you understood the problem with relying on floating point for long-term accumulation.
Yeah, got your points I think, but don't get a solution that can fit with my scenario :)
mystran wrote:With regards to tempo sync: if you want to avoid drift, then always derive your timing from the PPQ position you get from the host.
I'd like to be very indipendent from DAW, also because I'd like to release it standalone. Also, my "speed" is not sync with daw, but its essentially "free" (in hz).

Post

Are you outputting samples?

Then your speed isn't in Hz, it's some loose approximation to Hz in integer/discrete samples.

So you already have an exact integer reference.

Use it.

A uint64_t can represent up to 96076792050570.581+1/3e-3 seconds at 192 kHz rate.

That's approximately 3046575 years.
bill gates wrote:3.04 million years is enough for anyone
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

aciddose wrote:Are you outputting samples?

Then your speed isn't in Hz, it's some loose approximation to Hz in integer/discrete samples.

So you already have an exact integer reference.
Sorry, I don't think I'm really getting your point :neutral:

Are you suggesting somethings like this?

Code: Select all

#include <iostream>

const long envLength = 100;

uint64_t ResetLength(uint64_t processedSamples, double speed) {
	return (uint64_t)(envLength / speed);
}

int main() {
	std::cout.precision(50);

	int loopIndex = 0;
	int numLoops = 3;

	uint64_t indexChangeSpeed = 40;
	double speed = 1.0;
	double newSpeed = 0.5;

	uint64_t step = 0;
	uint64_t length = ResetLength(step, speed);

	while (step <= length) {
		// loop
		if (step == length) {
			step = 0;
			length = ResetLength(step, speed);

			loopIndex++;

			if (loopIndex >= numLoops) break;

			std::cout << std::endl << "--- loop ---" << std::endl << std::endl;
		}

		// emulating change speed
		if (step == indexChangeSpeed && loopIndex == 1) {
			uint64_t newStep = (uint64_t)((step / speed) / newSpeed);
			speed = newSpeed;
			length = ResetLength(step, speed);
			step = newStep;

			std::cout << std::endl << "--- change speed ---" << std::endl << std::endl;
		}

		std::cout << "step: " << step << " | pos: " << step / (double)length << std::endl;

		step += 1;
	}

	std::cout << std::endl;
	system("pause");

	return 0;
}
It seems nice, clear, fast and totally precise, even changing speed during playing, whenever I want:

Code: Select all

step: 0 | pos: 0
step: 1 | pos: 0.010000000000000000208166817117216851329430937767029
step: 2 | pos: 0.020000000000000000416333634234433702658861875534058
step: 3 | pos: 0.02999999999999999888977697537484345957636833190918
step: 4 | pos: 0.040000000000000000832667268468867405317723751068115
step: 5 | pos: 0.050000000000000002775557561562891351059079170227051
step: 6 | pos: 0.059999999999999997779553950749686919152736663818359
step: 7 | pos: 0.070000000000000006661338147750939242541790008544922
step: 8 | pos: 0.08000000000000000166533453693773481063544750213623
step: 9 | pos: 0.089999999999999996669330926124530378729104995727539
step: 10 | pos: 0.1000000000000000055511151231257827021181583404541
step: 11 | pos: 0.11000000000000000055511151231257827021181583404541
step: 12 | pos: 0.11999999999999999555910790149937383830547332763672
step: 13 | pos: 0.13000000000000000444089209850062616169452667236328
step: 14 | pos: 0.14000000000000001332267629550187848508358001708984
step: 15 | pos: 0.1499999999999999944488848768742172978818416595459
step: 16 | pos: 0.16000000000000000333066907387546962127089500427246
step: 17 | pos: 0.17000000000000001221245327087672194465994834899902
step: 18 | pos: 0.17999999999999999333866185224906075745820999145508
step: 19 | pos: 0.19000000000000000222044604925031308084726333618164
step: 20 | pos: 0.2000000000000000111022302462515654042363166809082
step: 21 | pos: 0.20999999999999999222843882762390421703457832336426
step: 22 | pos: 0.22000000000000000111022302462515654042363166809082
step: 23 | pos: 0.23000000000000000999200722162640886381268501281738
step: 24 | pos: 0.23999999999999999111821580299874767661094665527344
step: 25 | pos: 0.25
step: 26 | pos: 0.26000000000000000888178419700125232338905334472656
step: 27 | pos: 0.27000000000000001776356839400250464677810668945313
step: 28 | pos: 0.28000000000000002664535259100375697016716003417969
step: 29 | pos: 0.28999999999999998001598555674718227237462997436523
step: 30 | pos: 0.2999999999999999888977697537484345957636833190918
step: 31 | pos: 0.30999999999999999777955395074968691915273666381836
step: 32 | pos: 0.32000000000000000666133814775093924254179000854492
step: 33 | pos: 0.33000000000000001554312234475219156593084335327148
step: 34 | pos: 0.34000000000000002442490654175344388931989669799805
step: 35 | pos: 0.34999999999999997779553950749686919152736663818359
step: 36 | pos: 0.35999999999999998667732370449812151491641998291016
step: 37 | pos: 0.36999999999999999555910790149937383830547332763672
step: 38 | pos: 0.38000000000000000444089209850062616169452667236328
step: 39 | pos: 0.39000000000000001332267629550187848508358001708984
step: 40 | pos: 0.40000000000000002220446049250313080847263336181641
step: 41 | pos: 0.40999999999999997557509345824655611068010330200195
step: 42 | pos: 0.41999999999999998445687765524780843406915664672852
step: 43 | pos: 0.42999999999999999333866185224906075745820999145508
step: 44 | pos: 0.44000000000000000222044604925031308084726333618164
step: 45 | pos: 0.4500000000000000111022302462515654042363166809082
step: 46 | pos: 0.46000000000000001998401444325281772762537002563477
step: 47 | pos: 0.46999999999999997335464740899624302983283996582031
step: 48 | pos: 0.47999999999999998223643160599749535322189331054688
step: 49 | pos: 0.48999999999999999111821580299874767661094665527344
step: 50 | pos: 0.5
step: 51 | pos: 0.51000000000000000888178419700125232338905334472656
step: 52 | pos: 0.52000000000000001776356839400250464677810668945313
step: 53 | pos: 0.53000000000000002664535259100375697016716003417969
step: 54 | pos: 0.54000000000000003552713678800500929355621337890625
step: 55 | pos: 0.55000000000000004440892098500626161694526672363281
step: 56 | pos: 0.56000000000000005329070518200751394033432006835938
step: 57 | pos: 0.56999999999999995115018691649311222136020660400391
step: 58 | pos: 0.57999999999999996003197111349436454474925994873047
step: 59 | pos: 0.58999999999999996891375531049561686813831329345703
step: 60 | pos: 0.59999999999999997779553950749686919152736663818359
step: 61 | pos: 0.60999999999999998667732370449812151491641998291016
step: 62 | pos: 0.61999999999999999555910790149937383830547332763672
step: 63 | pos: 0.63000000000000000444089209850062616169452667236328
step: 64 | pos: 0.64000000000000001332267629550187848508358001708984
step: 65 | pos: 0.65000000000000002220446049250313080847263336181641
step: 66 | pos: 0.66000000000000003108624468950438313186168670654297
step: 67 | pos: 0.67000000000000003996802888650563545525074005126953
step: 68 | pos: 0.68000000000000004884981308350688777863979339599609
step: 69 | pos: 0.68999999999999994670929481799248605966567993164063
step: 70 | pos: 0.69999999999999995559107901499373838305473327636719
step: 71 | pos: 0.70999999999999996447286321199499070644378662109375
step: 72 | pos: 0.71999999999999997335464740899624302983283996582031
step: 73 | pos: 0.72999999999999998223643160599749535322189331054688
step: 74 | pos: 0.73999999999999999111821580299874767661094665527344
step: 75 | pos: 0.75
step: 76 | pos: 0.76000000000000000888178419700125232338905334472656
step: 77 | pos: 0.77000000000000001776356839400250464677810668945313
step: 78 | pos: 0.78000000000000002664535259100375697016716003417969
step: 79 | pos: 0.79000000000000003552713678800500929355621337890625
step: 80 | pos: 0.80000000000000004440892098500626161694526672363281
step: 81 | pos: 0.81000000000000005329070518200751394033432006835938
step: 82 | pos: 0.81999999999999995115018691649311222136020660400391
step: 83 | pos: 0.82999999999999996003197111349436454474925994873047
step: 84 | pos: 0.83999999999999996891375531049561686813831329345703
step: 85 | pos: 0.84999999999999997779553950749686919152736663818359
step: 86 | pos: 0.85999999999999998667732370449812151491641998291016
step: 87 | pos: 0.86999999999999999555910790149937383830547332763672
step: 88 | pos: 0.88000000000000000444089209850062616169452667236328
step: 89 | pos: 0.89000000000000001332267629550187848508358001708984
step: 90 | pos: 0.90000000000000002220446049250313080847263336181641
step: 91 | pos: 0.91000000000000003108624468950438313186168670654297
step: 92 | pos: 0.92000000000000003996802888650563545525074005126953
step: 93 | pos: 0.93000000000000004884981308350688777863979339599609
step: 94 | pos: 0.93999999999999994670929481799248605966567993164063
step: 95 | pos: 0.94999999999999995559107901499373838305473327636719
step: 96 | pos: 0.95999999999999996447286321199499070644378662109375
step: 97 | pos: 0.96999999999999997335464740899624302983283996582031
step: 98 | pos: 0.97999999999999998223643160599749535322189331054688
step: 99 | pos: 0.98999999999999999111821580299874767661094665527344

--- loop ---

step: 0 | pos: 0
step: 1 | pos: 0.010000000000000000208166817117216851329430937767029
step: 2 | pos: 0.020000000000000000416333634234433702658861875534058
step: 3 | pos: 0.02999999999999999888977697537484345957636833190918
step: 4 | pos: 0.040000000000000000832667268468867405317723751068115
step: 5 | pos: 0.050000000000000002775557561562891351059079170227051
step: 6 | pos: 0.059999999999999997779553950749686919152736663818359
step: 7 | pos: 0.070000000000000006661338147750939242541790008544922
step: 8 | pos: 0.08000000000000000166533453693773481063544750213623
step: 9 | pos: 0.089999999999999996669330926124530378729104995727539
step: 10 | pos: 0.1000000000000000055511151231257827021181583404541
step: 11 | pos: 0.11000000000000000055511151231257827021181583404541
step: 12 | pos: 0.11999999999999999555910790149937383830547332763672
step: 13 | pos: 0.13000000000000000444089209850062616169452667236328
step: 14 | pos: 0.14000000000000001332267629550187848508358001708984
step: 15 | pos: 0.1499999999999999944488848768742172978818416595459
step: 16 | pos: 0.16000000000000000333066907387546962127089500427246
step: 17 | pos: 0.17000000000000001221245327087672194465994834899902
step: 18 | pos: 0.17999999999999999333866185224906075745820999145508
step: 19 | pos: 0.19000000000000000222044604925031308084726333618164
step: 20 | pos: 0.2000000000000000111022302462515654042363166809082
step: 21 | pos: 0.20999999999999999222843882762390421703457832336426
step: 22 | pos: 0.22000000000000000111022302462515654042363166809082
step: 23 | pos: 0.23000000000000000999200722162640886381268501281738
step: 24 | pos: 0.23999999999999999111821580299874767661094665527344
step: 25 | pos: 0.25
step: 26 | pos: 0.26000000000000000888178419700125232338905334472656
step: 27 | pos: 0.27000000000000001776356839400250464677810668945313
step: 28 | pos: 0.28000000000000002664535259100375697016716003417969
step: 29 | pos: 0.28999999999999998001598555674718227237462997436523
step: 30 | pos: 0.2999999999999999888977697537484345957636833190918
step: 31 | pos: 0.30999999999999999777955395074968691915273666381836
step: 32 | pos: 0.32000000000000000666133814775093924254179000854492
step: 33 | pos: 0.33000000000000001554312234475219156593084335327148
step: 34 | pos: 0.34000000000000002442490654175344388931989669799805
step: 35 | pos: 0.34999999999999997779553950749686919152736663818359
step: 36 | pos: 0.35999999999999998667732370449812151491641998291016
step: 37 | pos: 0.36999999999999999555910790149937383830547332763672
step: 38 | pos: 0.38000000000000000444089209850062616169452667236328
step: 39 | pos: 0.39000000000000001332267629550187848508358001708984

--- change speed ---

step: 80 | pos: 0.40000000000000002220446049250313080847263336181641
step: 81 | pos: 0.40500000000000002664535259100375697016716003417969
step: 82 | pos: 0.40999999999999997557509345824655611068010330200195
step: 83 | pos: 0.41499999999999998001598555674718227237462997436523
step: 84 | pos: 0.41999999999999998445687765524780843406915664672852
step: 85 | pos: 0.4249999999999999888977697537484345957636833190918
step: 86 | pos: 0.42999999999999999333866185224906075745820999145508
step: 87 | pos: 0.43499999999999999777955395074968691915273666381836
step: 88 | pos: 0.44000000000000000222044604925031308084726333618164
step: 89 | pos: 0.44500000000000000666133814775093924254179000854492
step: 90 | pos: 0.4500000000000000111022302462515654042363166809082
step: 91 | pos: 0.45500000000000001554312234475219156593084335327148
step: 92 | pos: 0.46000000000000001998401444325281772762537002563477
step: 93 | pos: 0.46500000000000002442490654175344388931989669799805
step: 94 | pos: 0.46999999999999997335464740899624302983283996582031
step: 95 | pos: 0.47499999999999997779553950749686919152736663818359
step: 96 | pos: 0.47999999999999998223643160599749535322189331054688
step: 97 | pos: 0.48499999999999998667732370449812151491641998291016
step: 98 | pos: 0.48999999999999999111821580299874767661094665527344
step: 99 | pos: 0.49499999999999999555910790149937383830547332763672
step: 100 | pos: 0.5
step: 101 | pos: 0.50500000000000000444089209850062616169452667236328
step: 102 | pos: 0.51000000000000000888178419700125232338905334472656
step: 103 | pos: 0.51500000000000001332267629550187848508358001708984
step: 104 | pos: 0.52000000000000001776356839400250464677810668945313
step: 105 | pos: 0.52500000000000002220446049250313080847263336181641
step: 106 | pos: 0.53000000000000002664535259100375697016716003417969
step: 107 | pos: 0.53500000000000003108624468950438313186168670654297
step: 108 | pos: 0.54000000000000003552713678800500929355621337890625
step: 109 | pos: 0.54500000000000003996802888650563545525074005126953
step: 110 | pos: 0.55000000000000004440892098500626161694526672363281
step: 111 | pos: 0.55500000000000004884981308350688777863979339599609
step: 112 | pos: 0.56000000000000005329070518200751394033432006835938
step: 113 | pos: 0.56499999999999994670929481799248605966567993164063
step: 114 | pos: 0.56999999999999995115018691649311222136020660400391
step: 115 | pos: 0.57499999999999995559107901499373838305473327636719
step: 116 | pos: 0.57999999999999996003197111349436454474925994873047
step: 117 | pos: 0.58499999999999996447286321199499070644378662109375
step: 118 | pos: 0.58999999999999996891375531049561686813831329345703
step: 119 | pos: 0.59499999999999997335464740899624302983283996582031
step: 120 | pos: 0.59999999999999997779553950749686919152736663818359
step: 121 | pos: 0.60499999999999998223643160599749535322189331054688
step: 122 | pos: 0.60999999999999998667732370449812151491641998291016
step: 123 | pos: 0.61499999999999999111821580299874767661094665527344
step: 124 | pos: 0.61999999999999999555910790149937383830547332763672
step: 125 | pos: 0.625
step: 126 | pos: 0.63000000000000000444089209850062616169452667236328
step: 127 | pos: 0.63500000000000000888178419700125232338905334472656
step: 128 | pos: 0.64000000000000001332267629550187848508358001708984
step: 129 | pos: 0.64500000000000001776356839400250464677810668945313
step: 130 | pos: 0.65000000000000002220446049250313080847263336181641
step: 131 | pos: 0.65500000000000002664535259100375697016716003417969
step: 132 | pos: 0.66000000000000003108624468950438313186168670654297
step: 133 | pos: 0.66500000000000003552713678800500929355621337890625
step: 134 | pos: 0.67000000000000003996802888650563545525074005126953
step: 135 | pos: 0.67500000000000004440892098500626161694526672363281
step: 136 | pos: 0.68000000000000004884981308350688777863979339599609
step: 137 | pos: 0.68500000000000005329070518200751394033432006835938
step: 138 | pos: 0.68999999999999994670929481799248605966567993164063
step: 139 | pos: 0.69499999999999995115018691649311222136020660400391
step: 140 | pos: 0.69999999999999995559107901499373838305473327636719
step: 141 | pos: 0.70499999999999996003197111349436454474925994873047
step: 142 | pos: 0.70999999999999996447286321199499070644378662109375
step: 143 | pos: 0.71499999999999996891375531049561686813831329345703
step: 144 | pos: 0.71999999999999997335464740899624302983283996582031
step: 145 | pos: 0.72499999999999997779553950749686919152736663818359
step: 146 | pos: 0.72999999999999998223643160599749535322189331054688
step: 147 | pos: 0.73499999999999998667732370449812151491641998291016
step: 148 | pos: 0.73999999999999999111821580299874767661094665527344
step: 149 | pos: 0.74499999999999999555910790149937383830547332763672
step: 150 | pos: 0.75
step: 151 | pos: 0.75500000000000000444089209850062616169452667236328
step: 152 | pos: 0.76000000000000000888178419700125232338905334472656
step: 153 | pos: 0.76500000000000001332267629550187848508358001708984
step: 154 | pos: 0.77000000000000001776356839400250464677810668945313
step: 155 | pos: 0.77500000000000002220446049250313080847263336181641
step: 156 | pos: 0.78000000000000002664535259100375697016716003417969
step: 157 | pos: 0.78500000000000003108624468950438313186168670654297
step: 158 | pos: 0.79000000000000003552713678800500929355621337890625
step: 159 | pos: 0.79500000000000003996802888650563545525074005126953
step: 160 | pos: 0.80000000000000004440892098500626161694526672363281
step: 161 | pos: 0.80500000000000004884981308350688777863979339599609
step: 162 | pos: 0.81000000000000005329070518200751394033432006835938
step: 163 | pos: 0.81499999999999994670929481799248605966567993164063
step: 164 | pos: 0.81999999999999995115018691649311222136020660400391
step: 165 | pos: 0.82499999999999995559107901499373838305473327636719
step: 166 | pos: 0.82999999999999996003197111349436454474925994873047
step: 167 | pos: 0.83499999999999996447286321199499070644378662109375
step: 168 | pos: 0.83999999999999996891375531049561686813831329345703
step: 169 | pos: 0.84499999999999997335464740899624302983283996582031
step: 170 | pos: 0.84999999999999997779553950749686919152736663818359
step: 171 | pos: 0.85499999999999998223643160599749535322189331054688
step: 172 | pos: 0.85999999999999998667732370449812151491641998291016
step: 173 | pos: 0.86499999999999999111821580299874767661094665527344
step: 174 | pos: 0.86999999999999999555910790149937383830547332763672
step: 175 | pos: 0.875
step: 176 | pos: 0.88000000000000000444089209850062616169452667236328
step: 177 | pos: 0.88500000000000000888178419700125232338905334472656
step: 178 | pos: 0.89000000000000001332267629550187848508358001708984
step: 179 | pos: 0.89500000000000001776356839400250464677810668945313
step: 180 | pos: 0.90000000000000002220446049250313080847263336181641
step: 181 | pos: 0.90500000000000002664535259100375697016716003417969
step: 182 | pos: 0.91000000000000003108624468950438313186168670654297
step: 183 | pos: 0.91500000000000003552713678800500929355621337890625
step: 184 | pos: 0.92000000000000003996802888650563545525074005126953
step: 185 | pos: 0.92500000000000004440892098500626161694526672363281
step: 186 | pos: 0.93000000000000004884981308350688777863979339599609
step: 187 | pos: 0.93500000000000005329070518200751394033432006835938
step: 188 | pos: 0.93999999999999994670929481799248605966567993164063
step: 189 | pos: 0.94499999999999995115018691649311222136020660400391
step: 190 | pos: 0.94999999999999995559107901499373838305473327636719
step: 191 | pos: 0.95499999999999996003197111349436454474925994873047
step: 192 | pos: 0.95999999999999996447286321199499070644378662109375
step: 193 | pos: 0.96499999999999996891375531049561686813831329345703
step: 194 | pos: 0.96999999999999997335464740899624302983283996582031
step: 195 | pos: 0.97499999999999997779553950749686919152736663818359
step: 196 | pos: 0.97999999999999998223643160599749535322189331054688
step: 197 | pos: 0.98499999999999998667732370449812151491641998291016
step: 198 | pos: 0.98999999999999999111821580299874767661094665527344
step: 199 | pos: 0.99499999999999999555910790149937383830547332763672

--- loop ---

step: 0 | pos: 0
step: 1 | pos: 0.0050000000000000001040834085586084256647154688835144
step: 2 | pos: 0.010000000000000000208166817117216851329430937767029
step: 3 | pos: 0.01499999999999999944488848768742172978818416595459
step: 4 | pos: 0.020000000000000000416333634234433702658861875534058
step: 5 | pos: 0.025000000000000001387778780781445675529539585113525
step: 6 | pos: 0.02999999999999999888977697537484345957636833190918
step: 7 | pos: 0.035000000000000003330669073875469621270895004272461
step: 8 | pos: 0.040000000000000000832667268468867405317723751068115
step: 9 | pos: 0.04499999999999999833466546306226518936455249786377
step: 10 | pos: 0.050000000000000002775557561562891351059079170227051
step: 11 | pos: 0.055000000000000000277555756156289135105907917022705
step: 12 | pos: 0.059999999999999997779553950749686919152736663818359
step: 13 | pos: 0.065000000000000002220446049250313080847263336181641
step: 14 | pos: 0.070000000000000006661338147750939242541790008544922
step: 15 | pos: 0.074999999999999997224442438437108648940920829772949
step: 16 | pos: 0.08000000000000000166533453693773481063544750213623
step: 17 | pos: 0.085000000000000006106226635438360972329974174499512
step: 18 | pos: 0.089999999999999996669330926124530378729104995727539
step: 19 | pos: 0.09500000000000000111022302462515654042363166809082
step: 20 | pos: 0.1000000000000000055511151231257827021181583404541
step: 21 | pos: 0.10499999999999999611421941381195210851728916168213
step: 22 | pos: 0.11000000000000000055511151231257827021181583404541
step: 23 | pos: 0.11500000000000000499600361081320443190634250640869
step: 24 | pos: 0.11999999999999999555910790149937383830547332763672
step: 25 | pos: 0.125
step: 26 | pos: 0.13000000000000000444089209850062616169452667236328
step: 27 | pos: 0.13500000000000000888178419700125232338905334472656
step: 28 | pos: 0.14000000000000001332267629550187848508358001708984
step: 29 | pos: 0.14499999999999999000799277837359113618731498718262
step: 30 | pos: 0.1499999999999999944488848768742172978818416595459
step: 31 | pos: 0.15499999999999999888977697537484345957636833190918
step: 32 | pos: 0.16000000000000000333066907387546962127089500427246
step: 33 | pos: 0.16500000000000000777156117237609578296542167663574
step: 34 | pos: 0.17000000000000001221245327087672194465994834899902
step: 35 | pos: 0.1749999999999999888977697537484345957636833190918
step: 36 | pos: 0.17999999999999999333866185224906075745820999145508
step: 37 | pos: 0.18499999999999999777955395074968691915273666381836
step: 38 | pos: 0.19000000000000000222044604925031308084726333618164
step: 39 | pos: 0.19500000000000000666133814775093924254179000854492
step: 40 | pos: 0.2000000000000000111022302462515654042363166809082
step: 41 | pos: 0.20499999999999998778754672912327805534005165100098
step: 42 | pos: 0.20999999999999999222843882762390421703457832336426
step: 43 | pos: 0.21499999999999999666933092612453037872910499572754
step: 44 | pos: 0.22000000000000000111022302462515654042363166809082
step: 45 | pos: 0.2250000000000000055511151231257827021181583404541
step: 46 | pos: 0.23000000000000000999200722162640886381268501281738
step: 47 | pos: 0.23499999999999998667732370449812151491641998291016
step: 48 | pos: 0.23999999999999999111821580299874767661094665527344
step: 49 | pos: 0.24499999999999999555910790149937383830547332763672
step: 50 | pos: 0.25
step: 51 | pos: 0.25500000000000000444089209850062616169452667236328
step: 52 | pos: 0.26000000000000000888178419700125232338905334472656
step: 53 | pos: 0.26500000000000001332267629550187848508358001708984
step: 54 | pos: 0.27000000000000001776356839400250464677810668945313
step: 55 | pos: 0.27500000000000002220446049250313080847263336181641
step: 56 | pos: 0.28000000000000002664535259100375697016716003417969
step: 57 | pos: 0.28499999999999997557509345824655611068010330200195
step: 58 | pos: 0.28999999999999998001598555674718227237462997436523
step: 59 | pos: 0.29499999999999998445687765524780843406915664672852
step: 60 | pos: 0.2999999999999999888977697537484345957636833190918
step: 61 | pos: 0.30499999999999999333866185224906075745820999145508
step: 62 | pos: 0.30999999999999999777955395074968691915273666381836
step: 63 | pos: 0.31500000000000000222044604925031308084726333618164
step: 64 | pos: 0.32000000000000000666133814775093924254179000854492
step: 65 | pos: 0.3250000000000000111022302462515654042363166809082
step: 66 | pos: 0.33000000000000001554312234475219156593084335327148
step: 67 | pos: 0.33500000000000001998401444325281772762537002563477
step: 68 | pos: 0.34000000000000002442490654175344388931989669799805
step: 69 | pos: 0.34499999999999997335464740899624302983283996582031
step: 70 | pos: 0.34999999999999997779553950749686919152736663818359
step: 71 | pos: 0.35499999999999998223643160599749535322189331054688
step: 72 | pos: 0.35999999999999998667732370449812151491641998291016
step: 73 | pos: 0.36499999999999999111821580299874767661094665527344
step: 74 | pos: 0.36999999999999999555910790149937383830547332763672
step: 75 | pos: 0.375
step: 76 | pos: 0.38000000000000000444089209850062616169452667236328
step: 77 | pos: 0.38500000000000000888178419700125232338905334472656
step: 78 | pos: 0.39000000000000001332267629550187848508358001708984
step: 79 | pos: 0.39500000000000001776356839400250464677810668945313
step: 80 | pos: 0.40000000000000002220446049250313080847263336181641
step: 81 | pos: 0.40500000000000002664535259100375697016716003417969
step: 82 | pos: 0.40999999999999997557509345824655611068010330200195
step: 83 | pos: 0.41499999999999998001598555674718227237462997436523
step: 84 | pos: 0.41999999999999998445687765524780843406915664672852
step: 85 | pos: 0.4249999999999999888977697537484345957636833190918
step: 86 | pos: 0.42999999999999999333866185224906075745820999145508
step: 87 | pos: 0.43499999999999999777955395074968691915273666381836
step: 88 | pos: 0.44000000000000000222044604925031308084726333618164
step: 89 | pos: 0.44500000000000000666133814775093924254179000854492
step: 90 | pos: 0.4500000000000000111022302462515654042363166809082
step: 91 | pos: 0.45500000000000001554312234475219156593084335327148
step: 92 | pos: 0.46000000000000001998401444325281772762537002563477
step: 93 | pos: 0.46500000000000002442490654175344388931989669799805
step: 94 | pos: 0.46999999999999997335464740899624302983283996582031
step: 95 | pos: 0.47499999999999997779553950749686919152736663818359
step: 96 | pos: 0.47999999999999998223643160599749535322189331054688
step: 97 | pos: 0.48499999999999998667732370449812151491641998291016
step: 98 | pos: 0.48999999999999999111821580299874767661094665527344
step: 99 | pos: 0.49499999999999999555910790149937383830547332763672
step: 100 | pos: 0.5
step: 101 | pos: 0.50500000000000000444089209850062616169452667236328
step: 102 | pos: 0.51000000000000000888178419700125232338905334472656
step: 103 | pos: 0.51500000000000001332267629550187848508358001708984
step: 104 | pos: 0.52000000000000001776356839400250464677810668945313
step: 105 | pos: 0.52500000000000002220446049250313080847263336181641
step: 106 | pos: 0.53000000000000002664535259100375697016716003417969
step: 107 | pos: 0.53500000000000003108624468950438313186168670654297
step: 108 | pos: 0.54000000000000003552713678800500929355621337890625
step: 109 | pos: 0.54500000000000003996802888650563545525074005126953
step: 110 | pos: 0.55000000000000004440892098500626161694526672363281
step: 111 | pos: 0.55500000000000004884981308350688777863979339599609
step: 112 | pos: 0.56000000000000005329070518200751394033432006835938
step: 113 | pos: 0.56499999999999994670929481799248605966567993164063
step: 114 | pos: 0.56999999999999995115018691649311222136020660400391
step: 115 | pos: 0.57499999999999995559107901499373838305473327636719
step: 116 | pos: 0.57999999999999996003197111349436454474925994873047
step: 117 | pos: 0.58499999999999996447286321199499070644378662109375
step: 118 | pos: 0.58999999999999996891375531049561686813831329345703
step: 119 | pos: 0.59499999999999997335464740899624302983283996582031
step: 120 | pos: 0.59999999999999997779553950749686919152736663818359
step: 121 | pos: 0.60499999999999998223643160599749535322189331054688
step: 122 | pos: 0.60999999999999998667732370449812151491641998291016
step: 123 | pos: 0.61499999999999999111821580299874767661094665527344
step: 124 | pos: 0.61999999999999999555910790149937383830547332763672
step: 125 | pos: 0.625
step: 126 | pos: 0.63000000000000000444089209850062616169452667236328
step: 127 | pos: 0.63500000000000000888178419700125232338905334472656
step: 128 | pos: 0.64000000000000001332267629550187848508358001708984
step: 129 | pos: 0.64500000000000001776356839400250464677810668945313
step: 130 | pos: 0.65000000000000002220446049250313080847263336181641
step: 131 | pos: 0.65500000000000002664535259100375697016716003417969
step: 132 | pos: 0.66000000000000003108624468950438313186168670654297
step: 133 | pos: 0.66500000000000003552713678800500929355621337890625
step: 134 | pos: 0.67000000000000003996802888650563545525074005126953
step: 135 | pos: 0.67500000000000004440892098500626161694526672363281
step: 136 | pos: 0.68000000000000004884981308350688777863979339599609
step: 137 | pos: 0.68500000000000005329070518200751394033432006835938
step: 138 | pos: 0.68999999999999994670929481799248605966567993164063
step: 139 | pos: 0.69499999999999995115018691649311222136020660400391
step: 140 | pos: 0.69999999999999995559107901499373838305473327636719
step: 141 | pos: 0.70499999999999996003197111349436454474925994873047
step: 142 | pos: 0.70999999999999996447286321199499070644378662109375
step: 143 | pos: 0.71499999999999996891375531049561686813831329345703
step: 144 | pos: 0.71999999999999997335464740899624302983283996582031
step: 145 | pos: 0.72499999999999997779553950749686919152736663818359
step: 146 | pos: 0.72999999999999998223643160599749535322189331054688
step: 147 | pos: 0.73499999999999998667732370449812151491641998291016
step: 148 | pos: 0.73999999999999999111821580299874767661094665527344
step: 149 | pos: 0.74499999999999999555910790149937383830547332763672
step: 150 | pos: 0.75
step: 151 | pos: 0.75500000000000000444089209850062616169452667236328
step: 152 | pos: 0.76000000000000000888178419700125232338905334472656
step: 153 | pos: 0.76500000000000001332267629550187848508358001708984
step: 154 | pos: 0.77000000000000001776356839400250464677810668945313
step: 155 | pos: 0.77500000000000002220446049250313080847263336181641
step: 156 | pos: 0.78000000000000002664535259100375697016716003417969
step: 157 | pos: 0.78500000000000003108624468950438313186168670654297
step: 158 | pos: 0.79000000000000003552713678800500929355621337890625
step: 159 | pos: 0.79500000000000003996802888650563545525074005126953
step: 160 | pos: 0.80000000000000004440892098500626161694526672363281
step: 161 | pos: 0.80500000000000004884981308350688777863979339599609
step: 162 | pos: 0.81000000000000005329070518200751394033432006835938
step: 163 | pos: 0.81499999999999994670929481799248605966567993164063
step: 164 | pos: 0.81999999999999995115018691649311222136020660400391
step: 165 | pos: 0.82499999999999995559107901499373838305473327636719
step: 166 | pos: 0.82999999999999996003197111349436454474925994873047
step: 167 | pos: 0.83499999999999996447286321199499070644378662109375
step: 168 | pos: 0.83999999999999996891375531049561686813831329345703
step: 169 | pos: 0.84499999999999997335464740899624302983283996582031
step: 170 | pos: 0.84999999999999997779553950749686919152736663818359
step: 171 | pos: 0.85499999999999998223643160599749535322189331054688
step: 172 | pos: 0.85999999999999998667732370449812151491641998291016
step: 173 | pos: 0.86499999999999999111821580299874767661094665527344
step: 174 | pos: 0.86999999999999999555910790149937383830547332763672
step: 175 | pos: 0.875
step: 176 | pos: 0.88000000000000000444089209850062616169452667236328
step: 177 | pos: 0.88500000000000000888178419700125232338905334472656
step: 178 | pos: 0.89000000000000001332267629550187848508358001708984
step: 179 | pos: 0.89500000000000001776356839400250464677810668945313
step: 180 | pos: 0.90000000000000002220446049250313080847263336181641
step: 181 | pos: 0.90500000000000002664535259100375697016716003417969
step: 182 | pos: 0.91000000000000003108624468950438313186168670654297
step: 183 | pos: 0.91500000000000003552713678800500929355621337890625
step: 184 | pos: 0.92000000000000003996802888650563545525074005126953
step: 185 | pos: 0.92500000000000004440892098500626161694526672363281
step: 186 | pos: 0.93000000000000004884981308350688777863979339599609
step: 187 | pos: 0.93500000000000005329070518200751394033432006835938
step: 188 | pos: 0.93999999999999994670929481799248605966567993164063
step: 189 | pos: 0.94499999999999995115018691649311222136020660400391
step: 190 | pos: 0.94999999999999995559107901499373838305473327636719
step: 191 | pos: 0.95499999999999996003197111349436454474925994873047
step: 192 | pos: 0.95999999999999996447286321199499070644378662109375
step: 193 | pos: 0.96499999999999996891375531049561686813831329345703
step: 194 | pos: 0.96999999999999997335464740899624302983283996582031
step: 195 | pos: 0.97499999999999997779553950749686919152736663818359
step: 196 | pos: 0.97999999999999998223643160599749535322189331054688
step: 197 | pos: 0.98499999999999998667732370449812151491641998291016
step: 198 | pos: 0.98999999999999999111821580299874767661094665527344
step: 199 | pos: 0.99499999999999999555910790149937383830547332763672
BUT! As I said before... what if I need to iterate with speeds that are infinitesimal?
Try set double newSpeed = 0.3...
It will process 333 steps per loop... I still need fractional part (fp), which will sum, and accumulate... and so errors... :ud:

Post Reply

Return to “DSP and Plugin Development”