Page 2 of 2

Re: Expose more MiniAudio-Functions

Posted: Thu Oct 10, 2024 9:43 am
by NicTheQuick
Any idea on how to get it to work in Linux? I tried different names on the `ImportC`:
- pbminiaudio
- libpbminiaudio
- libpbminiaudio.a
- -lminiaudio
- libminiaudio
- libminiaudio.a
- libminiaudio.lib
- miniaudio.lib

The linker did not like any of these. :(

Re: Expose more MiniAudio-Functions

Posted: Thu Oct 10, 2024 10:06 am
by idle
Try this and save is as .so
viewtopic.php?p=628837#p628837

Search github for miniaudio and then try to compile it as shared object.

Re: Expose more MiniAudio-Functions

Posted: Thu Oct 10, 2024 10:31 am
by jamirokwai
I also had to set the full path to the .dylib to let PureBasic find it.

Re: Expose more MiniAudio-Functions

Posted: Thu Oct 10, 2024 12:35 pm
by NicTheQuick
idle wrote: Thu Oct 10, 2024 10:06 am Try this and save is as .so
viewtopic.php?p=628837#p628837

Search github for miniaudio and then try to compile it as shared object.
I found an easier way. I just extracted miniaudio.o from libpbminiaudio.a with the ar tool:

Code: Select all

nicolas@Rocky:~/programme/PureBasic_6.12_LTS/purelibraries/linux/libraries$ ar  t libpbminiaudio.a 
miniaudio.o
nicolas@Rocky:~/programme/PureBasic_6.12_LTS/purelibraries/linux/libraries$ ar x libpbminiaudio.a
nicolas@Rocky:~/programme/PureBasic_6.12_LTS/purelibraries/linux/libraries$ file miniaudio.o 
miniaudio.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
I then had to change the ImportC line to the full path to the file:

Code: Select all

ImportC  "/home/nicolas/programme/PureBasic_6.12_LTS/purelibraries/linux/libraries/miniaudio.o"
It compiles now but I get a segmentation fault at line 672, the Delay(1000) and some weird characters in the debug output:
PWÖ

Re: Expose more MiniAudio-Functions

Posted: Thu Oct 10, 2024 7:38 pm
by idle
The problem is the device enum functions aren't in the pb lib version.
it's the same with ma_sound_init_from_file_w in the ma_sound lib I made

Re: Expose more MiniAudio-Functions

Posted: Fri Oct 11, 2024 8:57 am
by NicTheQuick
Oh, I see. I didn't catch that in case you already said that before. :oops:
Maybe I will try it later again by compiling it myself. I found the headers in my linux packages but not the library itself. Weird. :?

Re: Expose more MiniAudio-Functions

Posted: Fri Oct 11, 2024 10:49 am
by idle
Miniaudio is a header only its rebellious c

Re: Expose more MiniAudio-Functions

Posted: Mon Jan 27, 2025 7:16 pm
by AndyMK
I added the ring buffer stuff but nothing works inside the callback. I even tried the lock free ring buffer i use with Portaudio and that also locks up inside the callback. Outside the callback, the ring buffer functions work fine although useless as there is not audio to process. Hoping you geniuses can figure this out.

Code: Select all

ma_pcm_rb_init(format.ma_format, channels.ma_uint32, bufferSizeInFrames.ma_uint32, *pOptionalPreallocatedBuffer, *pAllocationCallbacks, *pRB.ma_pcm_rb)
ma_pcm_rb_acquire_read(*pRB.ma_pcm_rb, *pSizeInFrames, *ppBufferOut)
ma_pcm_rb_commit_read(*pRB.ma_pcm_rb, sizeInFrames.ma_uint32, *pBufferOut)
ma_pcm_rb_acquire_write(*pRB.ma_pcm_rb, *pSizeInFrames, *ppBufferOut)
ma_pcm_rb_commit_write(*pRB.ma_pcm_rb, sizeInFrames.ma_uint32, *pBufferOut)
ma_pcm_rb_available_read(*pRB.ma_pcm_rb)
ma_pcm_rb_available_write(*pRB.ma_pcm_rb)

Global rb.ma_pcm_rb

If ma_pcm_rb_init(#ma_format_f32, 2, 256, #Null, #Null, @rb) <> #MA_SUCCESS
  Debug "Failed to initialize ring buffer"
  End
EndIf

Debug ma_pcm_rb_available_write(@rb) ; Works fine here but not in the callback.