Car engine
Blitz3D Forums/Blitz3D Programming/Car engine
| ||
Can anyone please tell me how program a car engine sound that changes according to your speed (like on f-zero or something) where if your car is still, theres just a smooth steady engine sound, but as your start to accelerate, it changes according to your speed. Thanks for any help |
| ||
The first thing I'd try is making a base engine sound loop and then alter it's pitch (SoundPitch/ChannelPitch commands) according to engine revs. |
| ||
Hmmm, thanks Big, i'll give it a try :) Cheers |
| ||
I use something like this ( need refinement ) but does it's job.Gear = Floor( LIMIT( CMspeedZ , 0 , 10.0 ) / v\GearRatio ) Diff# = Abs( CMspeedZ - Gear * v\GearRatio ) ChannelPitch v\CHANNELengine , ( 20.0 + Gear * 5.0 + Diff * 10.0 ) * v\Enginepitch ChannelVolume v\CHANNELengine , ( 1.5 + v\SOUNDvol * Abs(Throttle) * .5 ) * .5 Where CMspeedZ is the cars forward speed Throttle is 1 if accelerator pressed, -1 if breaking. GearRatio is just a number to determine how many gears you can go through based on the top speed. (e.g. TopSpeed 10, GearRatio = 3, => 4 gears. Other vars should be self explanitory. Just a case of playing with them. Stevie |
| ||
Cheers Stevie, it may take me a while to figure all that out properly :p but i will certainly give it a try. Cheers man |
| ||
Oh yeah, ChannelVolume as well - forgot about that one. :) |
| ||
Make sure the multipier for Diff is greater than Gear for best effect ... Oh and the LIMIT function is just ... Function LIMIT#( q# , low# , hi# ) If q < low q = low If q > hi q = hi Return q End Function |
| ||
The 'big boys' way of doing it is pretty much like the above except there are several samples of the same car engine: 1) Idle. 2) Low revs. 3) medium revs. 4) high revs. 5) maximum revs. When you want to output the engine sound which is in-between any of the samples, you layer the 2 adjacent samples over each other. Sounds good, it's just getting the original samples which can be a challenge. |