IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage Delphi Discussion :

Spectre d'un fichier .wav


Sujet :

Langage Delphi

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    15
    Détails du profil
    Informations personnelles :
    Âge : 33
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Mars 2006
    Messages : 15
    Points : 10
    Points
    10
    Par défaut Spectre d'un fichier .wav
    Bonjour,

    Je cherche a faire un logiciel d'edition de musique et je bloque sur l'affichage du spectre complet de la musique : c'est à dire en fait que je voudrais afficher le spectre complet d'un son au format wav dans une TPicture ou autre.
    Le seul probleme, c'est que je ne trouve rien la dessus...

    Quelqu'un peut-il m'aider ????????????

    merci d'avance, vous mes sauveurs...

    Yugimega...

  2. #2
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    Va voir ici, j'ai réussi à convertir son programme de VB6 à Delphi (avec plus ou moins de succès pour les couleurs du spectrogramme).

    Les sources sont ici :
    http://www.wilhelm-kurz-software.de/...pectrogram.htm

    si tu veux, je peux te livrer le code ici, mais je n'ai rien documenté
    Bidouilleuse Delphi

  3. #3
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    Allez, hop le code... j'espère que tu t'en sortira avec ça


    Ca vient en 6 parties

    Partie1 :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    unit UnitFourrier;
     
    interface
    Const W0Hanning = 0.5;
          W0Hamming = 0.54;
          W0Blackman = 0.42;
     
    type TComplex=record
           a,b:double; //a+ib
         end;
     
         TArrayOfDouble=array of Double;
         TComplexArray=array of TComplex;
    procedure MagnitudeSpectrum(ComplexData:TComplexArray; W0:Double; var Magnitudes:TArrayOfDouble);
    function Hanning(n,j:Integer):Double;
    function Hamming(n,j:Integer):Double;
    function Blackman(n,j:Integer):Double;
    procedure FourierTransform(ComplexData:TComplexArray; forward_dir:Boolean);
     
    implementation
     
    uses SysUtils,dialogs;
     
    function SquareSum(AComplex:TComplex):Double;
    var aaa:extended;
    begin
      try
       aaa:=AComplex.a*AComplex.a+AComplex.b*AComplex.b;
       Result:=aaa;
      except
      showmessage(FloatToStr(AComplex.a));
       result:=0;
      end;
    end;
     
    procedure MagnitudeSpectrum(ComplexData:TComplexArray; W0:Double; var Magnitudes:TArrayOfDouble);
    var i,nn:Integer;
    begin
       nn:=high(ComplexData);
       for i:=0 to nn do
       begin
         if i=0
         then Magnitudes[0]:=Sqr(SquareSum(ComplexData[0]))
         else Magnitudes[i]:=(Sqr(SquareSum(ComplexData[i])+SquareSum(ComplexData[nn-i])))/W0;
       end;
    end;
     
    function Hanning(n,j:Integer):Double;
    begin
       Result:=W0Hanning-0.5*Cos(2*pi*j/n);
    End;
     
    function Hamming(n,j:Integer):Double;
    begin
      Result:=W0Hamming-0.46*Cos(2*pi*j/n);
    end;
     
    function Blackman(n,j:Integer):Double;
    begin
      Result:=W0Blackman-0.5*Cos(2*pi*j/n)+0.08*Cos(4*pi*j/n);
    end;
     
    procedure Swap(var a,b:Double);
    var tempr:Double;
    begin
      tempr:=a;
      a:=b;
      b:=tempr;
    end;
     
    procedure FourierTransform(ComplexData:TComplexArray; forward_dir:Boolean);
    var LdArraysize,arg,count,c0,c1,i,j,aa,bb,k,nn:Integer;
        sign,prodreal,prodimag,w,phase0:Double;
        cosarray,sinarray:array of Double;
    begin
      nn:=High(ComplexData)+1;
      SetLength(cosarray,nn);
      SetLength(sinarray,nn);
     
      j:=0;
      if forward_dir
      then begin
           sign:=-1;
           For i:=0 To nn-1 do
             with ComplexData[i] do
             begin
               a:=a/SizeOf(ComplexData);
               b:=b/SizeOf(ComplexData);
             end;
           end
      else begin
             sign:=1;
           end;
     
      for i:=0 to nn-2 do
      begin
        if i<j
        then begin
               Swap(ComplexData[i].a,ComplexData[j].a);
               Swap(ComplexData[i].b,ComplexData[j].b);
             end;
        k:=nn div 2;
        while ((k<=j) and (j<>0)) do
        begin
          j:=j-k;
          k:=k div 2;
        end;
        j:=j+k;
      end;
     
      LdArraysize:=0;
      i:=nn;
      while (i<>1) do
      begin
        LdArraysize:=LdArraysize+1;
        i:=i div 2;
      end;
      phase0:=2*pi/nn;
      for i:=0 to nn-1 do
      begin
        sinarray[i]:=sign*Sin(phase0*i);
        cosarray[i]:=Cos(phase0*i);
      end;
     
      aa:=2;
      bb:=1;
     
      for count:=1 to LdArraysize do
      begin
        c0:=nn div aa;
        c1:=0;
        for k:=0 To bb-1 do
        begin
          i:=k;
          while (i<nn) do
          begin
            arg:=i+bb;
            if k=0
            then begin
                   prodreal:=ComplexData[arg].a;
                   prodimag:=ComplexData[arg].b;
                 end
            else begin
                   prodreal:=ComplexData[arg].a*cosarray[c1]-ComplexData[arg].b*sinarray[c1];
                   prodimag:=ComplexData[arg].a*sinarray[c1]+ComplexData[arg].b*cosarray[c1];
                 end;
            ComplexData[arg].a:=ComplexData[i].a-prodreal;
            ComplexData[arg].b:=ComplexData[i].b-prodimag;
            ComplexData[i].a:=ComplexData[i].a+prodreal;
            ComplexData[i].b:=ComplexData[i].b+prodimag;
            i:=i+aa;
          end;
          c1:=c1+c0;
        end;
        aa:=aa*2;
        bb:=bb*2;
      end;
    end;
     
    end.
    Bidouilleuse Delphi

  4. #4
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    Partie2 :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    unit UnitLoadWav;
     
    interface
    type
      TCCArray=array of array of cardinal;
      TBBArray=array of array of byte;
      TWWArray=array of array of Word;
     
    type TDDArray=array of array of double;
    function LoadWaveFile(WaveFileName:String;var Y:TDDArray;var NumChannels,BitsPerSample,SampleRate,NumSamples:Cardinal):Boolean;
     
    implementation
    uses mmsystem,windows,classes,sysutils,dialogs;
     
    type
    //Les différents headers que l'on trouve dans un fichier WAV
      THeaderRIFF = Packed Record
        ID    : Array[1..4]Of Char;
        Taille: Cardinal;
        Format: Array[1..4]Of Char;
      end;
     
      THeaderFormat = Packed Record
        ID    : Array[1..4]Of Char;
        Taille: Cardinal;
        Format: WORD;
        Mode  : WORD;
        SRate : Cardinal; //=Fréquence d'échantillonnage
        BRate : Cardinal; //=Nombre d'octets pour une seconde (SRate * Mode * BPS/8)
        Align : WORD;
        BPS   : WORD;     //Bits Per Sample
      end;
     
      THeaderData = Packed Record
        ID    : Array[1..4]Of Char;
        Taille: Cardinal;
      end;
     
      TWAVE = Packed Record
        RIFF: THeaderRIFF;
        Fmt : THeaderFormat;
        Data: THeaderData;
      end;
     
     
    // Reads file WaveFileName. Puts the normalized wave data in array Y and returns the sampling rate in SampleRate.
    // On return Y will hold a multidimensional array Y (sample,channel) of type Double, with the audio data.
    // Returns True, if the operation was successful, else False.
     
    function LoadWaveFile(WaveFileName:String;var Y:TDDArray;var NumChannels,BitsPerSample,SampleRate,NumSamples:Cardinal):Boolean;
    var
      WAVE:TWAVE;
      Stream: TFileStream;
      tmp   : String;
      i,c,nn:Cardinal;
      ybyte:TBBArray;
      yword:TWWArray;
    begin
      Result:=false;
      Stream := TFileStream.Create(WaveFileName, fmOpenRead);
     
      Try
        //Lecture des trois headers
        Stream.Read(WAVE, 44);
     
        //Vérification de la validité du fichier. Il faut un WAVE PCM
        If (WAVE.RIFF.ID <> 'RIFF') or (WAVE.RIFF.Format <> 'WAVE') or
           (WAVE.Fmt .ID <> 'fmt ') or (WAVE.Fmt.Format  <> 1) then
          Raise exception.Create('Le fichier choisi n''est pas un fichier WAVE PCM valide');
     
        Result:=True;
     
        NumSamples:=Round(WAVE.Data.Taille/(WAVE.Fmt.BPS/8)/WAVE.Fmt.Mode);
        NumChannels:=WAVE.Fmt.Mode;
        SampleRate:=WAVE.Fmt.SRate;
        BitsPerSample:=WAVE.Fmt.BPS;
     
        SetLength(Y,NumSamples,NumChannels);
        //FillChar(Y,SizeOf(y),0);
     
        if BitsPerSample=8
        then begin
               SetLength(ybyte,NumChannels,NumSamples);
               nn:=NumChannels*NumSamples*sizeof(byte);
               stream.Read(ybyte[0,0],nn);
               for i:= 0 to NumSamples - 1 do
                 for c:= 0 to NumChannels - 1 do
                   Y[i,c]:=(ybyte[c,i]-128)/128  //8 Bits/sample est non signé
             end
        else if BitsPerSample=16
             then begin
                    SetLength(yword,NumChannels,NumSamples);
                    nn:=NumChannels*NumSamples*sizeof(Word);
                    stream.Read(yword[0,0],nn);
                    for i:= 0 to NumSamples - 1 do
                      for c:= 0 to NumChannels - 1 do
                        Y[i,c]:=(yword[c,i]/32768);
                  end
             else ShowMessage(IntToStr(BitsPerSample)+' bits/sample non supporté');
      finally
        Stream.Free;
      end;
    end;
    end.
    Bidouilleuse Delphi

  5. #5
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    Partie3:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    unit Unit2;
     
    interface
    uses windows,graphics,controls;
     
    Const RangedB = 100;
          Log_10 = 2.30258509299405;
     
    type TAxisInfo=record
           fromX,toX,fromY,toY:Double;
         end;
     
         TPercent=0..99;
    CONST
      PixelCountMax = 32768;
     
    TYPE
      pRGBTripleArray = ^TRGBTripleArray;
      TRGBTripleArray = ARRAY[0..PixelCountMax-1] OF TRGBTriple;
     
    procedure DessineWav(WavFileName:string;WavMapArray:TImageList;SpectroMap:TBitmap;var WavAxisInfo,SpectroAxisInfo:TAxisInfo;FFTLength:cardinal;OverLapPercent:TPercent;AHeight,AWidth:Integer);
     
    implementation
    uses unitFourrier,unitLoadWav, SysUtils,types,math;
     
    // Maps magnitudes in the range [-RangedB .. 0] dB to palette index values in the range [0 .. Rangeindex-1]
    // and computes and returns the index value which corresponds to passed-in magnitude Mag
    function MapToPixelindex(Mag,RangedB:Double;Rangeindex:Cardinal):Double;
    var LevelIndB:Double;
    begin
      if Mag=0
      then Result:=0
      else begin
             LevelIndB:=20*Ln(Mag)/Log_10;
             if LevelIndB<-RangedB
             then Result:=0
             else Result:=Rangeindex*(LevelIndB+RangedB)/RangedB;
            end;
    end;
     
    PROCEDURE HSVtoRGB (CONST H,S,V: Real; VAR R,G,B: Real);
      VAR
        f : Real;
        i : INTEGER;
        hTemp: Real; // since H is CONST parameter
        p,q,t: Real;
    BEGIN
      IF       S = 0.0    // color is on black-and-white center line
      THEN BEGIN
        IF       IsNaN(H)
        THEN BEGIN
          R := V;           // achromatic: shades of gray
          G := V;
          B := V
        END;
        //ELSE RAISE EColorError.Create('HSVtoRGB: S = 0 and H has a value');
      END
     
      ELSE BEGIN // chromatic color
        IF       H = 360.0         // 360 degrees same as 0 degrees
        THEN hTemp := 0.0
        ELSE hTemp := H;
     
        hTemp := hTemp / 60;     // h is now IN [0,6)
        i := TRUNC(hTemp);        // largest integer <= h
        f := hTemp - i;                  // fractional part of h
     
        p := V * (1.0 - S);
        q := V * (1.0 - (S * f));
        t := V * (1.0 - (S * (1.0 - f)));
     
        CASE i OF
          0: BEGIN R := V; G := t;  B := p  END;
          1: BEGIN R := q; G := V; B := p  END;
          2: BEGIN R := p; G := V; B := t   END;
          3: BEGIN R := p; G := q; B := V  END;
          4: BEGIN R := t;  G := p; B := V  END;
          5: BEGIN R := V; G := p; B := q  END
        END
      END
    END {HSVtoRGB};
     
    Function PaletteValue(x:integer):TRGBTriple;
    var r4,u:Double;
        r,g,b:real;
    begin
        HSVtoRGB(x,255,255,r,g,b);
     
        result.rgbtRed:=byte(round(R));
        result.rgbtGreen:=byte(round(G));
        result.rgbtBlue:=byte(round(b));
    End;
     
    procedure DessineWav(WavFileName:string;WavMapArray:TImageList;SpectroMap:TBitmap;var WavAxisInfo,SpectroAxisInfo:TAxisInfo;FFTLength:cardinal;OverLapPercent:TPercent;AHeight,AWidth:Integer);
    var NumChannels,BitsPerSample,SampleRate,NumSamples:Cardinal;
        Y:TDDArray;
        c:Word;
        NFFT,Numcols,col:Cardinal;
        Overlap:Double;
        ColIncrement:Integer;
        TimeslotWidth,TimeslotIncrement:Double;
        ComplexData:TComplexArray;
        Magnitudes:TArrayOfDouble;
        Pixelmatrix:TBBArray;
        xx,yy,UnPixel:integer;
        PointList:array of TPoint;
        ABitmap:TBitmap;
        position:integer;
        couleur:integer;
        P :pRGBTripleArray;
    begin
      if not FileExists(WavFilename) then Exit;
      if LoadWaveFile(WavFileName, Y, NumChannels,BitsPerSample,SampleRate,NumSamples) then
      begin
        WavAxisInfo.FromX:=0;
        WavAxisInfo.ToX:=NumSamples/SampleRate;
        SetLength(PointList,NumSamples);
        WavMapArray.Clear;
        WavMapArray.Height:=AHeight;
        WavMapArray.Width:=AWidth;
        for c:=0 to NumChannels - 1 do
        begin
           ABitmap:=TBitmap.Create;
           ABitmap.PixelFormat:=pf24bit;
           ABitmap.Height:=AHeight;
           ABitmap.Width:=AWidth;
           ABitmap.Canvas.FillRect(Bounds(0,0,AWidth,AHeight));
           //dessine la courbe paramétrique
           for xx:=0 to NumSamples-1 do
             begin
               PointList[xx].X:=(xx*AWidth) div NumSamples;
               PointList[xx].Y:=round((Y[xx,c]+1)*AHeight/2);
             end;
           ABitmap.Canvas.Polyline(PointList);
           WavMapArray.Add(ABitmap,nil);
           ABitmap:=nil;
        end;
     
        NFFT:=FFTLength;
        Overlap:=OverLapPercent/100;
        ColIncrement:=round(NFFT*(1-Overlap));
     
        Numcols:=NumSamples div ColIncrement;
     
        while (((Numcols-1)*ColIncrement+NFFT)>NumSamples) do Numcols:=Numcols-1;
     
        SetLength(ComplexData,NFFT);
        SetLength(Magnitudes,NFFT);
        SetLength(Pixelmatrix,(NFFT div 2),Numcols);
     
        for col:= 0 to Numcols-1 do
        begin
          for c:=0 to NFFT-1 do
          begin
            ComplexData[c].b:=0;
            ComplexData[c].a:=Y[col*ColIncrement+c,0]*Hanning(NFFT,c);
          end;
     
          FourierTransform(ComplexData,true);
          MagnitudeSpectrum(ComplexData,W0Hanning,Magnitudes);
     
          for c:=0 To ((NFFT div 2) - 1) do
            Pixelmatrix[c, col]:=Round(MapToPixelindex(Magnitudes[c], RangedB, 360));
        end;
     
     
          SpectroMap.Height:=(NFFT div 2);
          SpectroMap.width:=Numcols;
     
          SpectroAxisInfo.fromX:=WavAxisInfo.fromX;
          SpectroAxisInfo.toX:=WavAxisInfo.toX;
          SpectroAxisInfo.fromY:=0;
          SpectroAxisInfo.toY:=SampleRate/2;
     
          TimeslotWidth:=NFFT/SampleRate;
          TimeslotIncrement:=ColIncrement/SampleRate;
          for yy:=0 to SpectroMap.height-1 do
          begin
             P:=SpectroMap.ScanLine[yy];
             for xx:=0 to SpectroMap.width-1 do
             begin
                couleur:=Pixelmatrix[yy,xx];
                P[xx]:=PaletteValue(couleur);
             end;
          end;
      end;
    end;
    end.
    Bidouilleuse Delphi

  6. #6
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    Partie 4 : l'unité principale
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    unit Unit1;
     
    interface
     
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls, StdCtrls,unit2,unitfourrier,unitloadwav, ImgList;
     
    type
      TForm1 = class(TForm)
        Panel1: TPanel;
        Panel2: TPanel;
        Button1: TButton;
        OpenDialog1: TOpenDialog;
        ImageList1: TImageList;
        Image1: TImage;
        Image2: TImage;
        procedure FormCreate(Sender: TObject);
        procedure FormDestroy(Sender: TObject);
        procedure Button1Click(Sender: TObject);
      private
        { Déclarations privées }
      public
        { Déclarations publiques }
        SpectroMap:TBitmap;
      end;
     
    var
      Form1: TForm1;
     
    implementation
    {$R *.dfm}
     
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      SpectroMap:=TBitmap.Create;
      SpectroMap.PixelFormat:=pf24bit;
    end;
     
    procedure TForm1.FormDestroy(Sender: TObject);
    begin
      SpectroMap.Free;
    end;
     
    procedure TForm1.Button1Click(Sender: TObject);
    var Axe1,Axe2:TAxisInfo;
        h,w:Integer;
        ABitmap:TBitmap;
    begin
      if OpenDialog1.Execute then
      begin
        ABitmap:=TBitmap.Create;
        h:=Panel1.ClientHeight;
        w:=Panel1.ClientWidth;
        DessineWav(OpenDialog1.FileName,ImageList1,SpectroMap,Axe1,Axe2,256,80,h,w);
     
        ImageList1.GetBitmap(0,ABitmap);
        image1.Picture.Assign(ABitmap);
        image2.Picture.Assign(SpectroMap);
        ABitmap.Free;
      end;
    end;
     
    end.
    Bidouilleuse Delphi

  7. #7
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    Partie5 : le dfm de l'Unit1
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    object Form1: TForm1
      Left = 185
      Top = 241
      Width = 696
      Height = 480
      Caption = 'Form1'
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      OldCreateOrder = False
      OnCreate = FormCreate
      OnDestroy = FormDestroy
      PixelsPerInch = 96
      TextHeight = 13
      object Panel1: TPanel
        Left = 48
        Top = 64
        Width = 393
        Height = 137
        Caption = 'Panel1'
        TabOrder = 0
        object Image1: TImage
          Left = 1
          Top = 1
          Width = 391
          Height = 135
          Align = alClient
          Stretch = True
        end
      end
      object Panel2: TPanel
        Left = 52
        Top = 248
        Width = 394
        Height = 145
        Caption = 'Panel2'
        TabOrder = 1
        object Image2: TImage
          Left = 1
          Top = 1
          Width = 392
          Height = 143
          Align = alClient
          Stretch = True
        end
      end
      object Button1: TButton
        Left = 528
        Top = 112
        Width = 75
        Height = 25
        Caption = 'Button1'
        TabOrder = 2
        OnClick = Button1Click
      end
      object OpenDialog1: TOpenDialog
        Filter = '*.wav|*.wav'
        Left = 496
        Top = 48
      end
      object ImageList1: TImageList
        Left = 456
        Top = 16
      end
    end
    Bidouilleuse Delphi

  8. #8
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    Dernière partie : le fichier dpr
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    program Project1;
     
    uses
      Forms,
      Unit1 in 'Unit1.pas' {Form1},
      UnitFourrier in 'UnitFourrier.pas',
      UnitLoadWav in 'UnitLoadWav.pas',
      Unit2 in 'Unit2.pas';
     
    {$R *.res}
     
    begin
      Application.Initialize;
      Application.CreateForm(TForm1, Form1);
      Application.Run;
    end.
    Bidouilleuse Delphi

  9. #9
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    Le mieux, c'est que tu essaies et que tu comprennes l'unité un pour utiliser les autres unités.

    Ensuite, tu pourras modifier les couleurs dans l'unité2 pour avoir un spectrogramme digne de ce nom.

    Enfin, sur ma fiche, j'ai placé
    - un TOpenDialog, 2 TPanel de même dimension
    - 2 TImage (un dans chaque dans un panel), avec stretch=true et Align=AlClient
    - Un TButton.

    si tu as des questions pose les ce soir, je suis absent pendant une semaine !

    Bon dev

    Nota Bene : BitsPerSample dans ma fonction DessinerWav, doit être une puissance de deux (0,1,2,4,8,16,32,64,128,256,512,1024, etc...)
    Bidouilleuse Delphi

  10. #10
    Membre averti
    Avatar de jmjmjm
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2005
    Messages
    760
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Service public

    Informations forums :
    Inscription : Avril 2005
    Messages : 760
    Points : 439
    Points
    439
    Par défaut
    sauf erreur de ma part 1 n'est pas une puissance de 2

  11. #11
    Membre habitué
    Profil pro
    Inscrit en
    Juillet 2002
    Messages
    207
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2002
    Messages : 207
    Points : 188
    Points
    188
    Par défaut
    sauf erreur de ma part 1 n'est pas une puissance de 2
    et 2 puissance 0 ?

    et zéro, c'est, sauf erreur de ma part, 2 puissance (-l'infini)

    Qu'on me corrige si je me trompe...

    NB : y'a pas à dire, Waskol, c'est le meilleur. Demandé lui une piste, et il vous sort un projet quasi complet... 8) si ça, c'est pas de l'entraide, moi je comprend plus

  12. #12
    Membre averti
    Avatar de jmjmjm
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2005
    Messages
    760
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Service public

    Informations forums :
    Inscription : Avril 2005
    Messages : 760
    Points : 439
    Points
    439
    Par défaut
    autant pour moi je me suis trompé en tapant je voulais mettre 0
    Mais sinon je suis tout a fait d'accord avec toi diam's, "waskol assure"

  13. #13
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    celà dit, je ne suis pas certain que mon programme fonctionne correctement avec zéro comme valeur de BitsPerSample

    (D'ailleurs je ne vois pas l'intérêt )

    Sinon, merci pour vos remarques très sympas.
    Bidouilleuse Delphi

  14. #14
    Membre habitué
    Profil pro
    Inscrit en
    Juillet 2002
    Messages
    207
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2002
    Messages : 207
    Points : 188
    Points
    188
    Par défaut
    De rien Waskol -> vive les bretons (comment ça on est chauvin ? même pas vrai ! )

    Au fait, "Waskol", c'est pour chardon ou pour artichaut ?

  15. #15
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    Citation Envoyé par diam's
    De rien Waskol -> vive les bretons (comment ça on est chauvin ? même pas vrai ! )

    Au fait, "Waskol", c'est pour chardon ou pour artichaut ?

    C'est juste le résultat d'un tirage de mots générés aléatoirement par un programme que j'ai fait il y a longtemps sur mon Oric Atmos.
    Comme j'ai bien aimé et que je suis toujours en manque d'inspiration pour trouver des pseudos corrects (forums, jeux, etc...), que les deux premières lettres sont mes initiales réelles, et comme il n'y a pas beaucoup d'autres Waskol sur le net, je l'ai gardé un peu comme un fétiche.

    A l'époque je n'étais pas encore "Breton", je le suis d'adoption depuis 4 ans ), sinon je suis Tourangeau
    Bidouilleuse Delphi

  16. #16
    Membre à l'essai
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    15
    Détails du profil
    Informations personnelles :
    Âge : 33
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Mars 2006
    Messages : 15
    Points : 10
    Points
    10
    Par défaut
    Oh Merci beaucoup...

    G pa pu repondre avant mon internet avait laché...
    Je vais teste tout cela demain...
    Mais Merci...

    Vive Delphi et Waskol !!!

    Yugimega

  17. #17
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    J'ai mis mon programme qui crée les spectrogramme sur mon site perso :
    http://waskol.developpez.com/

    Le lien se trouve dans la dernière rubrique, en bas.
    Bidouilleuse Delphi

  18. #18
    Membre à l'essai
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    15
    Détails du profil
    Informations personnelles :
    Âge : 33
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Mars 2006
    Messages : 15
    Points : 10
    Points
    10
    Par défaut
    Salut...

    He bien g teste mais quand j'ouvre un .wav, il ne m'affiche pas correctement le spectre : il m'affiche une gros rectangle noir sur la deuxieme moitié du Panel1...

    Je comprend pas ?

    Pouvez vous m'aider

    Yugimega...

  19. #19
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    Citation Envoyé par yugimega
    Salut...

    He bien g teste mais quand j'ouvre un .wav, il ne m'affiche pas correctement le spectre : il m'affiche une gros rectangle noir sur la deuxieme moitié du Panel1...

    Je comprend pas ?

    Pouvez vous m'aider

    Yugimega...
    C'est de ma faute, dans mon unité LoadWav, tout au début, j'ai déclaré mes données Wav comme ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    unit UnitLoadWav;
     
    interface
    type
      TCCArray=array of array of cardinal;
      TBBArray=array of array of byte; //données pour les fichiers wav au format 8 bits
      TWWArray=array of array of Word;//données pour les fichiers wav au format 16 bits
    Or les données d'un fichier wav 16 bits sont signées, donc il faut déclarer des smallint et pas des word
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    unit UnitLoadWav;
     
    interface
    type
      TCCArray=array of array of cardinal;
      TBBArray=array of array of byte;
      TWWArray=array of array of smallint; //<-- ici
    modifie le code là ou je t'ai indiqué, compile et essaies, ça marchera mieux

    Franchement désolé, il faut dire que je n'y ai pas passé des heures non plus...

    Sinon, pour ton information, les données sont récupérées dans un tableau de valeurs réelles comprises entre -1 et +1 qui s'appelle Y et qui à deux dimmensions.
    i : c'est la ième valeur (comprise entre 0 et NumSamples-1)
    c : c'est le numéro du canal (en stereo, il y en à deux, et dans mon programme on n'affiche que le premier canal de toute façon)
    Bidouilleuse Delphi

  20. #20
    Candidat au Club
    Inscrit en
    Novembre 2007
    Messages
    3
    Détails du profil
    Informations forums :
    Inscription : Novembre 2007
    Messages : 3
    Points : 2
    Points
    2
    Par défaut
    Le programme marche qu'avec le forma mono! Impossible d'avoir le spectre stéréo. peux tu réparé se petie bug S.V.P?
    aussi, si c'est posible dafficher les deux cannal. Merci.

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 2 12 DernièreDernière

Discussions similaires

  1. [Audio]Java et fichiers Wav
    Par danael dans le forum Multimédia
    Réponses: 3
    Dernier message: 10/10/2005, 20h09
  2. Réponses: 1
    Dernier message: 24/05/2005, 14h50
  3. Création d'un fichier .wav
    Par eag35 dans le forum MFC
    Réponses: 5
    Dernier message: 09/02/2005, 15h13
  4. Lecture de fichiers ".WAV"...
    Par 0x4e84 dans le forum Langage
    Réponses: 2
    Dernier message: 03/09/2002, 09h43
  5. [Kylix] jouer un fichier wav avec kilyx
    Par JlouisI dans le forum EDI
    Réponses: 1
    Dernier message: 14/06/2002, 02h05

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo