jpdupont
asked on
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\\essa i.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(a sr, (short *)buff, count,
WRFMT_PCM16);
if ( ((dwarf=BBTAsr_GetRecogniz edString(a sr,answer, 1024)))==0 )
fprintf(stderr,"Here :%s\n",answer);
};
BBTAsr_RecognizeBuffer16(a sr,NULL,0, WRFMT_PCM1 6);
answer[0] = '/0';
fprintf(stdout,"%d %s %s\n",number,argv[1],answe r);
fclose(essai);
=========
I want help to this part :
=====
while ((count=fread(buff,2,1024, essai))>0)
{
BBTAsr_RecognizeBuffer16(a sr, (short *)buff, count,
WRFMT_PCM16);
=====
The function is declared in a pas file :
pSmallInt = ^SmallInt;
function BBTAsr_RecognizeBuffer16(p Asr: LPASR; pData: pSmallInt; nb: integer; codingfmt: WRFMT_Coding): Integer; stdcall; external 'BabAsr.dll' name 'BBTAsr_RecognizeBuffer16' ;
Thanks for the help !
Jean-Pol
=========
FILE* essai=fopen("d:\\tri\\essa
short buff[1024];
int count;
char answer[1024];
int number=1;
int dwarf;
while ((count=fread(buff,2,1024,
{
BBTAsr_RecognizeBuffer16(a
WRFMT_PCM16);
if ( ((dwarf=BBTAsr_GetRecogniz
fprintf(stderr,"Here :%s\n",answer);
};
BBTAsr_RecognizeBuffer16(a
answer[0] = '/0';
fprintf(stdout,"%d %s %s\n",number,argv[1],answe
fclose(essai);
=========
I want help to this part :
=====
while ((count=fread(buff,2,1024,
{
BBTAsr_RecognizeBuffer16(a
WRFMT_PCM16);
=====
The function is declared in a pas file :
pSmallInt = ^SmallInt;
function BBTAsr_RecognizeBuffer16(p
Thanks for the help !
Jean-Pol
ASKER
Mike,
thanks for the answer !
What's the type of "buff" ?
How translate :
short buff[1024]; ?
Jean-Pol
thanks for the answer !
What's the type of "buff" ?
How translate :
short buff[1024]; ?
Jean-Pol
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks !
here we go:
Count := Stream.Read(buff, 2048);
while Count > 0 do
begin
BBTAsr_RecognizeBuffer16(a
:
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