Playing sound in GoLang

Is this possible to play a track in Go (especially on macOS and without “afplay” command execution)?

What level of control do you need? Why is afplay insufficient?

Usually you either have a command like that. Or an API to play files or chunks of audio, high level solution. Or a streaming API to do things, low level.

High level I don’t know anything on macOS, but for streaming audio there is stackoverflow code.
Portaudio gives you best platform independent solution for streaming. I guess that would be also your easiest way to stream audio, you need just to compile the shared library and get to learn the API.

If you’re streaming audio, you usually have the audio like the streaming API wants it (Portaudio lets you choose the sample data type of your stream, fortunately). Or you have compressed files/data that you need to decode first. Then it involves another library like ogg vorbis or flac.

Maybe start from here, doesn’t look wrong to me:

1 Like