Bat in the Dark
256-fall-2009: HW4
Roy Fejgin
This compressed tar file contains all the files needed to build and run this assignment.
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'.
USAGE:
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.
Example:
bat -p -h cmn16.stanford.edu
Another Example:
bat -b
This is a networked, audio-based baseball game.
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.
The program decides if it's the ball was it or it was a strike and gives and appropriate audio and visual feedback.
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:
the source velocity parameter has a different effect in Windows and Linux.
when a moving sound source goes from in front of the listener to behind them, the audio effect sounds unnatural. Because of this I had to limit the baseball to live in front of the batter. That's too bad because OpenAl actually does generate a pretty nice doppler effect that I could have used if it were not for this problem.