Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using flac library
#1
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
#2
Need its function reference and/or .h file containing function declarations in C language. Then convert the declarations to QM.
#3
ok, don't have this one...

if i eventually got one, how to proceed?

ty for input
#4
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.
#5
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?
#6
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.
#7
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
#8
Yes.
Macro Macro167
Code:
Copy      Help
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
Code:
Copy      Help
function[c]int byte*ptr size nmemb handle

;...
#9
ok, off coding now
#10
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"
#11
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.
#12
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?
#13
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....
#14
Maybe downloaded 64-bit dll.

Tested, works.
Macro Macro272
Code:
Copy      Help
dll "Q:\Downloads\libFLAC_dynamic.dll"
,FLAC__StreamDecoderInitStatusString
#15
Quote:is this correct?

No.

Macro Flac_Def
Code:
Copy      Help
;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
Code:
Copy      Help
function[c]int byte*ptr size nmemb handle

;your code here

Macro Macro272
Code:
Copy      Help
#compile Flac_Def

FLAC__StreamDecoderInitStatusString ...
;...

FLAC__IOCallbacks iocb
iocb.read=&FLAC__IOCallback_Read
iocb.write=...
;...

FLAC__FunctionThatCallsYourCallbacks ... &iocb ...
;...
#16
yes, wrong compilation, x86 dll works.

thanks for the input, must work to translate dll headers now


Forum Jump:


Users browsing this thread: 1 Guest(s)