Monday, November 16, 2009

OpenAL pitch

I've been working with NicQ on sound files for the piston engined airplanes, and we've found out some interesting things about the way OpenAL handles sound pitch. First, the API wants octaves as a pitch input, with "1" representing the unmodified sound file. Therefore, a pitch input of 0.5 means one octave lower, and a pitch input of 2.0 means one octave higher. That means that the pitch value needs to be: log2(input/ref) + 1.0, where "ref" is a reference value associated with the pitch of the unmodified sound file, and "input" is a flightgear property value to be compared with "ref". For example, if you have a sound file which represents the engine sound at 1000 rpm, then "ref" is 1000, and "input" is the property "engines/engine[n]/rpm".

One other thing, OpenAL appears to limit the pitch modification to +/- one octave. This means that to create sound for an rpm range of 500-3000 you would need two sounds to cover the range.

1 comment:

  1. I just built SimGear/FlightGear as of 1 Nov code, and I see that the pitch is not limited any more (linux, VIA8237, ALSA). I can use one sound to cover the whole rpm range.

    Also, thanks for NicQ for bringing to my attention that the pitch setting is not as complicated as I thought. It seems OpenAL is really looking for a simple ratio of (actual/reference), so for an engine using a sound file optimized to represent 1500 rpm, you give OpenAL the ratio (rpm/1500). At least that's the theory I'm currently going with.