Bat in the Dark

256-fall-2009: HW4

Roy Fejgin

Getting the project

This compressed tar file contains all the files needed to build and run this assignment.

Build instructions

The project builds for JACK/Linux.

To build just type 'make'.

To clean all temporary files and executables type 'make clean'.

To execute, run 'sndgaze'.


bat [ROLE] [-h HOST]

ROLE: "-p" to play pitcher, or "-b" for batter.

HOST: Name of computer to connect to. This parameter is only required when playing pitcher.


bat -p -h

Another Example:

bat -b


What is this program?

This is a networked, audio-based baseball game.

How does it work?

To play, two players on two computers are needed. One person plays the batter and the is the pitcher.

Game Sequence:

- The pitcher pitches in a certain direction by mouse-clicking the mouse on one of five squares displayed on the screen.

- The pitch's coordinates are transmitted using OSC over the network to the batter's computer.

- On the batter's computer, the pitch is sonified in 3D. The batter can hear a “ball” progressing from the pitcher towards him, and also how far to the left/right the pitch went.

- The batter clicks on the square where he thinks the pitch went. He must react within a certain time.

3D Audio

For rendering the 3D audio I used OpenAL.

The OpenAL objects I used were a listener, a source and some buffers.

The source represents the the ball, and the listener represents the batter. The program keeps updating the source's (x,y,z) position to represent its movement through the air, and OpenAL automatically adjusts the source's panning and attenuation according to the direction and distance from the listener.


I was hoping to get a bit more out of OpenAL. For example, I wanted to get a sense of up/down in the audio (which would have allowed the pitcher more directions to throw to). However, changing the Y axis of the sound source didn't seem to have any effect one the audio. As far as I understand, the interpretation of that axis depends on the underlying hardware and OS. Specifically, Creative's cards are supposed to be able to render the 3D more faithfully, and I've read Apple's 3D mixer might work as well. Other oddities I ran into were: