PDA

View Full Version : crossover...



tux
14-11-2004, 08:55 PM
ive started my sound system and have a simple engine simulation running (can be heard here (http://www.vadertrophy.com/files/racer/enginerevs.mp3) ). at the moment its using 2 samples 1 for idle and 1 for high revs, but i think it will sound better with 3 samples.

im having trouble figuring out the maths to make sample 1 get quieter as the revs increase (2500 + ), sample 2 gets louder towards middle revs (lets say 5000) and quieter as it goes past those revs as sample 3 gets louder as it gets to full revs (10,000)

anyone understand? :D

noeska
14-11-2004, 10:13 PM
Could not you record a whole sequence for a real engine and play the according part when needed?

tux
14-11-2004, 10:55 PM
dont have access to real engines :( but ive done it! ill post source code on how i did it (and a screenshot) when ive finished tidying up :)

i always jump into things over thinking everything ;)

tux
15-11-2004, 12:50 AM
the maths wasnt bad at all in the end, i just needed to think harder :)

here is how to do a cross over with 3 (easy to put more in ) samples

// sample 1
if iEngineRPM <= iSample1RPM then
sSample1Volume := iEngineRPM;// iSample1RPM + (iEngineRPM - iSample1RPM);

if iEngineRPM > iSample1RPM then
sSample1Volume := iSample1RPM - (iEngineRPM - iSample1RPM);


// sample 2
if (iEngineRPM <= iSample2RPM)
and (iEngineRPM - iSample2RPM < (iSample2RPM shr 1))
and (iEngineRPM - (iSample1RPM shr 1) > 0) then
sSample2Volume := (iSample2RPM + (iEngineRPM - iSample2RPM) - (iSample1RPM shr 1));

if (iEngineRPM > iSample2RPM) and (iEngineRPM - (iSample1RPM shr 1) > 0) then
sSample2Volume := (iSample2RPM - (iEngineRPM - iSample2RPM) - (iSample1RPM shr 1));


// sample 3
if (iEngineRPM <= iSample3RPM)
and (iEngineRPM - iSample3RPM < (iSample3RPM shr 1))
and (iEngineRPM - (iSample2RPM shr 1) > 0) then
sSample3Volume := (iSample3RPM + (iEngineRPM - iSample3RPM) - (iSample2RPM shr 1));

if (iEngineRPM > iSample3RPM) and (iEngineRPM - (iSample2RPM shr 1) > 0) then
sSample3Volume := (iSample3RPM - (iEngineRPM - iSample3RPM) - (iSample2RPM shr 1));


// updating
AlSourcef(source1, AL_GAIN, sSample1Volume / (iMaxRPM shr 1));
AlSourcef(source2, AL_GAIN, sSample2Volume / (iMaxRPM shr 1));
AlSourcef(source3, AL_GAIN, sSample3Volume / (iMaxRPM shr 1));

AlSourcef ( source1, AL_PITCH, iEngineRPM / (iMaxRPM shr 1));
AlSourcef ( source2, AL_PITCH, iEngineRPM / (iMaxRPM shr 1));
AlSourcef ( source3, AL_PITCH, iEngineRPM / (iMaxRPM shr 1));

that sounds much much better then the last method i was using :)