Bonjour,

Je suis en train de développer une unité pour utiliser la librairie libacarsd.dll dans mon programme.

J'ai réalisé, pour le moment, ce morceau de 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
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
 
unit libacarsd;
 
{$mode objfpc}{$H+}
 
interface
 
uses
    Windows;
 
const
    // Type of soundstreams
    // Only 3 types are supported at the moment:
    // 19500 Hz
    // 22050 Hz
    // 44100 Hz
    // all streams have to be MONO, 8bit
    STREAM19500 = 0;
    STREAM22050 = 1;
    STREAM44100 = 2;
 
type
    // Typedefinition for a single char within ACARS stream
    ACD_CONT = packed record
        error : Byte; // Error indicated by 1. No error = 0
        data  : Byte; // Decoded char - without error? see above
    end;
 
    // Typedefinition for the complete ACARS stream
    ACD = packed record
        len      : Integer; // Count of decoded chars
        errors   : Integer; // Errorcounter
        closed   : Integer; // Transmission correct closed
        flags    : Integer; // Flags for this transmission - see above
        squitter : Integer; // This is a Squitter message
        uplink   : Integer; // This is a Uplink message
        lastpos  : Integer; // Last position within soundstream
        crc      : Word;    // Calcutated CRC. 0 if message is complete and validated!
        c        : array[1..1024] of ACD_CONT;
    end;
 
    P_libacarsd = ^libacarsd;
    libacarsd = packed record
        acarsd_codepos : Integer;
        acarsd_utable  : array[1..10] of LongWord;
        codeholder     : array[1..100] of ACD;
        private        : Pointer;
    end;
 
    function acarsd_init(const buf: Integer; const sample: Integer; const pass: Integer): P_libacarsd; cdecl; external 'libacarsd.dll';
 
implementation
 
end.
Je l'utilise comme ça :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
procedure TForm1.FormCreate(Sender: TObject);
const
     Fichier = 'sndfile.snd';
var
   L : P_libacarsd;
begin
     if FileExists(ExtractFilePath(Application.ExeName) + Fichier) then
     begin
          L := acarsd_init(FileSize(ExtractFilePath(Application.ExeName) + Fichier), STREAM19500, 8);
     end;
end;
Le programme plante...

Je pense que ma conversion est bonne :
Code c : 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
 
/* Typedefinition for a single char within ACARS stream */
typedef struct {
    unsigned char error; /* Error indicated by 1. No error = 0 */
    unsigned char data;  /* Decoded char - without error? see above */
} ACD_CONT;
 
/* Typedefinition for the complete ACARS stream */
typedef struct {
    int len;             /* Count of decoded chars */
    int errors;          /* Errorcounter */
    int closed;          /* Transmission correct closed */
    int flags;           /* Flags for this transmission - see above */
    int squitter;        /* This is a Squitter message */
    int uplink;          /* This is a Uplink message */
    int lastpos;         /* Last position within soundstream */
    unsigned short crc;  /* Calcutated CRC. 0 if message is complete and validated! */
    ACD_CONT c[1024];    /* Included typedef from above */
} ACD;
 
/* Public part of Library structure 
   !!! DONT CHANGE ANYTHING ON THIS DEFINITION !!!
*/
typedef struct {
    int acarsd_codepos;
    unsigned long acarsd_utable[10];
    ACD codeholder[100];
    void *private;
} libacarsd;
 
/* Initialize internal structures */
EXPORT libacarsd __stdcall *acarsd_init(const int buf,    /* Size of buffer with sounddata  */
					const int sample, /* Sampling rate (see above)      */
					const int pass);  /* How many passes on each stream */

Qu'en pensez-vous ?

La documentation de la DLL est consultable en ligne à cette adresse : http://www.acarsd.org/docu.html

Merci pour votre aide,
ZiP