73 inline Time _t(
int secs) {
return Time(FSecs(secs)); }
74 inline Time _t(
int s,
int div) {
return Time(FSecs(s,div)); }
98 CHECK (_t(10) ==
Time{FSecs(10)});
99 CHECK (_t(10,3) ==
Time{FSecs(10,3)});
100 CHECK (FSecs(10,3) == FSecs(10)/3);
101 CHECK (FSecs(10)/3 == 10_r/3);
102 CHECK (Rat(10,3) == 10_r/3);
103 CHECK (Rat(10,3) == boost::rational<int64_t>(10,3));
104 CHECK (rational_cast<float> (10_r/3) == 3.3333333f);
132 CHECK (zoomWin.overallSpan() ==
TimeSpan(_t(0), FSecs(23)));
133 CHECK (zoomWin.visible() ==
TimeSpan(_t(0), FSecs(23)));
134 CHECK (zoomWin.px_per_sec() == 25);
137 CHECK (zoomWin.px_per_sec() == 50);
138 CHECK (zoomWin.visible() ==
TimeSpan(_t(23,4), FSecs(23,2)));
139 CHECK (zoomWin.overallSpan() ==
TimeSpan(_t(0), FSecs(23)));
142 CHECK (zoomWin.px_per_sec() == 50);
143 CHECK (zoomWin.visible() ==
TimeSpan(_t(0), FSecs(23,2)));
144 CHECK (zoomWin.overallSpan() ==
TimeSpan(_t(0), FSecs(23)));
159 CHECK (win1.overallSpan() ==
TimeSpan(_t(0), FSecs(23)));
160 CHECK (win1.visible() == win1.overallSpan());
161 CHECK (win1.pxWidth() == 25*23);
162 CHECK (win1.px_per_sec() == 25);
165 CHECK (win2.overallSpan() ==
TimeSpan(_t(-1), FSecs(2)));
166 CHECK (win2.visible() == win2.overallSpan());
167 CHECK (win2.pxWidth() == 25*2);
168 CHECK (win2.px_per_sec() == 25);
171 CHECK (win3.overallSpan() ==
TimeSpan(_t(0), FSecs(23)));
172 CHECK (win3.visible() == win3.overallSpan());
173 CHECK (win3.pxWidth() == 555);
174 CHECK (win3.px_per_sec() == 555_r/23);
177 CHECK (win4.overallSpan() ==
TimeSpan(-
Time(0,10), FSecs(5)));
178 CHECK (win4.visible() == win4.overallSpan());
179 CHECK (win4.pxWidth() == 555);
180 CHECK (win4.px_per_sec() == 111);
196 CHECK (win.overallSpan() ==
TimeSpan(_t(0), FSecs(23)));
197 CHECK (win.visible() ==
TimeSpan(_t(0), FSecs(23)));
198 CHECK (win.pxWidth() == 23*25);
201 CHECK (win.overallSpan() ==
TimeSpan(_t(0), FSecs(23)));
202 CHECK (win.visible() ==
TimeSpan(_t(0), FSecs(1)));
203 CHECK (win.px_per_sec() == 25);
204 CHECK (win.pxWidth() == 25);
207 CHECK (win.overallSpan() ==
TimeSpan(_t(-50), FSecs(100)));
208 CHECK (win.visible() ==
TimeSpan(_t(0), FSecs(1)));
209 CHECK (win.px_per_sec() == 25);
210 CHECK (win.pxWidth() == 25);
213 CHECK (win.overallSpan() ==
TimeSpan(_t(-50), FSecs(100)));
214 CHECK (win.visible() ==
TimeSpan(_t(0), FSecs(4)));
215 CHECK (win.px_per_sec() == 25);
216 CHECK (win.pxWidth() == 100);
219 CHECK (win.overallSpan() ==
TimeSpan(_t(-50), FSecs(60)));
220 CHECK (win.visible() ==
TimeSpan(_t(-10), _t(0)));
221 CHECK (win.px_per_sec() == 10);
222 CHECK (win.pxWidth() == 100);
225 CHECK (win.overallSpan() ==
TimeSpan(_t(-50), FSecs(60)));
226 CHECK (win.visible() ==
TimeSpan(_t(-40), FSecs(50)));
227 CHECK (win.px_per_sec() == 10);
228 CHECK (win.pxWidth() == 500);
230 win.setOverallDuration (
Duration{FSecs(30)});
231 CHECK (win.overallSpan() ==
TimeSpan(_t(-50), _t(-20)));
232 CHECK (win.visible() ==
TimeSpan(_t(-50), FSecs(30)));
233 CHECK (win.px_per_sec() == 500_r/30);
234 CHECK (win.pxWidth() == 500);
237 CHECK (win.overallSpan() ==
TimeSpan(_t(-50), _t(-20)));
238 CHECK (win.visible() ==
TimeSpan(_t(-50), FSecs(30)*3/5));
239 CHECK (win.px_per_sec() == 500_r/30);
240 CHECK (win.pxWidth() == 300);
254 CHECK (win.px_per_sec() == 20);
257 CHECK (win.overallSpan() ==
TimeSpan(_t(0), _t(64)));
258 CHECK (win.visible() ==
TimeSpan(_t(32,2), FSecs(32)));
259 CHECK (win.px_per_sec() == 40);
260 CHECK (win.pxWidth() == 1280);
262 win.setVisiblePos(0.0);
263 CHECK (win.visible() ==
TimeSpan(_t(0), FSecs(32)));
265 win.nudgeMetric(+15);
266 CHECK (win.overallSpan() ==
TimeSpan(_t(0), _t(64)));
267 CHECK (win.visible() ==
TimeSpan(_t(0), FSecs(32,32768) +MICRO_TICK));
268 CHECK (win.visible().start() == _t(0));
269 CHECK (win.visible().end() ==
TimeValue(977));
273 CHECK (win.px_per_sec() == 1280_r/977 *
Time::SCALE);
274 CHECK (win.pxWidth() == 1280);
277 CHECK (rational_cast<double> (32_r/32768 *
Time::SCALE) == 976.5625);
280 CHECK (win.overallSpan() ==
TimeSpan(_t(0), _t(64)));
283 CHECK (win.pxWidth() == 1280);
291 CHECK (win.visible().duration() ==
TimeValue(640));
295 win.calibrateExtension(2);
296 CHECK (win.overallSpan() ==
TimeSpan(_t(0), _t(64)));
297 CHECK (win.visible().duration() ==
TimeValue(1));
299 CHECK (win.pxWidth() == 2);
301 win.calibrateExtension(1);
302 CHECK (win.visible().duration() ==
TimeValue(1));
304 CHECK (win.pxWidth() == 1);
306 win.calibrateExtension(1280);
307 CHECK (win.visible().duration() ==
TimeValue(1280));
308 CHECK (win.visible().duration() ==
Duration{1280*MICRO_TICK});
310 CHECK (win.pxWidth() == 1280);
311 CHECK (win.overallSpan() ==
TimeSpan(_t(0), _t(64)));
314 CHECK (win.visible().duration() ==
Duration{32 * 1280*MICRO_TICK});
316 CHECK (win.pxWidth() == 1280);
317 CHECK (win.overallSpan() ==
TimeSpan(_t(0), _t(64)));
319 win.nudgeMetric(-12);
320 CHECK (win.visible() == win.overallSpan());
321 CHECK (win.overallSpan() ==
TimeSpan(_t(0), _t(64)));
322 CHECK (win.px_per_sec() == 20);
323 CHECK (win.pxWidth() == 1280);
326 win.expandVisibleRange (
TimeSpan{_t(60), _t(62)});
327 CHECK (win.px_per_sec() == 20_r/64*2);
328 CHECK (win.visible().duration() == _t(64 * 32));
329 CHECK (win.visible() == win.overallSpan());
330 CHECK (win.overallSpan() ==
TimeSpan(_t(-1920), _t(128)));
331 CHECK (win.overallSpan().duration() == _t(2048));
334 win.setMetric (5 / (1_r/44100));
335 CHECK (win.pxWidth() == 1280);
336 CHECK (win.px_per_sec() <= 5*44100);
337 CHECK (win.px_per_sec() >= 5*44100 - 1);
338 CHECK (win.visible().duration() ==
Duration{1280_r/(5*44100) +MICRO_TICK});
339 CHECK (win.visible().duration() ==
Duration{1280_r/win.px_per_sec()});
340 CHECK (win.overallSpan().duration() == _t(2048));
349 CHECK (win.visible() == win.overallSpan());
350 CHECK (win.px_per_sec() == 20);
352 win.setVisibleDuration (
Duration{FSecs(23,30)});
353 CHECK (win.visible().duration() == _t(23,30));
354 CHECK (win.visible().start() == _t(64,2) - _t(23,30*2));
355 CHECK (win.px_per_sec() == 1280_r/
_FSecs(_t(23,30)));
356 CHECK (win.pxWidth() == 1280);
358 win.setVisibleRange (
TimeSpan{_t(12), FSecs(16)});
359 CHECK (win.visible() ==
TimeSpan(_t(12), _t(12+16)));
360 CHECK (win.overallSpan() ==
TimeSpan(_t(0), _t(64)));
361 CHECK (win.px_per_sec() == 1280_r/16);
362 CHECK (win.pxWidth() == 1280);
364 win.setVisiblePos(_t(12));
365 CHECK (win.visible().start() < _t(12));
366 CHECK (win.visible().duration() == _t(16));
367 CHECK (win.overallSpan() ==
TimeSpan(_t(0), _t(64)));
368 CHECK (win.px_per_sec() == 1280_r/16);
369 CHECK (win.pxWidth() == 1280);
371 win.setVisiblePos(0.80);
372 CHECK (win.visible().start() <
Time{FSecs(64)*8/10});
373 CHECK (win.visible().end() >
Time{FSecs(64)*8/10});
374 CHECK (win.px_per_sec() == 1280_r/16);
375 CHECK (win.pxWidth() == 1280);
378 win.setOverallDuration (
Duration{FSecs(3600)});
379 CHECK (win.overallSpan() ==
TimeSpan(_t(0), _t(3600)));
380 CHECK (win.px_per_sec() == 1280_r/16);
381 CHECK (win.pxWidth() == 1280);
382 CHECK (win.visible().duration() == _t(16));
383 CHECK (win.visible().start() <
Time{FSecs(64)*8/10});
384 CHECK (win.visible().end() >
Time{FSecs(64)*8/10});
387 win.setOverallRange (
TimeSpan{_t(-64), _t(-32)});
388 CHECK (win.overallSpan() ==
TimeSpan(_t(-64), FSecs(32)));
389 CHECK (win.px_per_sec() == 1280_r/16);
390 CHECK (win.pxWidth() == 1280);
391 CHECK (win.visible() ==
TimeSpan(_t(-32-16), FSecs(16)));
393 win.setOverallStart (_t(100));
394 CHECK (win.overallSpan() ==
TimeSpan(_t(100), FSecs(32)));
395 CHECK (win.visible() ==
TimeSpan(_t(100), FSecs(16)));
396 CHECK (win.px_per_sec() == 1280_r/16);
398 win.setOverallRange (
TimeSpan{_t(50), _t(52)});
399 CHECK (win.overallSpan() ==
TimeSpan(_t(50), FSecs(2)));
400 CHECK (win.visible() ==
TimeSpan(_t(50), FSecs(2)));
401 CHECK (win.px_per_sec() == 1280_r/2);
402 CHECK (win.pxWidth() == 1280);
411 CHECK (win.visible() == win.overallSpan());
412 CHECK (win.visible() ==
TimeSpan(_t(0), FSecs(16)));
413 CHECK (win.px_per_sec() == 80);
415 win.nudgeVisiblePos(+1);
416 CHECK (win.visible() ==
TimeSpan(_t(8), FSecs(16)));
417 CHECK (win.overallSpan() ==
TimeSpan(_t(0), FSecs(16+8)));
418 CHECK (win.px_per_sec() == 80);
419 CHECK (win.pxWidth() == 1280);
421 win.nudgeVisiblePos(-3);
422 CHECK (win.visible() ==
TimeSpan(_t(-16), FSecs(16)));
423 CHECK (win.overallSpan() ==
TimeSpan(_t(-16), FSecs(16+8+16)));
424 CHECK (win.px_per_sec() == 80);
425 CHECK (win.pxWidth() == 1280);
427 win.setVisiblePos(0.50);
428 CHECK (win.visible() ==
TimeSpan(_t((40/2-16) -8), FSecs(16)));
429 CHECK (win.visible().start() == _t(-4));
431 win.setVisiblePos(-0.50);
432 CHECK (win.visible() ==
TimeSpan(_t(-16-40/2), FSecs(16)));
433 CHECK (win.visible().start() == _t(-36));
434 win.setVisiblePos(_t(200));
435 CHECK (win.visible() ==
TimeSpan(_t(200-16), FSecs(16)));
436 CHECK (win.px_per_sec() == 80);
437 CHECK (win.pxWidth() == 1280);
439 win.setVisibleRange(
TimeSpan{_t(-200), FSecs(32)});
440 CHECK (win.overallSpan() ==
TimeSpan(_t(-200), _t(200)));
441 CHECK (win.visible() ==
TimeSpan(_t(-200), FSecs(32)));
442 CHECK (win.px_per_sec() == 40);
443 CHECK (win.pxWidth() == 1280);
452 CHECK (win.overallSpan() ==
TimeSpan(_t(0), _t(4)));
453 CHECK (win.visible() ==
TimeSpan(_t(0), _t(4)));
454 CHECK (win.px_per_sec() == 25);
455 CHECK (win.pxWidth() == 100);
457 bool notified{
false};
459 CHECK (not notified);
460 CHECK (win.px_per_sec() == 50);
461 CHECK (win.visible().duration() == _t(2));
463 win.attachChangeNotification([&](){ notified =
true; });
464 CHECK (not notified);
465 CHECK (win.px_per_sec() == 50);
467 CHECK (win.px_per_sec() == 100);
471 CHECK (win.visible().start() == _t(3,2));
472 win.nudgeVisiblePos(+1);
473 CHECK (win.visible().start() == _t(2));
477 CHECK (win.overallSpan() ==
TimeSpan(_t(0), _t(4)));
478 win.setOverallRange(
TimeSpan(_t(-4), _t(4)));
479 CHECK (win.overallSpan() ==
TimeSpan(_t(-4), _t(4)));
483 CHECK (win.pxWidth() == 100);
484 win.calibrateExtension(200);
485 CHECK (win.pxWidth() == 200);
486 CHECK (win.px_per_sec() == 100);
490 bool otherTriger{
false};
492 wuz.attachChangeNotification([&](){ otherTriger =
true; });
493 CHECK (wuz.visible().start() == _t(0));
494 CHECK (not notified);
495 CHECK (not otherTriger);
496 wuz.nudgeVisiblePos(-1);
497 CHECK (not notified);
499 CHECK (wuz.visible().start() == _t(-1,2));
502 CHECK (not notified);
504 CHECK (not otherTriger);
506 CHECK (win.px_per_sec() == 200);
507 CHECK (wuz.px_per_sec() == 10);
511 win.detachChangeNotification();
513 CHECK (not notified);
514 CHECK (win.px_per_sec() == 400);
517 CHECK (not notified);
519 CHECK (win.px_per_sec() == 400);
520 CHECK (wuz.px_per_sec() == 20);
529 CHECK (win.visible() ==
TimeSpan(_t(0), _t(23)));
530 CHECK (win.px_per_sec() == 25);
531 CHECK (win.pxWidth() == 575);
533 win.setOverallDuration(
Duration{FSecs(50)});
534 win.setVisibleDuration(
Duration{FSecs(0)});
535 CHECK (win.overallSpan() ==
TimeSpan(_t(0), _t(50)));
536 CHECK (win.visible() ==
TimeSpan(_t(0), _t(23)));
537 CHECK (win.pxWidth() == 575);
539 win.calibrateExtension(0);
540 CHECK (win.px_per_sec() == 25);
541 CHECK (win.pxWidth() == 1);
542 CHECK (win.visible().duration() == _t(1,25));
552 win.setOverallRange(
TimeSpan(_t(10), _t(0)));
553 CHECK (win.overallSpan() ==
TimeSpan(_t(0), _t(10)));
554 CHECK (win.visible().duration() ==
Time(40,0));
555 CHECK (win.px_per_sec() == 25);
556 CHECK (win.pxWidth() == 1);
576 CHECK (poison == 206435633551724850_r/307445734561825883);
577 CHECK (2_r/3 < poison and poison < 1);
580 CHECK (-6 == rational_cast<gavl_time_t>(poison *
Time::SCALE));
581 CHECK (671453 == _raw(
Time(FSecs(poison))));
582 CHECK (671453.812f == rational_cast<float>(poison)*Time::SCALE);
586 CHECK (57 == ilog2 (poison.numerator()));
587 CHECK (58 == ilog2 (poison.denominator()));
590 int toxicity = toxicDegree (poison);
591 CHECK (toxicity == 18);
592 int64_t quant = poison.denominator() >> toxicity;
593 CHECK (quant == 1172812402961);
595 Rat detoxed = util::reQuant(poison, quant);
596 CHECK (detoxed == 787489446837_r/1172812402961);
597 CHECK (0.671453834f == rational_cast<float> (poison));
598 CHECK (0.671453834f == rational_cast<float> (detoxed));
600 CHECK (detoxed+Time::SCALE == 1172813190450446837_r/1172812402961);
601 CHECK (
Time(FSecs(detoxed)) > Time::ZERO);
602 CHECK (671453 == _raw(
Time(FSecs(detoxed))));
604 CHECK (1906 == _raw(
TimeValue(1280 / rational_cast<long double>(poison))));
605 CHECK (1906 == _raw(
TimeValue(1280 / rational_cast<long double>(detoxed))));
619 CHECK (win.visible() == win.overallSpan());
620 CHECK (win.visible().duration() == _t(23));
621 CHECK (win.px_per_sec() == 25);
622 CHECK (win.pxWidth() == 575);
625 CHECK (0 < poison and poison < 1);
628 win.setMetric (poison);
629 CHECK (win.visible() == win.overallSpan());
630 CHECK (win.visible().duration() == _t(23));
631 CHECK (win.visible() ==
TimeSpan(_t(0), _t(23)));
632 CHECK (win.px_per_sec() == 25);
633 CHECK (win.pxWidth() == 575);
636 CHECK (win.overallSpan().duration() ==
TimeValue{307445734561825860});
637 CHECK (win.overallSpan().duration() ==
Time::MAX);
638 CHECK (win.visible().duration() == _t(23));
641 win.setMetric (poison);
642 CHECK (win.overallSpan().duration() ==
Time::MAX);
643 CHECK (win.visible().duration() ==
TimeValue{856350691});
644 CHECK (win.px_per_sec() == Rat{win.pxWidth()} /
_FSecs(win.visible().duration()));
645 float approxPoison = rational_cast<
float> (poison);
646 CHECK (approxPoison == 0.671453834f);
647 float approxNewMetric = rational_cast<
float> (win.px_per_sec());
648 CHECK (approxNewMetric == 0.671453893f);
649 CHECK (win.px_per_sec() != poison);
650 CHECK (win.px_per_sec() < poison);
652 Rat poisonousDuration = win.pxWidth() / poison;
653 CHECK (poisonousDuration == 7071251894921995309_r/8257425342068994);
655 CHECK(856.350708f == rational_cast<float> (poisonousDuration));
656 CHECK(856.350708f == rational_cast<float> (
_FSecs(win.visible().duration())));
657 CHECK (win.px_per_sec() == 575000000_r/856350691);
658 CHECK (win.pxWidth() == 575);
660 CHECK (win.overallSpan().start() == Time::ZERO);
661 CHECK (win.overallSpan().duration() ==
TimeValue{307445734561825860});
662 CHECK (win.visible().duration() ==
TimeValue{856350691});
665 win.setVisiblePos (poison);
666 CHECK (win.overallSpan().start() == Time::ZERO);
667 CHECK (win.overallSpan().duration() ==
TimeValue{307445734561825860});
668 CHECK (win.visible().duration() ==
TimeValue{856350691});
670 TimeValue targetPos{gavl_time_t(_raw(win.overallSpan().duration())
671 * rational_cast<double> (poison))};
673 CHECK (targetPos ==
TimeValue{206435633551724864});
674 CHECK (win.visible().start() ==
TimeValue{206435633106265625});
675 CHECK (win.visible().end() ==
TimeValue{206435633962616316});
676 CHECK (win.visible().start() < targetPos);
677 CHECK (win.visible().end() > targetPos);
679 CHECK (win.px_per_sec() == 575000000_r/856350691);
680 CHECK (win.pxWidth() == 575);
684 CHECK (win.overallSpan() == win.visible());
685 CHECK (win.overallSpan().start() ==
TimeValue{307445734561825572});
686 CHECK (win.overallSpan().end() ==
TimeValue{307445734561825860});
687 CHECK (win.overallSpan().duration() ==
TimeValue{288});
688 CHECK (win.px_per_sec() == 17968750_r/9);
689 CHECK (win.pxWidth() == 575);
693 CHECK (win.visible().start() == Time::MIN +
TimeValue(13));
694 CHECK (win.visible().end() == win.visible().start() +
TimeValue{288});
695 CHECK (win.visible().duration() ==
TimeValue{288});
697 CHECK (win.overallSpan().start() == win.visible().start());
698 CHECK (win.overallSpan().end() ==
TimeValue{307445734561825860});
699 CHECK (_raw(win.overallSpan().duration()) == 614891469123651707);
700 CHECK (win.px_per_sec() == 17968750_r/9);
701 CHECK (win.pxWidth() == 575);
713 CHECK (win.overallSpan().duration() == _t(1));
714 CHECK (win.px_per_sec() == 3_r/1);
715 CHECK (win.pxWidth() == 3);
717 CHECK (_raw(win.overallSpan().duration()) == 614891469123651720);
718 CHECK (_raw(win.visible().duration()) == 1000000);
719 CHECK (win.px_per_sec() == 3_r/1);
720 CHECK (win.pxWidth() == 3);
723 Rat bruteZoom{3_r/(int64_t{1}<<60)};
724 win.setMetric (bruteZoom);
726 CHECK (_raw(win.overallSpan().duration()) == 614891469123651720);
727 CHECK (_raw(win.visible().duration()) == 3298534883328000);
728 CHECK (_raw(win.visible().duration()) < int64_t{1}<<60 );
729 CHECK (_raw(win.visible().duration()) == 3*
LIM_HAZARD*1000);
731 CHECK (win.visible().start() == - win.visible().end());
732 CHECK (win.px_per_sec() > bruteZoom);
733 CHECK (win.px_per_sec() == 125_r/137438953472);
734 CHECK (win.px_per_sec() == 1000_r/
LIM_HAZARD);
735 CHECK (win.px_per_sec() == 3 /
_FSecs(win.visible().duration()));
736 CHECK (win.pxWidth() == 3);
739 win.setMetric (5_r/std::numeric_limits<int64_t>::max());
740 CHECK (_raw(win.visible().duration()) == 3298534883328000);
741 CHECK (win.px_per_sec() == 125_r/137438953472);
742 CHECK (win.pxWidth() == 3);
746 CHECK (_raw(win.visible().duration()) == 3295239643684316);
747 CHECK (_raw(win.visible().duration()) < 3 *
LIM_HAZARD*1000);
749 CHECK (win.px_per_sec() == 1001_r/
LIM_HAZARD);
750 CHECK (win.px_per_sec() == 1001_r/1099511627776);
751 CHECK (win.pxWidth() == 3);
754 win.setMetric (1000_r/
LIM_HAZARD * 1024_r/1023);
755 CHECK (_raw(win.visible().duration()) == 3295313657856000);
756 CHECK (_raw(win.visible().duration()) < 3 *
LIM_HAZARD*1000);
759 CHECK (win.px_per_sec() == 1000_r/
LIM_HAZARD * 1024_r/1023);
760 CHECK (win.px_per_sec() == 125_r/137304735744);
761 CHECK (win.pxWidth() == 3);
767 CHECK (1001_r/(
LIM_HAZARD-3) == 77_r/84577817521);
769 CHECK (3_r/3295239643675325 *
Time::SCALE == 120000_r/131809585747013);
770 CHECK (win.px_per_sec() == 2003_r/2199023255552);
771 CHECK (win.pxWidth() == 3);
773 CHECK (_raw(
Duration{3_r/(77_r/84577817521)}) == 3295239643675324);
774 CHECK (_raw(win.visible().duration()) == 3295239643675325);
775 CHECK (_raw(
Duration{3_r/win.px_per_sec()}) == 3293594491590614);
777 CHECK (2003.0f/2002 - 1 == 0.000499486923f);
781 win.calibrateExtension (1
'000'000
'000); // implicit drastic zoom-out by increasing the number of pixels 782 CHECK (win.pxWidth() < 1'000
'000'000);
783 CHECK (win.pxWidth() == MAX_PX_WIDTH);
784 CHECK (win.px_per_sec() == 89407_r/549755813888);
785 CHECK (win.px_per_sec() > Rat{MAX_PX_WIDTH} /MAX_TIMESPAN);
786 CHECK (win.px_per_sec() < Rat{MAX_PX_WIDTH+1}/MAX_TIMESPAN);
788 CHECK (_raw(win.overallSpan().duration()) == 614891469123651720);
789 CHECK (_raw(win.visible().duration()) == 614891469123651720);
790 CHECK (win.overallSpan().end() ==
TimeValue{ 307445734561825860});
791 CHECK (win.visible().end() ==
TimeValue{ 307445734561825860});
792 CHECK (win.visible().start() ==
TimeValue{-307445734561825860});
795 CHECK (MAX_PX_WIDTH /
_FSecs(win.visible().duration()) == 2500000000_r/15372286728091293);
796 CHECK (MAX_PX_WIDTH * 1000000_r/614891469123651720 == 2500000000_r/15372286728091293);
797 CHECK (win.px_per_sec() *
_FSecs(win.visible().duration()) < 0);
798 CHECK (rational_cast<float>(win.px_per_sec())
799 * rational_cast<float>(
_FSecs(win.visible().duration())) == 100000.031f);
800 CHECK (rational_cast<float>(MAX_PX_WIDTH*1000000_r/614891469123651720) == 1.62630329e-07f);
801 CHECK (rational_cast<float>(win.px_per_sec()) == 1.62630386e-07f);
802 CHECK (win.px_per_sec() == 89407_r/549755813888);
805 win.setMetric (bruteZoom);
806 CHECK (_raw(win.overallSpan().duration()) == 614891469123651720);
807 CHECK (_raw(win.visible().duration()) == 614891469123651720);
808 CHECK (win.px_per_sec() == 89407_r/549755813888);
809 CHECK (MAX_PX_WIDTH /(614891469123651720_r/
Time::SCALE) == 2500000000_r/15372286728091293);
810 CHECK (2500000000_r/15372286728091293 < 89407_r/549755813888);
811 CHECK (win.pxWidth() == MAX_PX_WIDTH);
823 CHECK (win.visible().duration() ==
TimeValue(280));
824 CHECK (win.visible().start() ==
TimeValue(307445734561825580));
825 CHECK (win.visible().end() ==
TimeValue(307445734561825860));
826 CHECK (win.visible().end() ==
Time::MAX);
827 CHECK (win.visible() == win.overallSpan());
829 CHECK (win.px_per_sec() == 13975000_r/7);
830 CHECK (win.pxWidth() == 559);
834 win.setVisiblePos (anchorPos);
835 CHECK (win.visible().duration() ==
TimeValue(280));
836 CHECK (win.px_per_sec() == 13975000_r/7);
837 CHECK (win.pxWidth() == 559);
838 CHECK (win.visible().start() > Time::MIN);
839 CHECK (win.visible().start() == anchorPos);
840 CHECK (win.visible().end() > anchorPos);
841 CHECK (win.visible().start() ==
TimeValue(-288230376151711744));
842 CHECK (win.visible().end() ==
TimeValue(-288230376151711464));
843 CHECK (win.overallSpan().start() == win.visible().start());
844 CHECK (win.overallSpan().end() ==
Time::MAX);
847 win.calibrateExtension (560);
848 CHECK (win.visible().duration() ==
TimeValue(280));
849 CHECK (win.px_per_sec() == 2000000_r/1);
853 win.setVisibleDuration(targetDur);
855 CHECK (win.visible().duration() == targetDur);
857 CHECK (win.visible().start() == Time::MIN);
858 CHECK (win.visible().start() <
Time::MAX);
859 CHECK (win.visible().end() ==
TimeValue(307445734538825860));
861 CHECK (win.px_per_sec() == 2003_r/2199023255552);
862 CHECK (win.pxWidth() == 560);
865 win.setVisiblePos (Rat{std::numeric_limits<int64_t>::max()-23});
866 CHECK (win.visible().duration() == targetDur);
867 CHECK (win.px_per_sec() == 2003_r/2199023255552);
868 CHECK (win.pxWidth() == 560);
869 CHECK (win.visible().end() ==
Time::MAX);
870 CHECK (win.visible().start() > Time::MIN);
871 CHECK (win.visible().start() ==
TimeValue(-307445734538825860));
874 win.calibrateExtension (561);
875 CHECK (win.visible().duration() > targetDur);
877 CHECK (win.visible().end() ==
Time::MAX);
878 CHECK (win.visible().start() == Time::MIN);
879 CHECK (win.px_per_sec() == 2007_r/2199023255552);
880 CHECK (win.pxWidth() == 561);
884 CHECK (win.visible().end() ==
Time::MAX);
885 CHECK (win.visible().start() == Time::MIN +
TimeValue(1));
886 CHECK (win.px_per_sec() == 2007_r/2199023255552);
887 CHECK (win.pxWidth() == 561);
890 CHECK (win.visible().duration() ==
TimeValue(281));
892 CHECK (win.px_per_sec() == 561000000_r/281);
893 CHECK (win.visible().end() ==
Time::MAX);
894 CHECK (win.pxWidth() == 561);
905 CHECK (win.visible().duration() ==
TimeValue(1));
907 win.nudgeVisiblePos (-2);
911 CHECK (win.visible().end() ==
Time::MAX);
913 CHECK (win.visible().duration() ==
TimeValue(1));
914 CHECK (win.overallSpan().duration() ==
TimeValue(2));
915 CHECK (win.px_per_sec() == 1000000);
916 CHECK (win.pxWidth() == 1);
918 win.nudgeVisiblePos (std::numeric_limits<int64_t>::min());
920 CHECK (win.visible().duration() ==
TimeValue(1));
921 CHECK (win.visible().start() == Time::MIN);
922 CHECK (win.visible().end() == Time::MIN +
TimeValue(1));
923 CHECK (win.px_per_sec() == 1000000);
924 CHECK (win.pxWidth() == 1);
926 win.calibrateExtension (460);
929 CHECK (win.visible().start() == Time::MIN);
930 CHECK (win.visible().end() ==
TimeValue(-1));
932 win.nudgeVisiblePos (+2);
934 CHECK (win.visible().start() ==
TimeValue(-1));
935 win.nudgeVisiblePos (-1);
936 CHECK (win.visible().start() ==
TimeValue(-153722867280912930));
937 CHECK (win.visible().end() ==
TimeValue(+153722867280912929));
939 win.nudgeVisiblePos (+1000);
940 CHECK (ilogb(500.0 * _raw(
Time::MAX)) == 67);
941 CHECK (win.visible().start() ==
TimeValue(+1));
942 CHECK (win.visible().end() ==
Time::MAX);
943 CHECK (win.pxWidth() == 460);
954 CHECK (win.overallSpan().end() ==
Time::MAX);
955 CHECK (win.visible().duration() ==
LIM_HAZARD * 1000);
956 CHECK (win.visible().start()+win.visible().end() == Time::ZERO);
958 CHECK (win.px_per_sec() == 125_r/137438953472);
959 CHECK (win.pxWidth() == 1);
961 win.nudgeVisiblePos (+1);
962 CHECK (win.visible().start() == Time::ZERO);
963 CHECK (win.visible().end() ==
LIM_HAZARD*1000);
964 CHECK (win.px_per_sec() == 125_r/137438953472);
965 CHECK (win.pxWidth() == 1);
967 win.nudgeMetric (-1);
968 CHECK (win.px_per_sec() == 125_r/137438953472);
969 win.nudgeMetric (+1);
970 CHECK (win.px_per_sec() == 125_r/68719476736);
971 CHECK (win.visible().start() ==
TimeValue(274877908523000));
972 CHECK (win.visible().end() ==
TimeValue(824633722411000));
973 CHECK (win.visible().duration() ==
LIM_HAZARD * 1000 / 2);
974 CHECK (win.pxWidth() == 1);
977 CHECK (win.visible().end() ==
Time::MAX);
978 CHECK (win.visible().duration() ==
LIM_HAZARD * 1000 / 2);
980 CHECK (win.pxWidth() == 1);
984 CHECK (win.visible().end() ==
Time::MAX);
986 CHECK (win.visible().duration() ==
TimeValue(1098413214561438));
988 CHECK (win.px_per_sec() == 2003_r/2199023255552);
989 CHECK (win.pxWidth() == 1);
1001 CHECK (win.overallSpan().duration() == win.visible().duration());
1002 CHECK (win.visible().duration() ==
TimeValue(1));
1003 CHECK (win.visible().start() == Time::MIN);
1004 CHECK (win.visible().end() == Time::MIN +
TimeValue(1));
1006 CHECK (win.px_per_sec() == 1000000);
1007 CHECK (win.pxWidth() == 1);
1009 win.setOverallDuration (
Duration{FSecs(1)});
1010 win.calibrateExtension (2);
1011 CHECK (win.visible().duration() ==
TimeValue(2));
1012 CHECK (win.px_per_sec() == 1000000);
1016 CHECK (win.px_per_sec() == 2000000);
1017 CHECK (win.visible().start() == Time::MIN);
1018 CHECK (win.visible().end() == Time::MIN +
TimeValue(1));
1019 CHECK (win.pxWidth() == 2);
1021 win.nudgeVisiblePos (+1);
1022 CHECK (win.visible().start() == Time::MIN +
TimeValue(1));
1023 CHECK (win.visible().end() == Time::MIN +
TimeValue(2));
1024 CHECK (win.visible().duration() ==
TimeValue(1));
1027 win.calibrateExtension (3);
1028 CHECK (win.visible().duration() ==
TimeValue(2));
1030 CHECK (win.visible().start() == Time::MIN +
TimeValue(1));
1031 CHECK (win.visible().end() == Time::MIN +
TimeValue(3));
1032 CHECK (win.pxWidth() == 3);
1035 CHECK (win.px_per_sec() == 3000000_r/17);
1037 CHECK (win.px_per_sec() == 187500);
1039 CHECK (win.px_per_sec() == 200000);
1040 CHECK (win.visible().start() == Time::MIN +
TimeValue(1));
1041 CHECK (win.visible().end() == Time::MIN +
TimeValue(16));
1043 win.nudgeMetric (-1);
1044 CHECK (win.px_per_sec() == 100000);
1045 CHECK (win.visible().duration() ==
TimeValue(30));
1046 win.nudgeMetric (+2);
1047 CHECK (win.px_per_sec() == 375000);
1048 CHECK (win.visible().duration() ==
TimeValue(8));
1049 win.nudgeMetric (+1);
1050 CHECK (win.px_per_sec() == 750000);
1051 CHECK (win.visible().duration() ==
TimeValue(4));
1055 CHECK (win.px_per_sec() == 1000000);
1056 CHECK (win.visible().duration() ==
TimeValue(3));
1057 CHECK (win.visible().start() == Time::MIN +
TimeValue(1));
1058 CHECK (win.visible().end() == Time::MIN +
TimeValue(4));
1060 win.nudgeVisiblePos (-5);
1061 CHECK (win.visible().start() == Time::MIN +
TimeValue(0));
1062 CHECK (win.visible().end() == Time::MIN +
TimeValue(3));
1063 CHECK (win.visible().duration() ==
TimeValue(3));
1065 win.calibrateExtension (MAX_PX_WIDTH);
1066 CHECK (win.pxWidth() == 100000);
1067 CHECK (win.visible().duration() ==
TimeValue(100000));
1069 CHECK (win.visible().start() == Time::MIN +
TimeValue(0));
1070 CHECK (win.visible().end() == Time::MIN +
TimeValue(100000));
1074 CHECK (win.visible().duration() ==
TimeValue(50000));
1075 CHECK (win.visible().end() == Time::MIN +
TimeValue(50000));
1076 CHECK (win.pxWidth() == 100000);
void safeguard_extremeOffset()
static const Duration MAX
maximum possible temporal extension
void setVisibleDuration(Duration duration)
explicitly set the duration of the visible window range, working around the relative anchor point; po...
void verify_calibration()
void setRanges(TimeSpan overall, TimeSpan visible)
Set both the overall canvas, as well as the visible part within that canvas.
const int64_t LIM_HAZARD
Maximum quantiser to be handled in fractional arithmetics without hazard.
static const gavl_time_t SCALE
Number of micro ticks (µs) per second as basic time scale.
void verify_changeNotification()
void safeguard_veryDeep()
void safeguard_verySmall()
Lumiera's internal time value datatype.
void safeguard_extremeTimePos()
A component to ensure uniform handling of zoom scale and visible interval on the timeline.
Simplistic test class runner.
void nudgeVisiblePos(int64_t steps)
scroll by increments of half window size, possibly expanding.
Lumiera GTK UI implementation root.
void nudgeMetric(int steps)
scale up or down on a 2-logarithmic scale.
A collection of frequently used helper functions to support unit testing.
FSecs _FSecs(TimeValue const &timeVal)
void safeguard_toxic_zoomFactor()
void safeguard_reversed_intervals()
void safeguard_poisonousMetric()
const Rat ZOOM_MAX_RESOLUTION
the deepest zoom is to use 2px per micro-tick
void setOverallRange(TimeSpan range)
redefine the overall canvas range.
Offset measures a distance in time.
Duration is the internal Lumiera time metric.
void verify_simpleUsage()
Abstraction: the current zoom- and navigation state of a view, possibly in multiple dimensions...
A time interval anchored at a specific point in time.
void calibrateExtension(uint pxWidth)
Define the extension of the window in pixels.
void safeguard_extremeZoomOut()
void safeguard_zero_init()
basic constant internal time value.