Einzelnen Beitrag anzeigen

venice2
(Gast)

n/a Beiträge
 
#22

AW: FLOAT_INVALID_OPERATION und FLOAT_OVERFLOW nur 64Bit

  Alt 19. Jul 2021, 23:24
Das var ist Richtig. (Habe auch nichts anderes erwartet)
habe es aber geändert das man es auch ohne Glättung verwenden kann.
Siehe Smooth the Wave Data"

Delphi-Quellcode:
procedure TBassPlayer.DrawData(PaintDC: HDC);
var
  k: integer;
  TRA: array[1..256] of single;
  TIA: array[1..256] of single;
begin

  if gBin.SmoothWaveData = 1 then
  begin
    for k := 0 to 255 do
      TRA[k + 1] := WaveData[k];

    Fillchar(TIA, SizeOf(TIA), #0);
    XFFT(TRA, TIA, -1, 1, 255);
  end
  else
    for k := 0 to 255 do
      TRA[k + 1] := WaveData[k] / 1.50;

  // Render alle Bilder in den temporären Buffer TempBufferDC
  for k := 1 to 256 do
  begin
    if TRA[k] < 0 then
      TRA[k] := 0;

    BitBlt(TempBufferDC, k - 1, trunc(Abs(FHeight - TRA[k])), 1, FHeight,
      PicFlame[FCurentFlame].Canvas.Handle, 0, 0, SRCCOPY);
  end;

  FadeBackBuffer(TempBufferDC);

  BitBlt(PaintDC, 0, 0, FWidth, FHeight, TempBufferDC, 0, 0, SRCCOPY);
end;
Delphi-Quellcode:
procedure TBassPlayer.XFFT(var FR, FI: array of single; Sign, Sample, SampleCount: Integer);
// Wave Daten glätten
var
  Q, J, M, L, le, le1, ip: integer;
  tr, ti, s, ur, ur1, ui, wr, wi: single;

begin

    J := 1;
    for Q := Sample to (SampleCount - 1) do
    begin
      if Q < J then
      begin
        s := FR[Q];
        FR[Q] := FR[J];
        FR[J] := s;
        s := FI[Q];
        FI[Q] := FI[J];
        FI[J] := s;
      end;

      M := ((SampleCount) div 2);
      while M < J do
      begin
        J := J - M;
        M := M div 2;
        if M = 0 then
          break;
      end;
      J := J + M;
    end;

    for L := 1 to 8 do
    begin
      le := trunc(Power(2, L));
      le1 := le div 2;
      ur := 1;
      ui := 0;
      wr := Cos(PI / le1);
      wi := Sign * Sin(PI / le1);


      for J := 1 to le1 do
      begin
        Q := J;
        while Q < (SampleCount) do
        begin
          ip := Q + (le1 - 1);
          tr := FR[ip] * ur - FI[ip] * ui;
          ti := FR[ip] * ui + FI[ip] * ur;
          FR[ip] := FR[Q] - tr;
          FI[ip] := FI[Q] - ti;
          FR[Q] := FR[Q] + tr;
          FI[Q] := FI[Q] + ti;
          Q := Q + le;
        end;

        ur1 := ur * wr - ui * wi;
        ui := ur * wi + ui * wr;
        ur := ur1;
      end;

    end;

    for Q := Sample to (SampleCount) do
    begin
      FR[Q] := FR[Q] * DivN;
      FI[Q] := FI[Q] * DivN;
    end;
end;

Geändert von venice2 (21. Jul 2021 um 21:15 Uhr)
  Mit Zitat antworten Zitat