title
Products            Buy            Support Forum            Professional            About            Codec Central
 

Using DLLs

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Boereck

    Using DLLs

    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
    dBpoweramp Guru

    • Oct 2002
    • 761

    #2
    Re: Using DLLs

    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...)

    Comment

    • Spoon
      Administrator
      • Apr 2002
      • 44506

      #3
      Re: Using DLLs

      WFX is from Windows API.
      Spoon
      www.dbpoweramp.com

      Comment

      • Boereck

        #4
        Re: Using DLLs

        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

        Comment

        • Boereck

          #5
          Re: Using DLLs

          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'.
          Code:
          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',ReturnError,WavInfo);
           end;

          Comment

          • Boereck

            #6
            Re: Using DLLs

            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

            Comment

            • Spoon
              Administrator
              • Apr 2002
              • 44506

              #7
              Re: Using DLLs

              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
              www.dbpoweramp.com

              Comment

              • Spoon
                Administrator
                • Apr 2002
                • 44506

                #8
                Re: Using DLLs

                Plus everything in that function will be passed as a pointer to it, filename, WFX and result.
                Spoon
                www.dbpoweramp.com

                Comment

                • donny
                  dBpoweramp Guru

                  • Oct 2002
                  • 761

                  #9
                  Re: Using DLLs

                  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 ... :(

                  Comment

                  • Boereck

                    #10
                    Re: Using DLLs

                    Thanks, anyway.
                    I'll better ask in a Delphi-Forum. I think the people there have some exprience in using DLLs written in C++.

                    Comment

                    • donny
                      dBpoweramp Guru

                      • Oct 2002
                      • 761

                      #11
                      Re: Using DLLs

                      yeah, there are a lot of delphi forums, and poeple do need to to cross-over c++ and delphi...

                      Comment

                      • Bert

                        #12
                        Re: Using DLLs

                        Boereck, did you have success in unsing the dll with delphi?
                        It would be interesting for me too.

                        Comment

                        Working...

                        ]]>