|Attention||Topic was automatically imported from the old Question2Answer platform.|
|Old Version||Published before Godot 3 was released.|
I have a game where on button press the sound gets progressively higher pitched. I do it like so:
successMultiplyer += 0.1 print(successMultiplyer) if globals.allowSoundFX : soundSamplePlayer.play(successSound) soundSamplePlayer.voice_set_pitch_scale(0,successMultiplyer)
So it has the behavior of working for say, two button presses, then it reverts back to its original pitch, then it heads back up to the pitch it should be after a few more presses, then back to its original pitch for a few more presses.
Can anyone offer any advice as to why this could be the case?
The log data in the print function shows the
successMultiplyer increment properly as such:
1.1 1.2 1.3 1.4 etc
I just can’t see why it would work sometimes, but not every time.
I’m not sure if I understand much what is happening but try increasing polyphony limit on the player.
Don’t rely too much on “print”, you can get more information with breakpoints (like checking the tree, scripts and node’s data in any moment).
eons | 2016-10-24 02:11
I’m increasing the pitch by incrementing the multiplier. It works but only sometimes which is strange.
The polyphony is set quite high and I’ve played with it a bit with no change noticeable.
Can I ask why I shouldn’t rely on the print? Is there something unreliable about it?
Thanks also for your help…
Robster | 2016-10-24 02:15
Does the same with any multiplier increase?
Also, try using 2 sounds, one for odd and another for even multiplier(*10).
To remove possible sources of the issue (small values, same resource maybe cached?).
Btw, the audio system is being rewritten (promised for 2.2 but theres no 2.2 now) so if you find a buggy scenario could benefit the new audio server.
Print is quick but limited to… well, print, you can print data but is not useful to get debug information.
Using breakpoints you can check all the values on a specific moment, like checking pichscale before and just after changing, values of resources when playing, when ends playing.
You can dig more deep with debug proper.
EDIT: Noticed you are using sampleplayer2D (didn’t looked at the tags u__u), I think theres an issue related to that, you should check on github
eons | 2016-10-24 04:31
Firstly thanks for spending time helping and suggesting ideas, it’s really appreciated.
The frustrating part is it used to work perfectly. I can’t figure out what changed.
RE: your suggestions:
I just tried it with multiple variations of multipliers and it’s still acting the same.
I tried with 2 sound files. One for even multiplier, one with odd. The results were still unfortunately the same.
OhhhKay… I just played with the polyphony a bit more. When I reduce it to 1, it works! When I put it back up to a higher number (which I need) it fails. Would it be fair to say it’s a bug in godot?
If that were the case, do you think it could be fixed by having two samplePlayer2Ds?
I’ll give it a try, watch this space and again, thank you for the help…
EDIT: I’ve gone and added a second samplePlayer2D and assigned only the odd sounds to it, and the even sounds to the original but the behavior is the same. I guess I can only ask if there’s an idea someone might have to work around this? I may start another thread if required?
EDIT2: I’ve fixed the issue by playing the increment pitch scale in the first samplePlayer2D and am playing other sounds I require in a second samplePlayer2D.
It’s not perfect, I’m sure it’s a bug but it’s resolved / fudged the issue and I can move forward.
/u/eons Thank you for your help.
Robster | 2016-10-24 10:01
Couldn’t resist to test a bit more the “voice” thing…
SamplePlayer2D is weird, you can change its global pitch with
That affects all “voices”
Voices are all the sounds being played, in your code you
set voice_set_pitch_scale(0,...) that is, just the voice 0 is changing pitch (0 at polyphony list), you will hear it from time to time depending on how big the polyphony list is.
I was thinking, how hell you can get at least current or next voice? seems that the secret is in “play”.
What you can do is:
var current = soundSamplePlayer.play(successSound) #to get current voice soundSamplePlayer.voice_set_pitch_scale(current,successMultiplyer) #change pitch of current voice, the play is delayed and pitch affects it anyway
This should work with any polyphony level.
eons | 2016-10-24 14:17