Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Examples #12

Open
paked opened this issue Dec 3, 2014 · 6 comments
Open

No Examples #12

paked opened this issue Dec 3, 2014 · 6 comments

Comments

@paked
Copy link

paked commented Dec 3, 2014

Hey,

I've recently found your libraries - specifically the audio one - interesting, and am looking to (at least temporarily) integrate into my own game engine (https://github.com/paked/engi).

I noticed the lack of tutorials and/or sample code relating to this package (and its surrounding ones). I am more than happy to write something up, I just need information on how to do it.

Thanks for your work

@slimsag
Copy link
Contributor

slimsag commented Dec 3, 2014

Hi there! That's very cool to know! Great to see more doing game development in Go.

I noticed the lack of tutorials and/or sample code relating to this package (and its surrounding ones).

The tests for the audio/wav package would provide you with the best, yet perhaps somewhat convoluted, starting point as of right now.

I am more than happy to write something up, I just need information on how to do it.

Overview

The audio package azul3d.org/audio.v1 is extremely similar to Go's image package, except it works on audio data instead of image data.

Then there are decoders, the wav decoder azul3d.org/audio/wav.v1 and the in-development FLAC decoder azul3d.org/audio/flac.v0.

All of this thus far just handles decoding WAV and FLAC files into raw PCM audio data. You would then need to send that raw audio data through some system API for playback.

Easy Playback

Primarily I think the biggest problem you will run into is that there is not a easy-to-use playback package yet. This means you will have to hand off the data to a low-level API, e.g. OpenAL (via azul3d.org/native/al.v1, for instance).

I do plan to have a package for this in version two, but my time is rather constrained right now while I add mobile and web support to the graphics core).

@paked
Copy link
Author

paked commented Dec 3, 2014

Awesome, I'll take a crack at it tonight and probably get some feedback/questions ready for you tonight. Thanks for your help

@paked
Copy link
Author

paked commented Dec 3, 2014

Ok got a question, once I have a buffer how do I go about playback though the OpenAL bindings?

@slimsag
Copy link
Contributor

slimsag commented Dec 3, 2014

You'd basically have to translate a OpenAL tutorial (Google is your friend) into the Go equivalent using those bindings. The audio buffer can be passed to OpenAL via the unsafe package and taking a pointer to the sample slice.

As mentioned though, it's not an easy / trivial thing to do. An easy-to-use playback package will come in the future, and will be built atop those OpenAL bindings most likely. I don't have any examples of audio playback anywhere yet, sorry.

@metakeule
Copy link

@paked I made a gist that gets you started.

@slimsag
Copy link
Contributor

slimsag commented Jan 20, 2015

@metakeule thank you for sharing =) I think he wants an example of playing audio, however.

@nwidger's nintengo recent NES emulator using azul3d.org/native/al would be a good reference: https://github.com/nwidger/nintengo/blob/master/nes/azul3d_audio.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants