Commit 2fb8ab5

Richard Ziegler committed on
Fix Sample DrawWaveform with float interval and more
Mouse accuracy was dependent on window size with integer spacing,
Now smoothly scales at any width with Single float.
Paint range set to 32 so sample 0 can be seen on both sides.
Height has 2 pixel offset to see top/bottom lines.
commit 2fb8ab593c0ea9b07b6de1f48ed5891efe29d8a2 parent ed1bb9f
1 changed files +6−6
Modifiedtracker.pas +6−6
@@ -588,14 +588,14 @@ end;
588 588
589 procedure TfrmTracker.DrawWaveform(PB: TPaintBox; Wave: TWave); 589 procedure TfrmTracker.DrawWaveform(PB: TPaintBox; Wave: TWave);
590 var 590 var
591 Interval{, HInterval}: Integer; 591 Interval{, HInterval}: Single;
592 I: Integer; 592 I: Integer;
593 W, H : Integer; 593 W, H : Integer;
594 begin 594 begin
595 W := PB.Width; 595 W := PB.Width;
596 H := PB.Height; 596 H := PB.Height-4;
597 597
598 Interval := W div 31; 598 Interval := W / 32;
599 //HInterval := H div $10; 599 //HInterval := H div $10;
600 With PB.Canvas do begin 600 With PB.Canvas do begin
601 Brush.Color := clGameboyBlack; 601 Brush.Color := clGameboyBlack;
@@ -614,7 +614,7 @@ begin
614 Pen.Width := 2; 614 Pen.Width := 2;
615 MoveTo(0, H); 615 MoveTo(0, H);
616 for I := Low(Wave) to High(Wave) do 616 for I := Low(Wave) to High(Wave) do
617 LineTo(I*Interval, Trunc((Wave[I]/$F)*H)); 617 LineTo(Round(I*Interval), Trunc((Wave[I]/$F)*H)+2);
618 LineTo(W, Trunc((Wave[0]/$F)*H)); 618 LineTo(W, Trunc((Wave[0]/$F)*H));
619 end; 619 end;
620 end; 620 end;
@@ -2565,8 +2565,8 @@ begin
2565 X := EnsureRange(X, 0, WaveEditPaintBox.Width); 2565 X := EnsureRange(X, 0, WaveEditPaintBox.Width);
2566 Y := EnsureRange(Y, 0, WaveEditPaintBox.Height); 2566 Y := EnsureRange(Y, 0, WaveEditPaintBox.Height);
2567 if DrawingWave then begin 2567 if DrawingWave then begin
2568 Idx := EnsureRange(Round((X / WaveEditPaintBox.Width)*High(TWave)), Low(TWave), High(TWave)); 2568 Idx := EnsureRange(Round((X / WaveEditPaintBox.Width)*32), Low(TWave), High(TWave));
2569 CurrentWave^[Idx] := EnsureRange(Trunc((Y / WaveEditPaintBox.Height)*$F), 0, $F); 2569 CurrentWave^[Idx] := EnsureRange(Round((Y / WaveEditPaintBox.Height)*$F), 0, $F);
2570 UpdateHexWaveTextbox; 2570 UpdateHexWaveTextbox;
2571 WaveEditPaintBox.Invalidate; 2571 WaveEditPaintBox.Invalidate;
2572 if PlayWaveWhileDrawingCheckbox.Checked then 2572 if PlayWaveWhileDrawingCheckbox.Checked then