Posts: 795
Threads: 136
Joined: Feb 2009
Hi Gintaras, hi all
Gintaras, i found there http://www.rarewares.org/lossless.php a flac library, version 1.3.1 i'd like to use
The zip file contains two files:
libFLAC_dynamic.dll
libFLAC_dynamic.lib
How use them and interface them with QM?
TY
Posts: 12,095
Threads: 142
Joined: Dec 2002
Need its function reference and/or .h file containing function declarations in C language. Then convert the declarations to QM.
Posts: 795
Threads: 136
Joined: Feb 2009
ok, don't have this one...
if i eventually got one, how to proceed?
ty for input
Posts: 12,095
Threads: 142
Joined: Dec 2002
Probably this.
https://xiph.org/flac/api/files.html
Convert the C functions, struct etc to QM. All or only used. I see there are near 300 functions. Much work to convert all. I would search for a simplest C code example and then convert it to QM, and convert only declarations used there.
Posts: 795
Threads: 136
Joined: Feb 2009
found here, sources and all
https://git.xiph.org/?p=flac.git;a%3Dsummary
gives as your link libFlac or libFlac++, the first should be C code, the former C++ code (which i'm more used to)
1. Can I use C++ instead of C?
2. How to know which dll is using C++ code then?
3. libflac has more headers than libflac++, so i must use the headers from libflac in libflac++ (like the callback.h header)?
4. must i compile by myself the dll, or using headers is enough to manipulate flac files by QM only?
Posts: 12,095
Threads: 142
Joined: Dec 2002
1. No.
2. Usually the dll contains only C functions. C++ classes are just source code in .h and .cpp files; they call the same C functions.
3. Use only C headers.
4. The dll is in the zip, don't need to compile. Need only function declarations that are in headers. The .lib file is not useful.
Posts: 795
Threads: 136
Joined: Feb 2009
ok, will test this afternoon
last question, is the declaration like this?
dll "$qm$\libFLAC_dynamic.dll"
and how use callback.h?
ref callback.h
Posts: 12,095
Threads: 142
Joined: Dec 2002
Yes.
Macro Macro167
dll "$qm$\libFLAC_dynamic.dll"
,function1 declaration
,function2 declaration
,...
If there are many declarations, I would put all in a ref macro or file.
Callback example.
C
typedef size_t(* FLAC__IOCallback_Read )(void *ptr, size_t size, size_t nmemb, FLAC__IOHandle handle)
QM
Function FLAC__IOCallback_Read
function[c]int byte*ptr size nmemb handle
;...
Posts: 795
Threads: 136
Joined: Feb 2009
Posts: 795
Threads: 136
Joined: Feb 2009
Gintaras Wrote:Yes.
If there are many declarations, I would put all in a ref macro or file.
[/code]
so I use this on top of my macro?
dll "$qm$\libFLAC_dynamic.dll"
ref "$qm$\callbak.h"
ref "$qm$\ metadata.h"
Posts: 12,095
Threads: 142
Joined: Dec 2002
No, QM does not support .h files.
ref is for QM declarations.
Or #compile, it is similar.
ref or #compile are useful when the same declarations are used in multiple macros.
Posts: 795
Threads: 136
Joined: Feb 2009
like in Aspell example?
ok, so:
I create a macro named Flac_Def and put declaration related to flac in it (your example)
FLAC__IOCallback_Read int byte*ptr size nmemb handle
and compile at beginning of marco (or function) using flac dll code
dll "$qm$\libFLAC_dynamic.dll"
#compile Flac_Def
_i=FLAC__IOCallback_Read(0 0 23 0 0)
is this correct?
Posts: 795
Threads: 136
Joined: Feb 2009
argg, tried some code
dll "Q:\My QM\libFLAC_dynamic.dll"
Error in <open ":3274: /56">Macro11: dll not found or failed to load.
seem doomed here....
Posts: 12,095
Threads: 142
Joined: Dec 2002
Maybe downloaded 64-bit dll.
Tested, works.
Macro Macro272
dll "Q:\Downloads\libFLAC_dynamic.dll"
,FLAC__StreamDecoderInitStatusString
Posts: 12,095
Threads: 142
Joined: Dec 2002
Quote:is this correct?
No.
Macro Flac_Def
;constants
def xxx ...
;...
;types
type yyy ...
type FLAC__IOCallbacks read write seek tell eof close
;...
;functions
dll "Q:\Downloads\libFLAC_dynamic.dll"
,FLAC__StreamDecoderInitStatusString ...
,FLAC__FunctionThatCallsYourCallbacks ... FLAC__IOCallbacks*iocb ...
,...
,;Also you can declare the exported variables here.
;Don't need to declare callbacks. Just create functions with parameters etc that match the C callback declarations.
Function FLAC__IOCallback_Read
function[c]int byte*ptr size nmemb handle
;your code here
Macro Macro272
#compile Flac_Def
FLAC__StreamDecoderInitStatusString ...
;...
FLAC__IOCallbacks iocb
iocb.read=&FLAC__IOCallback_Read
iocb.write=...
;...
FLAC__FunctionThatCallsYourCallbacks ... &iocb ...
;...
Posts: 795
Threads: 136
Joined: Feb 2009
yes, wrong compilation, x86 dll works.
thanks for the input, must work to translate dll headers now
|