Audio libraries in Go

2,921 views
Skip to first unread message

Tyler Compton

unread,
Feb 23, 2014, 5:58:00 PM2/23/14
to golan...@googlegroups.com
I'm curious as to what the recommended audio libraries/bindings are for Go right now. I would want to load some kind of audio file and play it, like you might expect, but I'm having trouble finding a library suitable for helping me do that.

I'm aware of the portaudio bindings, which seem to work fine, but then comes the issue of how I would load an audio file. I've found libraries that are capable of loading various audio files, but none that appear to be complete enough to use seriously. Am I missing one?

If there's a Go library out there that's capable of reading an audio file AND playing it, that would excellent, but I may be getting a bit greedy at that point!

Matthew Kane

unread,
Feb 23, 2014, 6:02:12 PM2/23/14
to Tyler Compton, golang-nuts

There is a libsndfile binding: http://github.com/mkb218/gosndfile

Tying this to portaudio should be relatively easy.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Tyler Compton

unread,
Feb 23, 2014, 7:02:21 PM2/23/14
to golan...@googlegroups.com, Tyler Compton
Thank you for the suggestion![ There aren't by any chance any other similar libraries that play nicer with Windows, are there?

Aaron Blohowiak

unread,
Feb 23, 2014, 9:27:23 PM2/23/14
to golan...@googlegroups.com, Tyler Compton
Do you have control of the audio source? If so, export as a 16-bit WAV and ignore the first 44 bytes. then each sample is each 16 bits (little endian!), with the left and right channels alternating (if stereo), 

This is not RIFF-compliant and locks you into 16-bit stereo files but it is trivial to get started.

Matthew Kane

unread,
Feb 23, 2014, 10:02:17 PM2/23/14
to Tyler Compton, golang-nuts
Well, sox[1] supports more formats, and may be more Windows friendly.
Calling libsox's file support functions with cgo should be not too
tricky if you aren't trying to write effect chains. (This is all
gosndfile is, really)

You could also just install sox and use os/exec to run it and read its
standard output.

[1]: http://sox.sourceforge.net/
--
matt kane
twitter: the_real_mkb / nynexrepublic
http://hydrogenproject.com

Tyler Compton

unread,
Feb 24, 2014, 12:34:41 AM2/24/14
to golan...@googlegroups.com, Tyler Compton
sox looks like a really helpful resource, but I can't for the life of me find anything, source or precompiled, for libsox. There's this page here, but no download link.

I did find a binding someone already did called go-sox, though, for the record.

Gyepi SAM

unread,
Feb 24, 2014, 1:14:29 AM2/24/14
to Tyler Compton, golan...@googlegroups.com
On Sun, Feb 23, 2014 at 09:34:41PM -0800, Tyler Compton wrote:
> sox looks like a really helpful resource, but I can't for the life of me
> find anything, source or precompiled, for libsox. There's this page here<http://sox.sourceforge.net/libsox.html>,
> but no download link.

http://sourceforge.net/projects/sox/files/sox/

-Gyepi

Tyler Compton

unread,
Feb 24, 2014, 1:19:30 AM2/24/14
to golan...@googlegroups.com, Tyler Compton, self-...@gyepi.com
I see, I thought that was just the source for the tools themselves. Thank you!

Ernest Micklei

unread,
Feb 24, 2014, 7:37:34 AM2/24/14
to golan...@googlegroups.com
Considered Open-AL? and use bindings such as https://github.com/vova616/go-openal

Benedict Apuna

unread,
Feb 25, 2014, 10:27:31 AM2/25/14
to golan...@googlegroups.com
I was trying out the bindings for SFML2 found here just the other day and was able to load and play wav and ogg files using the sample code found here.

Tyler Compton

unread,
Feb 28, 2014, 1:41:33 AM2/28/14
to golan...@googlegroups.com
Thanks to everyone for all the suggestions! I ended up just loading a WAV file myself (which was surprisingly simple) and using OpenAL to play it. In the future, I'll probably need to use a compressed format like OGG Vorbis, so I'll refer back to this post for some guidance. Thanks again!

Jsor

unread,
Feb 28, 2014, 1:58:35 AM2/28/14
to golan...@googlegroups.com
I have a wrapper of the most current version of OpenAL-Soft (the only remaining, maintained OpenAL implementation I know of) with a functional wav file loader. I could open source it if it would be helpful. I had trouble getting the other wrappers to work because they relied on alh which is deprecated and hard to find nowadays (and isn't maintained regardless).
Reply all
Reply to author
Forward
0 new messages