Surround-sound IF

In my adventures of improving Frotz, I’ve come to the part where I mix OGG or MOD output with AIFF. Although I haven’t seen any rules outlining this, it seems that all Z-machine interpreters following the Blorb spec will allow an OGG or MOD file to be played, but not both at once. One AIFF may be played at once. An OGG/MOD may be mixed with an AIFF. So I figured I’d follow this convention. Something that’s bothering me is the possibility that someone will come up with a game that uses samples or OGGs that contain more than two channels; that is surround-sound. As far as I can tell, Zcode has no capability to send arbitrary hints to the interpreter. That could allow for the interpreter to position samples somewhere within a surround-sound environment. I know that Glulx does do hints, but I’m not sure if anyone has considered surround-sound.

What this boils down to is that I’m concerned that someone will be crazy enough to write a game that includes AIFFs containing surround-sound channels. If Frotz encounters such a thing, I want to make sure that I can cleanly mix that surround-sound clip with mono and stereo. Are any other interpreters or VMs aware of surround-sound? Should I just accept only mono or stereo?

No, it’s safe to say nobody has. :slight_smile:

This is an area where the game file doesn’t really have a say. The game says “start playing Ogg #3”, that’s all. If that’s a multi-channel file, the interpreter will either be able to deal with it or it won’t.

I’d expect that a modern Ogg-playing library would make an honest go of it, and a modern OS will have a notion of multichannel sound hardware… so if all those pieces are configured correctly, it’ll work. Whether this is over-optimistic or not, I have no idea. :slight_smile:

What’s bugging me most about all this is the issue of mixing. I brought up the topic on the linux-audio-dev mailing list and was told that I need to be careful about mapping mono or stereo to surround-sound and it quickly got very complicated. If someone does try to use surround-sound for any IF VM, I hope that said someone will take care to make sure all sounds have the same channels or else the mixing will sound weird or not make sense. For instance, if the background music is in surround-sound, a distant gunshot should not come from all the speakers. I’d rather have poorly-prepared audio play rather than have Frotz refuse to play it.

Libvorbis simply decodes OGG files and returns the audio data. How it gets to the speakers is another thing. After I get the mixing done, I call ao_play() on the buffer and the rest happens automagically. I chose libao because it’s lightweight and portable to all sorts of flavors of Unix, both common and obscure. I deliberately didn’t choose SDL_mixer because I don’t want to pull in graphical dependencies for a text-only application. When I fold in an graphical version of Frotz to my codebase, I might go back to SDL. It was done earlier with sfrotz.