Expose more MiniAudio-Functions

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
NicTheQuick
Addict
Addict
Posts: 1504
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Expose more MiniAudio-Functions

Post 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. :(
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
idle
Always Here
Always Here
Posts: 5836
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Expose more MiniAudio-Functions

Post 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.
jamirokwai
Enthusiast
Enthusiast
Posts: 796
Joined: Tue May 20, 2008 2:12 am
Location: Cologne, Germany
Contact:

Re: Expose more MiniAudio-Functions

Post by jamirokwai »

I also had to set the full path to the .dylib to let PureBasic find it.
Regards,
JamiroKwai
User avatar
NicTheQuick
Addict
Addict
Posts: 1504
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Expose more MiniAudio-Functions

Post 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Ö
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
idle
Always Here
Always Here
Posts: 5836
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Expose more MiniAudio-Functions

Post 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
User avatar
NicTheQuick
Addict
Addict
Posts: 1504
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Expose more MiniAudio-Functions

Post 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. :?
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
idle
Always Here
Always Here
Posts: 5836
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Expose more MiniAudio-Functions

Post by idle »

Miniaudio is a header only its rebellious c
AndyMK
Enthusiast
Enthusiast
Posts: 582
Joined: Wed Jul 12, 2006 4:38 pm
Location: UK

Re: Expose more MiniAudio-Functions

Post 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.
Post Reply