AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Konvertierungs problem C nach Delphi

Ein Thema von EWeiss · begonnen am 14. Mär 2007 · letzter Beitrag vom 14. Mär 2007
Antwort Antwort
EWeiss
(Gast)

n/a Beiträge
 
#1

Konvertierungs problem C nach Delphi

  Alt 14. Mär 2007, 21:30
habe ein kleines konvertierungs problem von c nach Delphi


Code:
h+=specdata[i*8+j+c*576];
h ist single original(float)
habe es so übersetzt!
h+ This_Mod^.Spectrumdata[i * 8 + j + c * 576]; Fehler.
[Pascal Error] VisCDRom.pas(423): E2008 Incompatible types


Code:
h/=(1.0f*255.0f);
habe es so übersetzt!
h/ (1.0 * 255.0); Fehler.
[Pascal Error] VisCDRom.pas(424): E2014 Statement expected, but expression of type 'Extended' found

Habe gelesen das 'h/' auch in Delphi verwendet wird genauso wie 'h+'
Zitat:
/ (slash) Similar. Object Pascal always returns a floating point result.
+ (plus) OK. Also used for string concatenation and set union.
ob das nun im zusammenhang mit h/ und h+ steht .. keine ahnung.

Scheint aber nicht zusammen zu passen.

gruss Emil
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#2

Re: Konvertierungs problem C nach Delphi

  Alt 14. Mär 2007, 22:07
Ja

Habs jetzt mal so gemacht und denke das ist richtig!
Delphi-Quellcode:
h := h + This_Mod^.Spectrumdata[i * 8 + j + c * 576];
h := h / (1.0 * 255.0);
Allerdings bekomme ich immer noch ein Problem wegen h = single und This_Mod^.Spectrumdata[i * 8 + j + c * 576]; Array

gruss Emil
  Mit Zitat antworten Zitat
Benutzerbild von DGL-luke
DGL-luke

Registriert seit: 1. Apr 2005
Ort: Bad Tölz
4.149 Beiträge
 
Delphi 2006 Professional
 
#3

Re: Konvertierungs problem C nach Delphi

  Alt 14. Mär 2007, 22:09
öhm... versuchs mal ohen dereferenzierung, delphi macht das implizit. und dann zeig mal deine definition von TMod oder was auch immer für ein strcut das ist wo du zugreifst. sind die indices, die du da benutzt, alle ganzzahlig?
Lukas Erlacher
Suche Grafiktablett. Spenden/Gebrauchtangebote willkommen.
Gotteskrieger gesucht!
For it is the chief characteristic of the religion of science that it works. - Isaac Asimov, Foundation I, Buch 1
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.166 Beiträge
 
Delphi 12 Athens
 
#4

Re: Konvertierungs problem C nach Delphi

  Alt 14. Mär 2007, 22:22
Code:
h := h + specdata[i * 8 + j + c * 576];
// oder
[s]inc(h, specdata[i * 8 + j + c * 576]);[/s]

h := h / 255.0; // *grübel*
// oder
h := h / 255;
wie ist specdata/Spectrumdata definiert?
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#5

Re: Konvertierungs problem C nach Delphi

  Alt 14. Mär 2007, 22:27
Zitat von DGL-luke:
öhm... versuchs mal ohen dereferenzierung, delphi macht das implizit. und dann zeig mal deine definition von TMod oder was auch immer für ein strcut das ist wo du zugreifst. sind die indices, die du da benutzt, alle ganzzahlig?
Weiss nicht was du mit dereferenzierung meinst aber das ist mal die Type
Delphi-Quellcode:
  TWinAMPVisModule = record
    Description : PChar;
    hWNDParent : HWND;
    hDLLInstance : HINST;
    sRate : Integer;
    nCh : Integer;
    LatencyMs : Integer;

    DelayMs : Integer;
    SpectrumNch : Integer;
    WaveformNch : Integer;

    SpectrumData : array[0..1,0..575] of byte;
    WaveformData : array[0..1,0..575] of byte;
    Config : procedure(This_Mod: PWinAMPVisModule); cdecl;
    Init : function(This_Mod: PWinAMPVisModule): Integer; cdecl;
    Render : function(This_Mod: PWinAMPVisModule): Integer; cdecl;
    Quit : procedure(This_Mod: PWinAMPVisModule); cdecl;
    UserData : Pointer;
  end;
meinst du das h := h + mit dereferenzierung ?

hier ist die ganze schleife.
Delphi-Quellcode:
   // Spektrum Analyser Daten glaetten
   for c := 0 to 1 do
   begin
      for i := 0 to 72 do
      begin
         h := 0.0;
         for j := 0 to 8 do
        h := h + This_Mod^.Spectrumdata[i * 8 + j + c * 576];
           h := h / (1.0 * 255.0);

         h := Ln(h + 1.0)* 10.0;

         delta :=(ElapsedTime-LastTime)* 10.0;
         delta2 :=(ElapsedTime-LastTime)* 2.0;
         if (h > heights[c][i] - delta) then
        h:= heights[c][i]
      else
        heights[c][i] := heights[c][i] - delta;

         if (h > heights2[c][i] - delta2) then
      begin
        h := heights2[c][i]
      end else heights2[c][i] := heights2[c][i]-delta2;
      end;
   end;
Edit:
Die Var's

Delphi-Quellcode:
Var
  i,j,c : integer;
  h,delta,delta2 : single;
  x1,x2,z1,z2,y : GLfloat;
  d1 : GLfloat;
  d2 : GLfloat;
  overdraw : GLfloat;
  h2,h3,d12d : GLfloat;
  hd : GLfloat;
gruss Emil
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#6

Re: Konvertierungs problem C nach Delphi

  Alt 14. Mär 2007, 22:43
Zitat von himitsu:
Code:
h := h + specdata[i * 8 + j + c * 576];
// oder
[s]inc(h, specdata[i * 8 + j + c * 576]);[/s]

h := h / 255.0; // *grübel*
// oder
h := h / 255;
wie ist specdata/Spectrumdata definiert?
nee das ist openGl da ist 1.0 nicht das letzte
da gibt es noch 0.9, 0.8 usw ..

eigenlich geht es mir nur darum single mit dem Array kompatibel zu machen (konvertieren)
das will er irgendwie nicht.

Zitat:
[Pascal Error] VisCDRom.pas(423): E2008 Incompatible types
wenn ich die dereferenzierung entferne kommt!
Zitat:
[Pascal Error] VisCDRom.pas(423): E2010 Incompatible types: 'Single' and 'Array'
gruss Emil
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.166 Beiträge
 
Delphi 12 Athens
 
#7

Re: Konvertierungs problem C nach Delphi

  Alt 14. Mär 2007, 23:09
Aber mal ganz ehrlich, Spectrumdata und specdata sind nicht gleich definiert.

Code:
specdata =    array[0..irgendwas] of MirUnbekannt
[color=#0000ff]und [/color]
Spectrumdata = array[[color=#ff0000]0..1[/color], 0..575] of byte;
fällt dir was auf?
da ist ein Wert zuviel.



Code:
h+=specdata[i*8+j+c*576];
h/=(1.0f*255.0f);
steht das direkt hintereinander?

weil dann müßte es doch so auch gehn?
Code:
h := (h + This_Mod^.Spectrumdata[i * 8 + j + c * 576]) / (1.0 * 255);
                 [color=#ff0000] ^ die dereverenzierung ist dieses[/color]

[color=#0000ff]// ohne wäre es dann so:[/color]
h := (h + This_Mod.Spectrumdata[i * 8 + j + c * 576]) / (1.0 * 255);


also dann sozusagen so?
Delphi-Quellcode:
h := (h + This_Mod^.Spectrumdata[i * 8 + j + c * 576]) / (1.0 * 255.0);
h := (h + This_Mod^.Spectrumdata[i * 8 + j + c * 576]) / (0.9 * 255.0);
...
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#8

Re: Konvertierungs problem C nach Delphi

  Alt 14. Mär 2007, 23:18
Zitat von himitsu:
Aber mal ganz ehrlich, Spectrumdata und specdata sind nicht gleich definiert.

Code:
specdata =    array[0..irgendwas] of MirUnbekannt
[color=#0000ff]und [/color]
Spectrumdata = array[[color=#ff0000]0..1[/color], 0..575] of byte;
fällt dir was auf?
da ist ein Wert zuviel.
ja jetzt wo du es sagst
Nein im ernst habe da nicht nach gesehen soweit war ich noch nicht.
Da bedingt durch die übersetzung sich das projekt erst gar nicht kompilieren ließ.

Spätestens danach wäre es mir aufgefallen mit einer neuen Fehlermeldung
welche nicht ausgebleieben wäre ..

trotzdem danke für die Info.

Das ist Original!
Code:
   for (c=0;c<=1;c++)
   {
      for ( i = 0; i < 72; i++ )
      {
         h=0.0f;
         for (j=0;j<8;j++) h+=specdata[i*8+j+c*576];
         h/=(1.0f*255.0f);

         h=(float)(log(h+1.0f))*10.0f;

         delta=(currenttime-lastcurrenttime)*10.0f;
         delta2=(currenttime-lastcurrenttime)*2.0f;
         if (h>heights[c][i]-delta) heights[c][i]=h; else heights[c][i]=heights[c][i]-delta;
         if (h>heights2[c][i]-delta2) heights2[c][i]=h; else heights2[c][i]=heights2[pre][i]-delta2;
      }
   }
So gehts jetzt? Dank den Hinweis auf dem array
Delphi-Quellcode:
  // Spektrum Analyser Daten glaetten
  for c := 0 to 1 do
  begin
    for i := 0 to 72 do
    begin
      h := 0.0;
      for j := 0 to 8 do
      begin
        h := (h + This_Mod^.Spectrumdata[0][i * 8 + j + c * 576]);
        h := h / (1.0 * 255.0);

        h := Ln(h + 1.0) * 10.0;

        delta := (ElapsedTime - LastTime) * 10.0;
        delta2 := (ElapsedTime - LastTime) * 2.0;
        if (h > heights[c][i] - delta) then
          h := heights[c][i]
        else
          heights[c][i] := heights[c][i] - delta;

        if (h > heights2[c][i] - delta2) then
          h := heights2[c][i]
        else
          heights2[c][i] := heights2[c][i] - delta2;
      end;
    end;
  end;
gruss Emil
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:42 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz