Monthly Archives: April 2013

Final projects are most inconvenient.

Basically, my bandwidth has been exceeded, and this work can be extended into the summer, while finals are due in two weeks. It’s that whole urgent vs. important thing.

Anyway, I did find an interesting piece on Touch Mechanics: Haptic Technology and Perceptual Computing that got written up over at Intel Software. And to make this post look more interesting, I’m going to link in the TedEd talk that most of the article is based on, so you don’t even have to click the link:

Who says you can’t procrastinate productively?

Standard programming mysteries.

I hate it when I’m starting off with an API and the tutorials don’t work.

I was working with the LWJGL OpenAl examples described in earlier posts, and could not get the audio files in the examples to open. The file was there, it could be converted to an InputStream, but when I tried creating a LWJGL WaveData object, the underlying java audio code would throw an error and I’d get a null object.

So since I’m now trying to figure out what gives with the javax.sound.sampled.* system, I might as well see if I can do what I want to do here. So off we go to the Internet once more, looking for examples that work.

The first thing I found was the Oracle Java Sound API documents, which are huge, loaded with theory and very little code. I’m not complaining really, because they look like they will be really useful when I have a little bit of code working. But there needs to be a “Hello, World”.

Which showed up after a bit of searching. There is a website JSResources, put together by two German (?) developers; Florian Bomers and Matthias Pfisterer. It is loaded with examples that seem to work. I’ve just gotten one of their simple examples running with a minimum of fuss. (Here’s the (slightly) modified code).  Since this is straight sound library, we know that we can run all the channels. Now we just need to get from here to there.

Multichannel sound

It was looking like Java3D only handled Mono and stereo, but I just found com.sun.j3d.audioengines.javasound .JavaSoundMixer, It also uses javax.media.j3d.PhysicalEnvironment, which looks like it has built-in head tracking.

Darn it – got my hopes up too soon: “While the sound image created for final output to the playback system is either only mono or stereo, most device driver implementations will mix the left and right image signals generated for each rendered sound source before outputting the final playback image. Each sound source will use N input channels of this internal mixer. Each implemented Java3D audio device driver will have its own limitations and driver-specific characteristics. These include channel availability and usage (during rendering). Methods for querying these device-driver specific characteristics are provided.” (from javax.media.j3d.AudioDevice)

OK, I’m not ready to give up on Java yet. According to this bug report, multichannel support has been working for a while. My two options at this point are OpenAl through the LWJGL folks, and the javax.sound.sampled library.

Because I’d like to show graphically where the sounds are coming from, I’m going to try the LWJGL approach first.

Looks like multichannel support is in OpenAl, but will require care: “The multi-channel extension provides a mechanism to play multi-channel data via OpenAL. A variety of formats are supported. Multi-channel buffers can be attached or queued on a source. Note that when using the “Generic Software” device, the multi-channel buffers are mixed down to a stereo output. On a hardware device (such as the “Generic Hardware” device or a native device), each channel of a buffer requires a hardware voice. So, for example playing a buffer using the AL_FORMAT_51CHN16 format will require 6 free hardware voices. If the hardware resources are unavailable, the call to alSourceQueueBuffers or alSourcei will fail.”


And then there’s Javascript….

It turns out that there is a good deal of work going on in bringing multichannel audio to your browser. Since this *is* the future, it’s not a thing that I want to overlook, but I don’t want to put all that much time into it right now either. So here are some links: