Creating a C Module Help

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
Posts: 1
Joined: Sun Oct 03, 2021 5:55 pm

Creating a C Module Help

Post by GEek42 » Tue Oct 12, 2021 8:07 pm

I'm looking to see if I can either get some pointers to more advanced documentation of the C side of building an external module, or get some help with what I'm trying to do.

I've reviewed and understand to some level the instructions for creating a standalone compiled C module that I can import, and testing the example code works fine, so that part I'm good with. My challenge is that my C understanding is limited(mostly easy stuff, or simplified C like Arduino), I don't really understand the intermediate and advanced pieces enough to make it work. I don't mind learning, but I've not yet gotten where I need to be.

What I'd like to do is try building a module based on libMad(designed to do the decoding using 32bit integer math) for MP3 decoding on devices that might support it(in my case, ESP32, which can decode MP3 for sure, but I see no reason not to make it generic enough to work on any device). Optimally I would like to have the module just provide a single object that can be passed an open file object and feed back bytes decoded(form there I can send them wherever I need, like my I2S device), it would be nice to have some properties like sample rate and bit depth available to setup output devices. The example minimad.c decoder in the code base looks like a good example of what I need.

But, as I said, I don't understand C enough to translate the setup into a module that we can call from python easily.

Anyone up for helping me through this one? Open source of course. Even some pointers to code that might be similar may get me on my feet faster then poking around like I am now.

Post Reply