Audio out from Windows.

Just starting out? Need help? Post your questions and find answers here.
User avatar
matalog
Enthusiast
Enthusiast
Posts: 305
Joined: Tue Sep 05, 2017 10:07 am

Audio out from Windows.

Post 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?
infratec
Always Here
Always Here
Posts: 7664
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Audio out from Windows.

Post by infratec »

User avatar
idle
Always Here
Always Here
Posts: 6035
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Audio out from Windows.

Post 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 ...
infratec
Always Here
Always Here
Posts: 7664
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Audio out from Windows.

Post 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
User avatar
idle
Always Here
Always Here
Posts: 6035
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Audio out from Windows.

Post 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.
User avatar
matalog
Enthusiast
Enthusiast
Posts: 305
Joined: Tue Sep 05, 2017 10:07 am

Re: Audio out from Windows.

Post by matalog »

Thanks guys. I'll see if I can get my head around Portaudio.
User avatar
idle
Always Here
Always Here
Posts: 6035
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Audio out from Windows.

Post 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.
User avatar
the.weavster
Addict
Addict
Posts: 1581
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Re: Audio out from Windows.

Post 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
User avatar
idle
Always Here
Always Here
Posts: 6035
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Audio out from Windows.

Post 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:
User avatar
the.weavster
Addict
Addict
Posts: 1581
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Re: Audio out from Windows.

Post 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 😉
User avatar
idle
Always Here
Always Here
Posts: 6035
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Audio out from Windows.

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