# Car audio, gear shifting and RPM, How?

Discussion in 'Scripting' started by SamohtVII, Apr 18, 2019.

1. ### SamohtVII

Joined:
Jun 30, 2014
Posts:
193
I have a basic car controller (here: http://dotteam.pro/pdf/Car_Script_basic.pdf) and i need to add some audio into it. Can anyone explain how car audio works in terms of rpm, pitch, gear changing etc?

I understand higher rpm = higher pitch?

And how, with a basic car controller, do I simulate a gear change and in turn audio?

I have the basic idea of
Code (CSharp):
1. gear = 1
2. if(speed > 20 && speed < 50) gear = 2
3. else if (speed > 50 && speed < 70) gear = 3
4. etc.
5.
Then based on gear and where the speed is between min and max set the pitch.
So if we are at 30kph we are in gear 2's pitch range and we are at about 20% of gear 2's total (Between 20 and 50).

If I am way off i'd love some explanation and correction.

Thanks

2. ### SparrowsNest

Joined:
Apr 6, 2017
Posts:
1,860
the pitch should be relative to the RPM of the engine, not the speed, the sound you get from speed is from the tire friction to whatever its driving on and noise from air turbulence.

I'm not sure what do you mean "how car audio works", but yes,
is basically what applies.

3. ### csofranz

Joined:
Apr 29, 2017
Posts:
784
I agree with Sparrows' and would add the following (Sparrow mentioned ot as an aside):

1. the engine sound (pitch) is a function of rpm - higher rpm --> higher pitch. This simulates the Audio generated from the engine
2. Add a rumbling/white noise sound source that simulate the noise generated by wind and tires. This only increases in pitch (slightly) and volume by the car's speed.

So you'll have at least two sound sources that create the sound of your car.