Topic was automatically imported from the old Question2Answer platform.
Asked By
Robster
Old Version
Published before Godot 3 was released.
Hi all,
I want to change the pitch of a sound each time it’s played, so it increments.
I had a look at the docs and came across voice_set_pitch_scale but after some playing can’t seem to fully understand how it works enough to actually make it work. :-/
Has anyone had any experience with it? I’ve tried things like:
OK I figured it out, I’ll put it here to help someone in the future. The key point is the pitch scale change changes the currently PLAYING sound, so it must be used after the play command.
Basically in voice_set_pitch_scale(0,1.2) the first argument (which I have as 0) is the index of the sound that’s playing, so in my case, the first (and only) sound.
The second argument, which I’m testing with 1.2 is the scale change, so 20% higher in this case.
I hope that helps someone in the future.
Almost exactly a year later…one addendum about that first argument To be more robust you should say:
var voice = soundSamplePlayer.play('success01')
soundSamplePlayer.voice_set_pitch_scale(voice, 1.2)
(You can also set the relative volume using voice_set_volume_scale_db)