xioxin / lab_sound_flutter

a wrapper for LabSound(graph-based audio engine)
Other
16 stars 3 forks source link

General Enquiry about Miniaudio #3

Closed AseemWangoo closed 3 years ago

AseemWangoo commented 3 years ago

Hello @xioxin

Hope you are doing well. I recently started to play around with ffigen, found it very interesting. I just know the basics of C, not in depth. Next, i decided to port the library https://miniaud.io/

I was able to generate the bindings, but when I started to use it, it gave me an error. Probably, I think I need to create a wrapper over the generated bindings.

But, I am finding it difficult (although not impossible :p), started searching over the net and found your repository has a tag of miniaudio. I wanted to know how are you using miniaudio in your project.

I didn't know how to connect with you, hence filing an issue. In case you are interested to connect, on git or any other platform, kindly let me know.....

xioxin commented 3 years ago

My native language is not English and I use translation software to communicate. Please forgive me if there are translation errors.

If it is convenient, you can communicate in this Issues.

This project is based on LabSound. labSound uses miniaudio for the backend audio. i don't use miniaudio directly.

Can I see the code and error messages if I can?

I will try to help you as much as possible.

AseemWangoo commented 3 years ago

Language should not be a barrier and your translator is doing very good job :)

I understand now, that LabSound uses miniaudio internally.

Project link: https://drive.google.com/file/d/1EbQ_Fx1vPthi0ZXC5cNeJuFONS3YCS60/view?usp=sharing

  1. This is a flutter macos project.
  2. flutter run -d macos
  3. Click on "Choose a Wav File" button

In my case, I'm failing to call ma_decoder_init_file

The C code and libraries are in the audio folder. To test the C code

  1. Go to audio directory and run ./audio_test sample.wav

Inside the audio directory there is the header file and playback.c

This playback.c calls ma_decoder_init_file as the first function, hence I tried calling it from dart.

Im not sure in case ma_decoder_init_file is the correct function to be called.

xioxin commented 3 years ago
[WARNING]: Removed All Struct Members from ma_decoder(ma_decoder), struct member has an unsupported type.

ffigen did not parse ma_decoder correctly. It seems that ffi does not currently support including functions in structs

Wrap new methods and structs to avoid using unsupported types. For asynchronous events this can be solved using SendPort. https://github.com/dart-lang/sdk/blob/master/samples/ffi/async/sample_async_callback.dart

Create a new ma_decoder_init_file wrapper to return a pointer to the ma_decoder. Then create a clean struct to return the information. Create a bind listener method that listens for events by passing in a pointer and SendPort.

AseemWangoo commented 3 years ago

Thanks for taking time to see the code. I will follow your advice. Closing this issue.

If needed, I will continue this thread (in comment mode only)