Audio pitch with SDL

Hi

I’m currently writing a player for the SMUS format (an old IFF-based format
developed by EA in 1987) to support music in an old game. I have the
sample/track parser working correctly, and I’ve now reached the stage where I
need to reproduce the music using SDL’s audio features.

I am, however, a bit confused with the theory behind audio mixing/playback and
wonder if someone could be so kind as to point me in the right direction. I’m
always happy to RTFM if there is a manual. :slight_smile:

The music consists of a few separate tracks each playing different samples at
different pitches and lengths simultaneously. I’ve knocked up a basic mixer
using SDL_Mixer to mix each sound sample together, so I can just drop in
sample data with a given length and it’ll be played. This is where I start to
get a little confused.

The SDL_AudioSpec passed to SDL_OpenAudio needs a frequency to be passed to
it. Does this fix all sound I play to the same pitch? I can happily reproduce
the samples at their sampled rate (which is mostly around 8192Hz, with a few
samples around 4096Hz), but how do I go about altering their pitch to
reproduce the music?

I’ve been playing around (unsuccessfully) using SDL_AudioConvert to convert
the sample from 8192Hz to a frequency I specify, but this gives rather odd
results (either very low pitched sounds, or very high on a few frequencies).
Is this the approach I’m meant to be taking, or am I missing something obvious?–
Cheers,
Jay

http://www.evilrealms.net/ - Systems Administrator & Developer
http://www.imperial.ac.uk/ - 3rd year CS student