How to translate from C to Delphi

I want to read a wav file in small buffers and to call a function in a DLL with this buffer. Here the sample code in C. How do this with Delphi ?
=========
FILE* essai=fopen("d:\\tri\\essai.wav","rb");

short buff[1024];
int count;
char answer[1024];
int number=1;
int dwarf;

        while ((count=fread(buff,2,1024,essai))>0)
        {
                BBTAsr_RecognizeBuffer16(asr, (short *)buff, count,
WRFMT_PCM16);
                if ( ((dwarf=BBTAsr_GetRecognizedString(asr,answer,1024)))==0)
                         fprintf(stderr,"Here :%s\n",answer);

        };
        BBTAsr_RecognizeBuffer16(asr,NULL,0,WRFMT_PCM16);

        answer[0] = '/0';
        fprintf(stdout,"%d %s %s\n",number,argv[1],answer);
fclose(essai);
=========
I want help to this part :
=====
        while ((count=fread(buff,2,1024,essai))>0)
        {
                BBTAsr_RecognizeBuffer16(asr, (short *)buff, count,
WRFMT_PCM16);
=====

The function is declared in a pas file :

  pSmallInt       = ^SmallInt;

function BBTAsr_RecognizeBuffer16(pAsr: LPASR; pData: pSmallInt; nb: integer; codingfmt: WRFMT_Coding): Integer; stdcall; external 'BabAsr.dll' name 'BBTAsr_RecognizeBuffer16';

Thanks for the help !

Jean-Pol
jpdupontAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

LischkeCommented:
Hi Jean-Pol,

here we go:

Count := Stream.Read(buff, 2048);
while Count > 0 do
begin
  BBTAsr_RecognizeBuffer16(asr, @buff, count, WRFMT_PCM16);
  :
  Count := Stream.Read(buff, 2048);
end;


Here I'd recommend that you use a file stream instead of the old style file handling. The value 2048 results from the fread call using 1024 items with an item size of 2 bytes.

Ciao, Mike
0
jpdupontAuthor Commented:
Mike,

thanks for the answer !

What's the type of "buff" ?

How translate :

short buff[1024]; ?

Jean-Pol
0
LischkeCommented:
write it so:

var
  buff: array[0..1023] of SmallInt;

Ciao, Mike
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jpdupontAuthor Commented:
Thanks !
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.