azul3d / engine

Azul3D - A 3D game engine written in Go!
https://azul3d.org
Other
613 stars 52 forks source link

No Examples #80

Open azul3d-bot opened 8 years ago

azul3d-bot commented 8 years ago

Issue by paked Wednesday Dec 03, 2014 at 02:59 GMT Originally opened as https://github.com/azul3d/audio/issues/12


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

azul3d-bot commented 8 years ago

Comment by slimsag Wednesday Dec 03, 2014 at 03:53 GMT


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).

azul3d-bot commented 8 years ago

Comment by paked Wednesday Dec 03, 2014 at 04:15 GMT


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

azul3d-bot commented 8 years ago

Comment by paked Wednesday Dec 03, 2014 at 10:37 GMT


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

azul3d-bot commented 8 years ago

Comment by slimsag Wednesday Dec 03, 2014 at 10:45 GMT


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.

azul3d-bot commented 8 years ago

Comment by metakeule Tuesday Jan 20, 2015 at 10:13 GMT


@paked I made a gist that gets you started.

azul3d-bot commented 8 years ago

Comment by slimsag Tuesday Jan 20, 2015 at 20:35 GMT


@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