Hi all,
Just an update: I've been making more progress on this than I
expected, so we're actually a lot closer to some form of audio for Go.
However, I've also decided to change the binding to expose most of the
C API for OpenAL, and I am still refactoring all of that.
Two Go features I *love* as a result of this experience: Methods for
"basic" types and embedding of structs. You can see why in the
recently added openal/al and openal/alc packages on github.
OpenAL uses uint32 to name things it calls "sources" and "buffers".
Since I can add methods to something like "type Source uint32" dealing
with sources and buffers turns out to be efficient (well, as efficient
as cgo let's you be anyway) since I can save myself allocations *and*
the resulting "classes" make Go OpenAL code look a lot nicer than C
OpenAL code.
OpenAL also has things called "devices" and an addition called
"capture devices" to record audio that was added later. Since the C
API returns pointers for those, I have to wrap them into their own
*Device and *CaptureDevice things (otherwise the Go restriction
regarding implicit assignments is violated). So that's a drawback, but
it's minor. What's a major advantage is that I can define
CaptureDevice as follows:
type CaptureDevice struct {
Device;
}
Now all the "shared" operations work fine, *and* I get to add the
capture-specific methods in a way that totally avoids any possibility
for the programmer to call them on a non-capture device by accident.
It all worked out surprisingly well so far, making me a happy Go
hacker regardless of the brace syntax. :-D