Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I create audio that increases in pitch as you go faster?

Asked by 6 years ago

Basically, I want to create a system for a road sound, where if a car is touching the road, the sound plays. Furthermore, I want the audio to increase in pitch as you move faster.

For Example, say 50mph is default playbackspeed = "1" and the quicker or slower you go it changes pitch.

I also want it to be a 3d sound which is attached either to the car or the head.

Any help will be appreciated! Thank you!

Extra Info:

The car's tires are named as follows: "FL" "FR" "RL" "RR"

1 answer

Log in to vote
0
Answered by 6 years ago

say 50mph is default playbackspeed = "1" and the quicker or slower you go it changes pitch.

  • Just as you said, to change the pitch, you'd edit the PlaybackSpeed property. To change the pitch in relation to the speed, you would first grab the position of a part attached the car twice: once immediately and again after a given amount of time (I recommend wait(1) ).
  • Then, you'd get the magnitude (distance) of the two positions by doing (p1-p2).magnitude, then divide it by the amount of time you waited:
position1= part.Position
time = wait() --we'll store the amount of time we waited for later
position2 = part.Position
  • Then, you'd get the magnitude (distance) of the two positions by doing (p1-p2).magnitude, then divide it by the amount of time you waited:
position1= part.Position
time = wait() --we'll store the amount of time we waited for later
position2 = part.Position
distance = (position1-position2).magnitude
speed = distance/time --this gets the studs/sec. rate
  • Finally, determine at what rate you want the speed to effect the pitch/PlaybackSpeed. For now, we'll say for every 10 studs/sec. , we'll increase it by .1 . Then set the PlaybackSpeed property I mentioned earlier to 1 + speed/rate:
position1= part.Position
time = wait(1) --we'll store the amount of time we waited for later
position2 = part.Position
distance = (position1-position2).magnitude
speed = distance/time --this gets the studs/sec. rate
rate = 20 --means that Playbackspeed will increase by .1 for every 2 studs/sec. increase
sound.PlaybackSpeed = 1 + speed/rate
Ad

Answer this question