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

Delphi Discussion :

Types de variables incompatibles


Sujet :

Delphi

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Février 2004
    Messages
    213
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Février 2004
    Messages : 213
    Par défaut Types de variables incompatibles
    Hello,

    je suis débutant en programmation Delphi, et j'ai quelques soucis avec les formats de variables.

    Mes erreurs sont:

    [Erreur] Unit1.pas(542): Opérateur ou point-virgule manquant
    [Erreur] Unit1.pas(542): Opérateur non applicable à ce type d'opérande

    La ligne 542 est : value := Trunc(@fft(384) * 1000);

    Voici mon code :

    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
     
    procedure TForm1.toneTimer(Sender: TObject);
    var
    fft : array [0..255] of Single; // 255 or 511 ?
    reed : Integer;
    value : Integer;
    begin
     
      if BASS_ChannelIsActive(chan) = 1 then
      begin
      // Detection
     
      reed := BASS_ChannelGetData(chan, @fft, BASS_DATA_FFT512);
     
          if (reed >= 0) then
            begin
            // trunc Réel > Entier
              value := Trunc(@fft(384) * 1000); // here i get the sound level at 16500 hz
              if (value >= 100) then
                begin
                Button1.Click();
                tone.Enabled := False;
              end;
            end;
     
        end;
     
    end;

    Voici les infos la fonction spécifique :

    BASS_ChannelGetData

    --------------------------------------------------------------------------------

    Retrieves the immediate sample data (or an FFT representation of it) of a stream or MOD music channel. Can also be used with a recording channel.

    DWORD WINAPI BASS_ChannelGetData(
    DWORD handle,
    void *buffer,
    DWORD length
    );


    Parameters
    handle The channel handle... a HMUSIC, HSTREAM, or HRECORD.
    buffer Location to write the data... can be NULL when handle is a recording channel (HRECORD), to discard the requested amount of data from the recording buffer.
    length Number of bytes wanted, and/or the following flags.
    BASS_DATA_FLOAT Return floating-point sample data.
    BASS_DATA_FFT512 512 sample FFT (returns 256 floating-point values)
    BASS_DATA_FFT1024 1024 sample FFT (returns 512 floating-point values)
    BASS_DATA_FFT2048 2048 sample FFT (returns 1024 floating-point values)
    BASS_DATA_FFT4096 4096 sample FFT (returns 2048 floating-point values)

    BASS_DATA_FFT_INDIVIDUAL Use this flag to request separate FFT data for each channel. The size of the data returned (as listed above) is multiplied by the number channels.

    BASS_DATA_FFT_NOWINDOW This flag can be used to prevent a Hanning window being applied to the sample data when performing an FFT.
    BASS_DATA_AVAILABLE Query the amount of data the channel has buffered. This flag is primarily of use when recording, and can't be used with decoding channels as they do not have playback buffers. buffer can be NULL when using this flag.



    Return value
    If an error occurs, -1 is returned, use BASS_ErrorGetCode to get the error code. When requesting FFT data, the number of bytes read from the channel (to perform the FFT) is returned. When requesting sample data, the number of bytes written to buffer will be returned (not necessarily the same as the number of bytes read when using the BASS_DATA_FLOAT flag). When using the BASS_DATA_AVAILABLE flag, the number of bytes in the channel's buffer is returned.

    Error codes
    BASS_ERROR_HANDLE handle is not a valid channel.
    BASS_ERROR_NOPLAY The channel is not playing, or is stalled. When handle is a "decoding channel", this indicates that it has reached the end.
    BASS_ERROR_NOTAVAIL The BASS_DATA_AVAILABLE flag was used with a decoding channel.
    BASS_ERROR_BUFLOST Should not happen... check that a valid window handle was used with BASS_Init.


    Remarks
    This function can only return as much data as has been written to the channel's buffer, so it may not always be possible to get the amount of data requested, especially if you request large amounts. If you really do need large amounts, then increase the buffer lengths (BASS_CONFIG_BUFFER). The BASS_DATA_AVAILABLE flag can be used to check how much data a channel's buffer contains at any time, including when stopped or stalled.

    When requesting data from a "decoding channel" (BASS_STREAM_DECODE or BASS_MUSIC_DECODE was used at creation), there are no intermediate buffers involved, so as much data as is available can be decoded in one go.

    When retrieving sample data, the returned data is in the standard Windows PCM format: 8-bit samples are unsigned, 16-bit samples are signed, 32-bit floating-point samples range from -1 to 1 (not clipped, so can actually be outside this range). That's unless the BASS_DATA_FLOAT flag is used, in which case, the sample data will be converted to 32-bit floating-point (if it isn't already).

    When requesting FFT data, floating-point values ranging from 0 to 1 are returned. Only the first half of the FFT is useful, so that's what BASS returns. For example with a 2048 sample FFT, it'll return 1024 values - the 1st value being the DC component, the 2nd the amplitude at 1/2048 of the channel's sample rate, then the amplitude at 2/2048, 3/2048, etc... A Hanning window is applied to the sample data to reduce leakage, unless the BASS_DATA_FFT_NOWINDOW flag is used.

    Channels that have 2 or more sample channels (ie. stereo or above) may have FFT performed on each individual channel, using the BASS_DATA_FFT_INDIVIDUAL flag. Without this flag, all the channels are combined, and a single mono FFT is performed. Performing the extra individual FFTs of course increases the amount of processing required. The return values are interleaved in the same order as the channel's sample data, eg. stereo = left,right,left,etc...

    This function is most useful if you wish to visualize (eg. spectrum analyze) the sound.

    Example
    Get an 1024 sample FFT representation of a playing channel.

    float fft[512]; // fft data buffer
    BASS_ChannelGetData(channel,fft,BASS_DATA_FFT1024);

    Bon weekend à tous.

  2. #2
    Expert confirmé

    Avatar de sjrd
    Homme Profil pro
    Directeur de projet
    Inscrit en
    Juin 2004
    Messages
    4 517
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : Suisse

    Informations professionnelles :
    Activité : Directeur de projet
    Secteur : Enseignement

    Informations forums :
    Inscription : Juin 2004
    Messages : 4 517
    Par défaut
    Ceci ne veut rien dire :
    ne veut strictement rien dire

    Déjà les tableaux en Pascal sont indicés par des [] et non des (). Ensuite pourquoi utiliser l'opérateur @, qui te donne l'adresse de la variable ? Finalement, pourquoi 384 : ce n'est pas un indice valide de ton tableau à 255 caractères

    Bref je ne comprends pas du tout ce que tu cherches à obtenir par cette ligne de code
    sjrd, ancien rédacteur/modérateur Delphi.
    Auteur de Scala.js, le compilateur de Scala vers JavaScript, et directeur technique du Scala Center à l'EPFL.
    Découvrez Mes tutoriels.

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Février 2004
    Messages
    213
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Février 2004
    Messages : 213
    Par défaut
    Salut,

    J'ai corrigé:

    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
     
    procedure TForm1.toneTimer(Sender: TObject);
    var
    fft : array [0..511] of Single; // 255 or 511 ?
    reed : Integer;
    value : Integer;
    begin
     
      if BASS_ChannelIsActive(chan) = 1 then
      begin
      // Detection
     
      reed := BASS_ChannelGetData(chan, fft, BASS_DATA_FFT512);
     
          if (reed >= 0) then
            begin
            // trunc Réel > Entier
              value := Trunc(fft[384] * 1000); // here i get the sound level at 16500 hz
              if (value >= 100) then
                begin
                Button1.Click();
                tone.Enabled := False;
              end;
            end;
     
        end;
     
    end;
    dernière erreur:

    [Erreur] Unit1.pas(537): Types incompatibles : 'Array' et 'Pointer'

    l'erreur est ici:
    reed := BASS_ChannelGetData(chan, fft, BASS_DATA_FFT512);

  4. #4
    Expert confirmé

    Avatar de sjrd
    Homme Profil pro
    Directeur de projet
    Inscrit en
    Juin 2004
    Messages
    4 517
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : Suisse

    Informations professionnelles :
    Activité : Directeur de projet
    Secteur : Enseignement

    Informations forums :
    Inscription : Juin 2004
    Messages : 4 517
    Par défaut
    Citation Envoyé par mickaelmediaprod
    dernière erreur:

    [Erreur] Unit1.pas(537): Types incompatibles : 'Array' et 'Pointer'

    l'erreur est ici:
    reed := BASS_ChannelGetData(chan, fft, BASS_DATA_FFT512);
    Remplace fft par @fft[0], et ça devrait aller.
    sjrd, ancien rédacteur/modérateur Delphi.
    Auteur de Scala.js, le compilateur de Scala vers JavaScript, et directeur technique du Scala Center à l'EPFL.
    Découvrez Mes tutoriels.

  5. #5
    Membre confirmé
    Homme Profil pro
    Inscrit en
    Juillet 2006
    Messages
    58
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2006
    Messages : 58
    Par défaut Bonjour
    Bonjour,

    @fft[0] : c'est l'adresse mémoire du premier élement du tableau fft[]

Discussions similaires

  1. Types de variables incompatibles
    Par marcel6566 dans le forum Langage
    Réponses: 4
    Dernier message: 25/08/2014, 14h07
  2. [SQL S 2000] Type de variable ?
    Par Tankian dans le forum MS SQL Server
    Réponses: 2
    Dernier message: 29/06/2004, 14h03
  3. Assembleur et type de variable delphi
    Par declencher dans le forum Langage
    Réponses: 5
    Dernier message: 20/06/2004, 23h21
  4. Comparer les types de variable
    Par onipif dans le forum ASP
    Réponses: 11
    Dernier message: 27/05/2004, 18h07
  5. Types de variables entre mysql/php et flash
    Par ramses83 dans le forum Flash
    Réponses: 2
    Dernier message: 06/10/2003, 18h35

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