[Linux] Convertir un projet Delphi7 en Lazarus et des Single en Float (ou l'inverse)
Bonjour,
Dans un projet D7 je trouve, dans Unit1,
Code:
1 2 3 4 5
| var
Form1: TForm1;
FFT : array[1..1024] of float; // Initial array that FFT Data will go into
Scaled_FFT : array[0..15] of float; // The sorted and scaled data
Bin_Dist : array[0..16] of integer; // My way of sorting data |
et plus loin
Code:
1 2 3 4 5 6
| for x := 0 to 15 do
begin
tot_sum := 0;
for y := Bin_Dist[x] to Bin_Dist[x+1] do tot_sum := tot_sum + (FFT[y]);
Scaled_FFT[x] := tot_sum * 50; // Just get the numbers a little larger to work with
end; |
donc ici on est en Float.
Dans une unité complémentaire
Code:
1 2 3 4 5 6 7 8
| Procedure TSpectrum.Draw_Spec(HWND : THandle; FFTData : array of single);
var
i : Integer;
begin
Img_Hand := HWND;
for i := 0 to No_Peaks - 1 do Spec_Data[i] := FFTData[i];
Draw_It;
end; |
Ici on est en Single et D7 ne dit rien à la compilation, et l'exécution est parfaite.
Lazarus, lui, n'est pas content du tout lors de l'appel de cette procédure :
Code:
1 2 3 4 5
| procedure TForm1.Timer1Timer(Sender: TObject);
begin
GetData; // My proc to get and sort the data
My_Spectrum.Draw_Spec(paintbox1.Canvas.Handle, Scaled_FFT);
end; |
Avec le curseur au bout de Scaled_FFT je gagne
Citation:
Error: Incompatible type for arg no. 2: Got "Array[0..15] Of Extended", expected "Open Array Of Single"
Si je remplace array of single par array of float dans les déclarations, ça compile, mais les données sont tellement en vrac que c'est inutilisable
Et pareil si j'inverse :
Code:
1 2
| // Scaled_FFT : array[0..15] of float; // The sorted and scaled data
Scaled_FFT : array[0..15] of single; // The sorted and scaled data |
J'ai remis en place {$MODE Delphi} mais ça ne change pas la donne.
Comment faire ?
Merci,
Ah, pour les curieux, tout ça se trouve dans le projet audio BigJim_Spectrum (Dieu sait où je l'ai trouvé, et il y a looooooongtemps…)