Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use native C libraries from Vala?

Tags:

vala

lame

I'm building a frontend for a LAME encoder in order to do a proof-of-concept in Gtk/Vala.

I've installed libmp3lame-dev and would like to simply encode a WAV file using a few given encoding parameters and graphically display the progress using a Gtk progress bar.

I can definitely figure out how to do that, but I'm not sure how to import libmp3lame into my Vala files and interface with the library.

like image 432
Naftuli Kay Avatar asked Oct 21 '25 15:10

Naftuli Kay


1 Answers

Yes, but you need to use a VAPI to explain how to bind the C library to Vala. The easy way to do this is using GObject Introspection to generate the bindings automatically, but since LAME doesn't use GObject the only option is to write them by hand. There is some documentation of the process, and it tends to be much easier than writing wrappers for dealing with C in other languages, but it can still be somewhat intimidating for beginners—you should consider dropping by the #vala channel on GIMPnet to get help as you're developing the bindings.

That said, Vala includes bindings for GStreamer, which does include an element for using LAME. Were I in your shoes I would carefully consider using it before creating bindings for libmp3lame.

like image 148
nemequ Avatar answered Oct 24 '25 08:10

nemequ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!