Jump to content

lame_enc.dll


Recommended Posts

Ok, so i am writing a autoit script that encodes mp3 files via lame_enc.dll. I don't normally work with dll's so i am not even sure if i am doing this correctly.

The DLL is by default compiled with the MS Visual C/C++ compiler, which has the following type definitions:

Type Description

CHAR signed char (8 bits)

BYTE unsigned char (8 bits)

SHORT signed short (16 bits)

WORD unsigned short (16 bits)

INT signed long (32 bits)

LONG signed long (32 bits)

BOOL signed long (32 bits) (YES, 32 bits for a one bit value)

TRUE = 0

FALSE=-1

DWORD unsigned long (32 bits)

FLOAT floating point (32 bits)

DOUBLE float point (64 bits)

LPCSTR const char* (32 bits pointer to zero terminated character string)

Ok, that is all good and dandy, except the AutoIt DllStructCreate() doesn't have all those. It doesn't have Boolean. So i am trying to figure out if i used a signed integer for the TRUE = 0 and FALSE=-1 values. In addition the documentation isn't being that helpful(for me at least).

format.LHV1.dwReSampleRate Specifies to which sample rate the input stream has to be resampled, if set to 0, the encoder will decide which ReSample rate to use

format.LHV1.nMode Stereomode for MP3 file. This can be either BE_MP3_MODE_STEREO, BE_MP3_MODE_JSTEREO, BE_MP3_MODE_DUALCHANNEL or BE_MP3_MODE_MONO.

The first part uses a signed integer, but the second part uses n? What do you use for the n prefix? A signed integer since those variables above are all assigned integer values?

Also, i am not sure what to do with the second function:

beInitStream()

Synopsis: BE_ERR beInitStream( PBE_CONFIG pbeConfig, PDWORD dwSamples, PDWORD dwBufferSize, PHBE_STREAM phbeStream )

Parameters:

pbeConfig Pointer at the struct containing encoder settings.

dwSamples Pointer at double word where number of samples to send to each beEncodeChunk() is returned.

dwBufferSize Pointer at double word where minimum size in bytes of output buffer is returned.

phbeStream Pointer at integer where Stream handle is returned.

Description: This function is the first to call before starting an encoding stream.

Now, i think i know what the first one is, all i have to use is the ptr value and then use the DllStructGetPtr($BE_CONFIG) to get the pointer, however, the rest of the parameters don't make much sense to me. I have no idea what they mean by:

"Pointer at double word where number of samples to send to each beEncodeChunk() is"

"Pointer at double word where minimum size in bytes of output buffer is returned."

"Pointer at integer where Stream handle is returned."

How and where do you get these pointers from? Any help would be appreciated.

I have done most of the work searching through the documentation in hopes that you won't have to do much work and that i will get more replies as a result.

Here is a link to the the dll programmer documentation(function reference):

http://users.hol.gr/~dzach/vox/lame/LameDLLInterface.htm

Here is a link to the header file with the constants:

http://www.thekandieman.com/misc/BladeMP3EncDLL.h (8 KB)

Here is a link to a zip file with the latest lame_enc.dll and an ini file that sets the dll in debug mode.

http://www.thekandieman.com/misc/lame_enc.zip (340 KB)

Also, what tags do you use for the AutoIt color code(for posting on the forums)? I'd use the codebox, but it really isn't that long.

Important! For some reason the posting butchers some of the script, replacing dword with & symbols and other various things.

Please download the code here:

http://www.thekandieman.com/misc/lame.au3 (7 KB)

Edit: Posting the code in the codebox seems to butcher it. Please download from the link above, sorry. :(

Thanks for any help you can provide me with. :)

Edited by The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

Yes, the executable version of lame is a command line encoder(yes, great if you want to write bat files or send commands other ways to the .exe version), but i want to use the lame_enc.dll which isn't command line since it is a dynamic link library and not an executable. Therefore in order to be able to use the .dll i must use advanced dll calls and create dll structures.

I want to do this to better integrate lame into my script and to learn how to use dll calls and structures.

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

...Also, what tags do you use for the AutoIt color code(for posting on the forums)?...

[autoit] and [/ autoit] without the space

Edit2: http://www.autoitscript.com/forum/index.ph...showtopic=25105

Edit: Others have worked with this dll:

http://www.autoitscript.com/forum/index.php?showtopic=26289

...but you might have already seen that

and/or

it may be of no help to your efforts.

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

[autoit] and [/ autoit] without the space

Edit2: http://www.autoitscript.com/forum/index.ph...showtopic=25105

Edit: Others have worked with this dll:

http://www.autoitscript.com/forum/index.php?showtopic=26289

...but you might have already seen that

and/or

it may be of no help to your efforts.

Thanks, i never thought of looking in the idea lab to figure out how to use the color posting. Jon should pin a topic on the forum that tells you how to use the tags.

I have seen that post and while he is trying to do the exact same thing as me, he has also run into the same problems that i have with the second function. :)

Any ideas?

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

Nobody here can help?

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

>>It doesn't have Boolean

Use a type that takes up an equivelent amount of bits.

Try doing it step by step and if you already have some code done, I'd prefer looking at it.

#)

Link to comment
Share on other sites

Thanks for responding. :)

Yeah, sorry, i had orignally posted the code in a codebox but the codebox improperly displayed the code, so i had to link to the souce instead:

http://www.thekandieman.com/misc/lame.au3 (7 KB)

That is the source. I have the dll structure done, i think. Not sure about how to do the beInitStream(), beEncodeChunk(), and other similar functions. They don't have that many parameters though and it is just stuff like, "Pointer at double word where number of samples to send to each beEncodeChunk() is."

There are links to the documentation and the lame_enc.dll that i am using in my original post. ^

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

First function call:

;;nfwu: Create Structures to contain the data returned via the pointers
$NumberOfSamplesToSend_Struct = DllStructCreate("dword")
$MinimumBufferSize_Struct     = DllStructCreate("dword")
$HandleToStream_Struct        = DllStructCreate("int")

;;BE_ERR beInitStream( PBE_CONFIG pbeConfig, PDWORD dwSamples, PDWORD dwBufferSize, PHBE_STREAM phbeStream )
$beInitStream_ReturnValue = DllCall($dll,"str","beInitStream","ptr",DllStructGetPtr($BE_CONFIG),"dword", DllStructGetPtr($NumberOfSamplesToSend_Struct, 1), "dword", DllStructGetPtr($MinimumBufferSize_Struct, 1), "int", DllStructGetPtr($HandleToStream_Struct, 1))

#)

EDIT: BTW, I noticed the line

INT signed long (32 bits)

in the docs, if your current code does not work, change every "int" in your code to "long". Edited by nfwu
Link to comment
Share on other sites

Btw, here is a list of commonly used version of Hungarian Notation:

Types

i = integer

f = float

d = double

l = long

b = boolean

dw = double word (dword)

w = word

by = byte

sz = C-Style (null-termintated) string

Common Extentions

Str = C++ String Object

H = Handle

V = Vector

Pt = Point

Rgb = RGB Triplet

Modifier

p = Pointer To

r = Reference To

U = unsigned

a = array

ary = array

Scope

m_ = Member Var

g_ = Global Var

s_ = Static Var

Hope it helps!

#)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...