[Openal] How to Change/Vary the Speed of Music?

Chris Robinson chris.kcat at gmail.com
Thu May 22 01:42:05 PDT 2008


On Thursday 22 May 2008 12:20:26 am 藺心皓 wrote:
> Hi.
>
> I try to change the speed of music to do some effect like the
> conductor can change the speed of whole band.
> By changing Pitch, it may close to my object -- the speed of music was
> change, but pitch also changed.
> Is  there any method to change the speed but remain orignal pitch?

Unfortunately, it's not that easy. The audio data is just a long series of 
pulses, at various strengths. Going through the pulses faster makes it play 
faster, and gets a higher pitch (and going through it slower gives it a lower 
pitch).

The EFX extension has an effect that can change the pitch independantly of 
playback speed (which could be used along with adjusting the playback speed 
to get a normal pitch at faster/slower speeds), but I wouldn't expect to see 
that effect outside of hardware implementations (neither Creative's software 
implementation, nor OpenAL Soft, provide it). Pitch detection and 
modification is not an easy task to do on a real-time stream without some 
dedicated parallelism.

About the only thing I can think of to do to reasonably get the effect you 
want is to use module files (.mod, .it, .s3m..), or MIDI files with a 
wavetable patchset, and using a converter (like BASS/DUMB or Timidity) to 
convert it into PCM that can be streamed through OpenAL. Unlike PCM data, 
MIDI/MOD files are basically like sheet music.. they simply say what notes 
should be played when and how. With "rendering" it in realtime, it can play 
through the notes slower/faster without altering the pitch of the notes 
themselves (assuming it has controlls to speed it up or slow it down, of 
course).

Hope that helps.



More information about the Openal mailing list