Help Me Get Up and Running With DLL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Apostle
    New Member
    • Dec 2008
    • 28

    Help Me Get Up and Running With DLL

    Hi All,
    I want to make single file encoder with lame_enc.dll.
    I have DLL Manual and it tells me steps to follow is to fill BE_CONFIG and going with other stuffs. I'm newbee with this and I need help to get started.

    Google didn't help me much, I tried in other places with no avail. I hope someone here will give me a shoulder of help to get started with this library.

    Thanks for your precious time
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    I could help if you were using Windows.

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Originally posted by weaknessforcats
      I could help if you were using Windows.
      ".dll" is a windowism; us regular folks who might wear tennis shoes or an occasional python boot call it a ".so" object ;-)

      kind regards,

      Jos

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        So what do they call a DLL in Unix-land?

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          Originally posted by weaknessforcats
          So what do they call a DLL in Unix-land?
          As I wrote above: a "shared object" (.so)

          kind regards,

          Jos

          Comment

          • Banfa
            Recognized Expert Expert
            • Feb 2006
            • 9067

            #6
            Apostle it is not at all clear, are you trying to write a DLL or use a DLL? I assume you are using Windows?

            Comment

            • Apostle
              New Member
              • Dec 2008
              • 28

              #7
              Originally posted by Banfa
              Apostle it is not at all clear, are you trying to write a DLL or use a DLL? I assume you are using Windows?
              Sorry guys for late reply. I was out of the net for some time now
              I actually want to use dll named lame_enc.dll found here:


              I want to make simple MP3 encoder that encodes one file from wav to mp3
              I have a manual here

              But I want to get started

              I will appreciate your help!

              Comment

              • weaknessforcats
                Recognized Expert Expert
                • Mar 2007
                • 9214

                #8
                Do you have a copy of Windows via C/C++ by Jeffrey Richter?

                How to use a DLL is covered in excruciating detail there.

                The only thing you need know at the outset is whether you want to use implicit or explicit linking. That is, do you call the DLL methods directly as you would other functions and let the compiler generate code to locate the DLL, load it, locate the funciton in the DLL and call that function each time you make a call (implicit linking) or whether you will load the DLL yourself and use GetProcAddress to locate the address of the functions in the DLL which you will keep around as function pointers to use in function calls later (explicit linking).

                Comment

                • Apostle
                  New Member
                  • Dec 2008
                  • 28

                  #9
                  I plan to use implicit, yet I cannot find the .lib file in lame distribution.
                  BTW I don't have that book!

                  Comment

                  • weaknessforcats
                    Recognized Expert Expert
                    • Mar 2007
                    • 9214

                    #10
                    You need that book.

                    However, if there is no .lib file distributed with the DLL then look at the .h file that is distributed. Do you see anything like __declspec(dlli mport) in the function prototypes?

                    If not, you cannot use implicit linking but now have to do the linking yourself explicitly at run time using LoadLibrary, GetProcAddress and a bunch of function pointers.

                    If the __declspec(dlli mport) is there then there must be a .lib file that contains the code necessary to call the function. This is a load of the dll (if necessary) an address lookup of the function in the dll and a call to that function using that address.

                    Please note: The DLLs export functions do not work in C++ due to name mangling. Be sure your code is all extern"C" when referring to DLL functions. Internal DLL functions can use C++ but the interfacing functions cannot.

                    Comment

                    • Apostle
                      New Member
                      • Dec 2008
                      • 28

                      #11
                      I really wish to but here in my country such technological books are hard to have.
                      They are, infact difficult to get. So unless there is free PDF, I cannot have it!
                      Very sad to say :(

                      Comment

                      • weaknessforcats
                        Recognized Expert Expert
                        • Mar 2007
                        • 9214

                        #12
                        Did you read this? http://en.wikipedia.org/wiki/Dynamic-link_library

                        Then read the MSDN topics on DLLs. There are examples there.

                        Comment

                        • Apostle
                          New Member
                          • Dec 2008
                          • 28

                          #13
                          I want to get started with THIS lame_enc.dll
                          I have read the MSDN and have an overview. What I miss is how to Jump start!

                          Comment

                          • weaknessforcats
                            Recognized Expert Expert
                            • Mar 2007
                            • 9214

                            #14
                            Post a piece of the .h file that you have for the DLL.

                            Comment

                            • Apostle
                              New Member
                              • Dec 2008
                              • 28

                              #15
                              BladeMP3Enc.h

                              Code:
                              /*
                               * Blade Type of DLL Interface for Lame encoder
                               *
                               * Copyright (c) 1999-2002 A.L. Faber
                               * Based on bladedll.h version 1.0 written by Jukka Poikolainen
                               *
                               * This library is free software; you can redistribute it and/or
                               * modify it under the terms of the GNU Lesser General Public
                               * License as published by the Free Software Foundation; either
                               * version 2 of the License, or (at your option) any later version.
                               * 
                               * This library is distributed in the hope that it will be useful,
                               * but WITHOUT ANY WARRANTY; without even the implied warranty of
                               * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
                               * Lesser General Public License for more details.
                               * 
                               * You should have received a copy of the GNU Lesser General Public
                               * License along with this library; if not, write to the
                               * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
                               * Boston, MA  02111-1307, USA.
                               */
                              
                              #ifndef ___BLADEDLL_H_INCLUDED___
                              #define ___BLADEDLL_H_INCLUDED___
                              
                              #ifdef __GNUC__
                              #define ATTRIBUTE_PACKED	__attribute__((packed))
                              #else
                              #define ATTRIBUTE_PACKED
                              #pragma pack(push)
                              #pragma pack(1)
                              #endif
                              
                              #ifdef	__cplusplus
                              extern "C" {
                              #endif
                              
                              /* encoding formats */
                              
                              #define		BE_CONFIG_MP3			0										
                              #define		BE_CONFIG_LAME			256		
                              
                              /* type definitions */
                              
                              typedef		unsigned long			HBE_STREAM;
                              typedef		HBE_STREAM				*PHBE_STREAM;
                              typedef		unsigned long			BE_ERR;
                              
                              /* error codes */
                              
                              #define		BE_ERR_SUCCESSFUL					0x00000000
                              #define		BE_ERR_INVALID_FORMAT				0x00000001
                              #define		BE_ERR_INVALID_FORMAT_PARAMETERS	0x00000002
                              #define		BE_ERR_NO_MORE_HANDLES				0x00000003
                              #define		BE_ERR_INVALID_HANDLE				0x00000004
                              #define		BE_ERR_BUFFER_TOO_SMALL				0x00000005
                              
                              /* other constants */
                              
                              #define		BE_MAX_HOMEPAGE			128
                              
                              /* format specific variables */
                              
                              #define		BE_MP3_MODE_STEREO		0
                              #define		BE_MP3_MODE_JSTEREO		1
                              #define		BE_MP3_MODE_DUALCHANNEL	2
                              #define		BE_MP3_MODE_MONO		3
                              
                              
                              
                              #define		MPEG1	1
                              #define		MPEG2	0
                              
                              #ifdef _BLADEDLL
                              #undef FLOAT
                              	#include <Windows.h>
                              #endif
                              
                              #define CURRENT_STRUCT_VERSION 1
                              #define CURRENT_STRUCT_SIZE sizeof(BE_CONFIG)	// is currently 331 bytes
                              
                              
                              typedef enum
                              {
                              	VBR_METHOD_NONE			= -1,
                              	VBR_METHOD_DEFAULT		=  0,
                              	VBR_METHOD_OLD			=  1,
                              	VBR_METHOD_NEW			=  2,
                              	VBR_METHOD_MTRH			=  3,
                              	VBR_METHOD_ABR			=  4
                              } VBRMETHOD;
                              
                              typedef enum 
                              {
                              	LQP_NOPRESET			=-1,
                              
                              	// QUALITY PRESETS
                              	LQP_NORMAL_QUALITY		= 0,
                              	LQP_LOW_QUALITY			= 1,
                              	LQP_HIGH_QUALITY		= 2,
                              	LQP_VOICE_QUALITY		= 3,
                              	LQP_R3MIX				= 4,
                              	LQP_VERYHIGH_QUALITY	= 5,
                              	LQP_STANDARD			= 6,
                              	LQP_FAST_STANDARD		= 7,
                              	LQP_EXTREME				= 8,
                              	LQP_FAST_EXTREME		= 9,
                              	LQP_INSANE				= 10,
                              	LQP_ABR					= 11,
                              	LQP_CBR					= 12,
                              	LQP_MEDIUM				= 13,
                              	LQP_FAST_MEDIUM			= 14,
                              
                              	// NEW PRESET VALUES
                              	LQP_PHONE	=1000,
                              	LQP_SW		=2000,
                              	LQP_AM		=3000,
                              	LQP_FM		=4000,
                              	LQP_VOICE	=5000,
                              	LQP_RADIO	=6000,
                              	LQP_TAPE	=7000,
                              	LQP_HIFI	=8000,
                              	LQP_CD		=9000,
                              	LQP_STUDIO	=10000
                              
                              } LAME_QUALITY_PRESET;
                              
                              
                              
                              typedef struct	{
                              	DWORD	dwConfig;			// BE_CONFIG_XXXXX
                              								// Currently only BE_CONFIG_MP3 is supported
                              	union	{
                              
                              		struct	{
                              
                              			DWORD	dwSampleRate;		// 48000, 44100 and 32000 allowed
                              			BYTE	byMode;			// BE_MP3_MODE_STEREO, BE_MP3_MODE_DUALCHANNEL, BE_MP3_MODE_MONO
                              			WORD	wBitrate;		// 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256 and 320 allowed
                              			BOOL	bPrivate;		
                              			BOOL	bCRC;
                              			BOOL	bCopyright;
                              			BOOL	bOriginal;
                              
                              			} mp3;					// BE_CONFIG_MP3
                              
                              			struct
                              			{
                              			// STRUCTURE INFORMATION
                              			DWORD			dwStructVersion;	
                              			DWORD			dwStructSize;
                              
                              			// BASIC ENCODER SETTINGS
                              			DWORD			dwSampleRate;		// SAMPLERATE OF INPUT FILE
                              			DWORD			dwReSampleRate;		// DOWNSAMPLERATE, 0=ENCODER DECIDES  
                              			LONG			nMode;				// BE_MP3_MODE_STEREO, BE_MP3_MODE_DUALCHANNEL, BE_MP3_MODE_MONO
                              			DWORD			dwBitrate;			// CBR bitrate, VBR min bitrate
                              			DWORD			dwMaxBitrate;		// CBR ignored, VBR Max bitrate
                              			LONG			nPreset;			// Quality preset, use one of the settings of the LAME_QUALITY_PRESET enum
                              			DWORD			dwMpegVersion;		// FUTURE USE, MPEG-1 OR MPEG-2
                              			DWORD			dwPsyModel;			// FUTURE USE, SET TO 0
                              			DWORD			dwEmphasis;			// FUTURE USE, SET TO 0
                              
                              			// BIT STREAM SETTINGS
                              			BOOL			bPrivate;			// Set Private Bit (TRUE/FALSE)
                              			BOOL			bCRC;				// Insert CRC (TRUE/FALSE)
                              			BOOL			bCopyright;			// Set Copyright Bit (TRUE/FALSE)
                              			BOOL			bOriginal;			// Set Original Bit (TRUE/FALSE)
                              			
                              			// VBR STUFF
                              			BOOL			bWriteVBRHeader;	// WRITE XING VBR HEADER (TRUE/FALSE)
                              			BOOL			bEnableVBR;			// USE VBR ENCODING (TRUE/FALSE)
                              			INT				nVBRQuality;		// VBR QUALITY 0..9
                              			DWORD			dwVbrAbr_bps;		// Use ABR in stead of nVBRQuality
                              			VBRMETHOD		nVbrMethod;
                              			BOOL			bNoRes;				// Disable Bit resorvoir (TRUE/FALSE)
                              
                              			// MISC SETTINGS
                              			BOOL			bStrictIso;			// Use strict ISO encoding rules (TRUE/FALSE)
                              			WORD			nQuality;			// Quality Setting, HIGH BYTE should be NOT LOW byte, otherwhise quality=5
                              
                              			// FUTURE USE, SET TO 0, align strucutre to 331 bytes
                              			BYTE			btReserved[255-4*sizeof(DWORD) - sizeof( WORD )];
                              
                              			} LHV1;					// LAME header version 1
                              
                              		struct	{
                              
                              			DWORD	dwSampleRate;
                              			BYTE	byMode;
                              			WORD	wBitrate;
                              			BYTE	byEncodingMethod;
                              
                              		} aac;
                              
                              	} format;
                              		
                              } BE_CONFIG, *PBE_CONFIG ATTRIBUTE_PACKED;
                              
                              
                              typedef struct	{
                              
                              	// BladeEnc DLL Version number
                              
                              	BYTE	byDLLMajorVersion;
                              	BYTE	byDLLMinorVersion;
                              
                              	// BladeEnc Engine Version Number
                              
                              	BYTE	byMajorVersion;
                              	BYTE	byMinorVersion;
                              
                              	// DLL Release date
                              
                              	BYTE	byDay;
                              	BYTE	byMonth;
                              	WORD	wYear;
                              
                              	// BladeEnc	Homepage URL
                              
                              	CHAR	zHomepage[BE_MAX_HOMEPAGE + 1];	
                              
                              	BYTE	byAlphaLevel;
                              	BYTE	byBetaLevel;
                              	BYTE	byMMXEnabled;
                              
                              	BYTE	btReserved[125];
                              
                              
                              } BE_VERSION, *PBE_VERSION ATTRIBUTE_PACKED;
                              
                              #ifndef _BLADEDLL
                              
                              typedef BE_ERR	(*BEINITSTREAM)			(PBE_CONFIG, PDWORD, PDWORD, PHBE_STREAM);
                              typedef BE_ERR	(*BEENCODECHUNK)		(HBE_STREAM, DWORD, PSHORT, PBYTE, PDWORD);
                              
                              // added for floating point audio  -- DSPguru, jd
                              typedef BE_ERR	(*BEENCODECHUNKFLOATS16NI)	(HBE_STREAM, DWORD, PFLOAT, PFLOAT, PBYTE, PDWORD);
                              typedef BE_ERR	(*BEDEINITSTREAM)			(HBE_STREAM, PBYTE, PDWORD);
                              typedef BE_ERR	(*BECLOSESTREAM)			(HBE_STREAM);
                              typedef VOID	(*BEVERSION)				(PBE_VERSION);
                              typedef BE_ERR	(*BEWRITEVBRHEADER)			(LPCSTR);
                              typedef BE_ERR	(*BEWRITEINFOTAG)			(HBE_STREAM, LPCSTR );
                              
                              #define	TEXT_BEINITSTREAM				"beInitStream"
                              #define	TEXT_BEENCODECHUNK				"beEncodeChunk"
                              #define	TEXT_BEENCODECHUNKFLOATS16NI	"beEncodeChunkFloatS16NI"
                              #define	TEXT_BEDEINITSTREAM				"beDeinitStream"
                              #define	TEXT_BECLOSESTREAM				"beCloseStream"
                              #define	TEXT_BEVERSION					"beVersion"
                              #define	TEXT_BEWRITEVBRHEADER			"beWriteVBRHeader"
                              #define	TEXT_BEFLUSHNOGAP				"beFlushNoGap"
                              #define	TEXT_BEWRITEINFOTAG				"beWriteInfoTag"
                              
                              
                              #else
                              
                              __declspec(dllexport) BE_ERR	beInitStream(PBE_CONFIG pbeConfig, PDWORD dwSamples, PDWORD dwBufferSize, PHBE_STREAM phbeStream);
                              __declspec(dllexport) BE_ERR	beEncodeChunk(HBE_STREAM hbeStream, DWORD nSamples, PSHORT pSamples, PBYTE pOutput, PDWORD pdwOutput);
                              
                              // added for floating point audio  -- DSPguru, jd
                              __declspec(dllexport) BE_ERR	beEncodeChunkFloatS16NI(HBE_STREAM hbeStream, DWORD nSamples, PFLOAT buffer_l, PFLOAT buffer_r, PBYTE pOutput, PDWORD pdwOutput);
                              __declspec(dllexport) BE_ERR	beDeinitStream(HBE_STREAM hbeStream, PBYTE pOutput, PDWORD pdwOutput);
                              __declspec(dllexport) BE_ERR	beCloseStream(HBE_STREAM hbeStream);
                              __declspec(dllexport) VOID		beVersion(PBE_VERSION pbeVersion);
                              __declspec(dllexport) BE_ERR	beWriteVBRHeader(LPCSTR lpszFileName);
                              __declspec(dllexport) BE_ERR	beFlushNoGap(HBE_STREAM hbeStream, PBYTE pOutput, PDWORD pdwOutput);
                              __declspec(dllexport) BE_ERR	beWriteInfoTag( HBE_STREAM hbeStream, LPCSTR lpszFileName );
                              
                              #endif
                              
                              #ifdef	__cplusplus
                              }
                              #endif
                              
                              #ifndef __GNUC__
                              #pragma pack(pop)
                              #endif
                              
                              #endif

                              Comment

                              Working...