Page 1 of 1

Audio out from Windows.

Posted: Sat Feb 24, 2024 9:48 pm
by matalog
I want to make a little synth to mess about with to run on windows.

For now I will generate triangle, sine and waveforms.

To get the audio to speakers, can I simply stream them to the DAC, or do I have to do that via an actual playback of an audio file?

I will be making sounds with the program, live and want it to be as responsive as possible, can I output directly to the speakers/audiohardware without writing it to a file first?

What do you think the best way to go about this would be?

Re: Audio out from Windows.

Posted: Sat Feb 24, 2024 9:56 pm
by infratec

Re: Audio out from Windows.

Posted: Sat Feb 24, 2024 10:17 pm
by idle
PB now has miniaudio built in
you can access it in in c backend but you probably don't need the dll anymore just import miniaudio.lib but you would need likely need the tool pbcex to include the header
https://github.com/idle-PB/pbcex/tree/m ... /miniaudio

There is also portaudio in pbcex as well which is easier to use in my opinion

or you could look at the soundserver code in ymplayer
you could also look at https://github.com/idle-PB/YMPlayer

both miniaudio and port audio allow duplex record and playback this it pretty cool as you can modify recorded audio and mix it with synth if you like.

I've yet to dig in to the functionality Freds exposed on PB build for miniaudio so maybe we can do it natively now without messing around with inline c ...

Re: Audio out from Windows.

Posted: Sat Feb 24, 2024 10:51 pm
by infratec
Oh, I forgot ... bass is not free.

But you can use portaudio, It has more possibiities than miniaudio.
Here is wrapper abvailable for libportaudio_2.dll

Re: Audio out from Windows.

Posted: Sat Feb 24, 2024 11:37 pm
by idle
infratec wrote: Sat Feb 24, 2024 10:51 pm Oh, I forgot ... bass is not free.

But you can use portaudio, It has more possibiities than miniaudio.
Here is wrapper abvailable for libportaudio_2.dll
I agree portaudio is the easiest and it will be easy to build statically now.
I've just been trying miniaudio natively but it returns a struct for ma_device_config_init() so need to add it as a function
but if I can get it working it will be native.

Re: Audio out from Windows.

Posted: Mon Feb 26, 2024 10:08 am
by matalog
Thanks guys. I'll see if I can get my head around Portaudio.

Re: Audio out from Windows.

Posted: Mon Feb 26, 2024 10:17 am
by idle
Port audio is way easier to use in my opinion but having said that I've stuffed around for half a day porting what's needed to do duplex in miniaudio only to discover that the version I had built was older than the current version and well 600 lines later I'm 97% there, even though it still does nothing apart from copy the input to the output. I dread to think how much more I need to do to get it to get it to record mic or line in and play it back. port audio is way easier to use.

Re: Audio out from Windows.

Posted: Mon Feb 26, 2024 11:12 am
by the.weavster
Something else to consider - PB 6.10 will have the new WebViewGadget which gives you the option of using the Web Audio API

Re: Audio out from Windows.

Posted: Mon Feb 26, 2024 11:36 am
by idle
the.weavster wrote: Mon Feb 26, 2024 11:12 am Something else to consider - PB 6.10 will have the new WebViewGadget which gives you the option of using the Web Audio API
oh come on, that's just one more hoop to jump through! :lol:

Re: Audio out from Windows.

Posted: Mon Feb 26, 2024 3:38 pm
by the.weavster
idle wrote: Mon Feb 26, 2024 11:36 am oh come on, that's just one more hoop to jump through! :lol:
Or is it one fewer compared to using a third-party library 🤔

Here's a nice tutorial to help get up and running 😉

Re: Audio out from Windows.

Posted: Tue Feb 27, 2024 12:27 am
by idle
the.weavster wrote: Mon Feb 26, 2024 3:38 pm
idle wrote: Mon Feb 26, 2024 11:36 am oh come on, that's just one more hoop to jump through! :lol:
Or is it one fewer compared to using a third-party library 🤔

Here's a nice tutorial to help get up and running 😉
could be quite useful :D

Apart from the pain of importing headers we can use miniaudio natively just need to import lots of structures.
this doesn't do anything as such and there's a lot more to import but it's a start, collaborative effort with infratec

https://www.purebasic.fr/english/viewto ... 23#p616623