• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Sound crackles when pitched low

VerteX123

Member
I'm having issues with my car engine sound. Using phy_speed variable to pitch it, but when pitch is low, the sound starts crackling. Has anyone got ideas to fix it?
 

Andrey

Member
Yes, I also have this problem. And I constantly write about this on the forum.

I hope that the next update of GMS2 will fix this situation.

Although, maybe it's worthwhile to create a ticket about the error?
 

Juju

Member
How low is low? Bear in mind that at a certain point, you'll hit the limits of what the audio buffer can reconstruct with pitch shifting.

@Andrey, the post you linked to mentions a bug in the IDE rather than in-game. That would appear to be an unrelated issue (though still an annoyance).
 

Andrey

Member
@Andrey, the post you linked to mentions a bug in the IDE rather than in-game. That would appear to be an unrelated issue (though still an annoyance).
No, distortions are in the game (and in Windows and Android).
It's crackling that's dirty vinyl.
 

VerteX123

Member
@Juju It starts below 0.5. If it's because the limit, would it work, if I pitch the sound in external audio editor and start using new sound from that point on when it starts to crackle? So it will start the pitch shifting from 1 to 0.5 again but only this time the sound is half of its original pitch. Any other ideas are welcome.
 

TsukaYuriko

☄️
Forum Staff
Moderator
For the sake of illustration, this issue may be of a similar nature as scaling graphics. In such a scenario, you're scaling small graphics to a higher resolution, which means that more pixel data is required than is known. The result is that the rest of the data has to be made up out of thin air based on some sort of algorithm... which works fine for some graphics and not so well for others.

It's the same here. Since not only the pitch, but also the tempo of the sound, are changed by audio_sound_pitch (assuming that you're using that), lowering the pitch of the sound also lowers its tempo, thus increasing its length and, finally, increasing the amount of data needed to represent it. This data, again, has to be created out of thin air based on an algorithm which may or may not have the desired results in any given case and may lead to effects such as the one you're experiencing when not enough data exists to accurately calculate the pitched-down version.


This shouldn't be an issue (or less of an issue - using anything other than the source material means some data will have to be made up or truncated, both of which are not guaranteed to work out perfectly, but this way the effects are much less noticeable) if, say, your sound file naturally starts at a lower pitch and then has its pitch increased programmatically instead of the other way, as there would not be a need to create data out of thin air.
 

Juju

Member
I'd expect to see problems well below 0.5... feels like something's up.

No, distortions are in the game (and in Windows and Android).
I know Android historically has had poor audio support, but on Windows too? Yeah, that's concerning.
 

Andrey

Member
Problems started after known updates with audio engine. Before that, the sound was perfectly smooth.
 

VerteX123

Member
So I did a little test and it seems to me the problem is how audio engine handles the low frequencies. I lowered the pitch of the original sound in Audacity, then imported it back to project. This time I started pitching from 1 to higher, but it still crackles while sound hasn't reached higher pitch (crackling is quite subtle though, but noticeable). Also tried pitching up with initial sound that has higher pitch, works fine, no crackling.
 

Andrey

Member
So I did a little test and it seems to me the problem is how audio engine handles the low frequencies. I lowered the pitch of the original sound in Audacity, then imported it back to project. This time I started pitching from 1 to higher, but it still crackles while sound hasn't reached higher pitch (crackling is quite subtle though, but noticeable). Also tried pitching up with initial sound that has higher pitch, works fine, no crackling.
Excellent, that you have an example!
Soon, probably, there will be an update of GMS2, if this error is not corrected, you can create a new bug report, where your example will come in handy.
 
Im curious but cant test right now: does it only crackle when running from GMS or also when exported as VM and exported with YYC?
 

VerteX123

Member
Decided to do some more testing and discovered that the crackling sound isn't about pitching low frequencies, but pitching in general. While I was using a sound that had a lot of frequencies, that sound was just overlapping with crackles in the higher frequencies.
Made some very simple test project, where I used a simple sine wave loop with initial 130 Hz and crackling is there even if the sound is pitched very high. This crackling is produced by the change of pitch, so every increasement or decreasement creates a little click. The click is more audible when using bigger steps in increase/decrease. When shifting pitch with 0.001 per step, the click is barely audible (depends on which headphones you use, I use studio headphones, but when I listened with regular Hi-Fi headphones, the shift per step had to be greater to hear the click).
@The Reverend Crackles remain the same even when exported as VM. Haven't tested with YYC. I don't have Visual Studio files installed and downloading it would take a long time considering my Internet speed.
If anyone's interested, this is how I tested:

Create:
Code:
testSound = snd_test;
audio_play_sound(testSound, 10, true);
pitch = 1;
pitchShift = 0.001;
Step:
Code:
if (keyboard_check(vk_up))
   {
   if (pitch < 5)
       {
       pitch += pitchShift;
       }
   audio_sound_pitch(testSound, pitch);
   }
else if (keyboard_check(vk_down))
   {
   if (pitch > 0)
       {
       pitch -= pitchShift;
       }
   audio_sound_pitch(testSound, pitch);
   }
I know there's a click when you suddenly stop a sound and it's easily fixable with audio_sound_gain() function, but there shouldn't be this while pitching?
 

Andrey

Member
Im curious but cant test right now: does it only crackle when running from GMS or also when exported as VM and exported with YYC?
I have crackles in Windows (in test) and when exporting to Android (VM and YYC). Crackles I hear both in the headphones, and through the Android device's speakers. They just are.
 

Tornado

Member
I have GMS2 IDE v2.1.5.322 Runtime v2.1.5.246.
I just imported my Project from gms1.4.
I have this crackling problem too in GMS2 when changing the pitch of the music.
I checked on Windows WM build and Android YYC build. The problem appears on both.
How come? I thought they have fixed this issue?

(In gms1.4 the problem doesn't occur.)
 

rIKmAN

Member
I have GMS2 IDE v2.1.5.322 Runtime v2.1.5.246.
I just imported my Project from gms1.4.
I have this crackling problem too in GMS2 when changing the pitch of the music.
I checked on Windows WM build and Android YYC build. The problem appears on both.
How come? I thought they have fixed this issue?

(In gms1.4 the problem doesn't occur.)
The current version of GMS2 is 2.1.5 and if you check that linked bug report above, although the bug is marked as fixed / resolved you can see that the target version is 2.2.0 - which will probably be the next GMS2 update.
 

Tornado

Member
ah thank you! I did check that link before, but apparently i failed to interpret it correctly. Sorry !!!
They talk there only about emitters, I hope that the fix also includes normal audio_sound_pitch(...) function, because the crackling happens there too.
 
Top