View Full Version : Using DLLs
Boereck
03-08-2004, 08:46 PM
Hello,
I want to use the dBpowerAmp-encoding-DLLs in my program, but I have some problems. I thought that the ExampleCompression-Source from the website could help me, but I write in Delphi, so I don't understand everything in the ExampleCompression-Code.
Well, here are my questions:
How is the type / class (?) "WAVEFORMATEX" defined?
With which parameters/variables do I call the "SetProfile"-function? And what does it do?
Do I have to stream the data of the wave-file through "ANewDataBlockArrived" or is there a way to encode directly from a file on harddisk?
Thanks you,
Max
donny
03-09-2004, 06:02 AM
you should try importing some of the dlls in Delphi...
I think it is done tru import types, or define new types... I can look it up if you can't fin it...
anyway I think you shuld get new components installed and then you can see their properties and it should be logic enough....
I did this for QueMaster (components amp and multiplayer...)
Spoon
03-09-2004, 08:01 AM
WFX is from Windows API.
Boereck
03-10-2004, 12:56 AM
Allright, I found WAVEFORMATEX in Delphi's Windows SDK-Help.
I can use "SetProfile" as a function without parameters and output (at least It doesn't cause an access-violation), but I still don't know what it actually does.
I think before I can use the encoder-DLLs I have to learn how to get WAVEFORMATEX-Information from a WAVE-file, and how to read blocks of a WAVE-file that I can send to ANewDataBlockArrived.
I Already found a WAV-file component. I hope it helps me.
Thanks,
Max
Boereck
03-10-2004, 07:57 AM
When I try to use the "CreateNewCompressionObject"-function, I always get this access-violation error:
Project C:\Eigene Datein\Delphi\DLL Loader\DllLoader.exe faulted with message: 'access violation at 0x00431c54: read of address 0x00000000'. Process Stopped. Use Step or Run to continue.
Here are some code-extracts (taken from several units). I get the message when I use "Start" with correct WavInfo from 'C:\test.wav'.
interface
type TWaveFormatEX = record
wFormatTag: Word; { format type }
nChannels: Word; { number of channels (i.e. mono, stereo, etc.) }
nSamplesPerSec: DWORD; { sample rate }
nAvgBytesPerSec: DWORD; { for buffer estimation }
nBlockAlign: Word; { block size of data }
wBitsPerSample: Word; { number of bits per sample of mono data }
cbSize: Word; { the count in bytes of the size of }
end;
type ENCompressionOpenResult = (COROk, CORFileError, CORMemoryError, CORCodecError);
procedure CreateNewCompressionObject(FileName:ShortString; var ReturnError: ENCompressionOpenResult; WFXOutputFormat: TWaveFormatEX); cdecl; external 'Mp3 (Lame).dll';
procedure Start(WavInfo: TWaveFormatEX);
implementation
procedure Start(WavInfo: TWaveFormatEX);
var
ReturnError: ENCompressionOpenResult;
begin
CreateNewCompressionObject('C:\test.wav',ReturnErr or,WavInfo);
end;
Boereck
03-10-2004, 09:45 PM
If I use an "Array of Char" inistead of a "ShortString" in "CreateNewCompressionObject" and call it with an "Array [0..255] of Char" the program doesn't crash totaly, I but still get an access-violation:
Project DllLoader.exe raised exception class EAccessViolation with message 'Access violation at address 1000AC44 in module 'Mp3 (Lame).dll'. Write of address 000000FF'. Process stopped. Use Step or Run to continue.
I don't get it. How can I call this function?? I even tried to send a pointer to the Filename. I'm trying it for hours now. I thing I'm going mad soon. o_O
Spoon
03-11-2004, 07:42 AM
I would like to help but don't program in delphi.
"type ENCompressionOpenResult = (COROk, CORFileError, CORMemoryError, CORCodecError);"
Possibly delphi handles enums differently to C++
Spoon
03-11-2004, 07:43 AM
Plus everything in that function will be passed as a pointer to it, filename, WFX and result.
donny
03-11-2004, 08:05 AM
I don't know if this helps but I used to have a lot of similar errors before... In my case I had to "create" an tamp component first, before using it .... something like:
amp:= tamp.create;
maybe that is your problem too... you don't "reserve" the memory before using it...
I remeber I had those errors about some other issues, but can't remeber what ... :(
Boereck
03-11-2004, 08:19 AM
Thanks, anyway. :)
I'll better ask in a Delphi-Forum. I think the people there have some exprience in using DLLs written in C++.
donny
03-12-2004, 07:05 AM
yeah, there are a lot of delphi forums, and poeple do need to to cross-over c++ and delphi...
Boereck, did you have success in unsing the dll with delphi?
It would be interesting for me too.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.