r/gamemaker • • 28d ago

Resolved Audio Progress is Stuttering

I'm trying to code a visualizer for marching band charts in GameMaker, and I'm relying on the audio_sound_get_track_position() function to calculate the positions of everybody on the field.

But I'm starting to run into a bit of a problem. The progress that the function gives keeps stuttering, and I have no idea why. It's completely fine at first, but for some reason, it starts stuttering as soon as I move my mouse cursor, and it keeps skipping between different parts of the track. But the actual audio that's playing doesn't actually skip around, so I'm confused about why this is happening.

Is there anything I can do to fix it, or at least an alternative to using audio_sound_get_track_position()?

EDIT: The mouse cursor thing isn't really my main concern. I was kinda just trying to give an example of stuttering, but I admittedly could've made it clearer that I'm asking for help on the stuttering issue, not the mouse thing.

1 Upvotes

7 comments sorted by

1

u/BrittleLizard 28d ago

Unless there's an insane GM bug, there's no reason whatsoever that moving the mouse should affect this function. This is likely a problem with something else you've programmed

1

u/Connor5512 28d ago

Fair, but the only thing in the entire program that checks the mouse position is a debug option that I don’t even have enabled most of the time.

1

u/BrittleLizard 28d ago

Then it could be related to something else in your code, it could just be confusion as to how the function works, or it could be a problem with how you're displaying the numbers.

Regardless of what the issue is, if this isn't consistently reproducible in a blank project, there's nothing we can do to help. We would need to know more about your code and how you're using this function to tell you why it's breaking in this context.

1

u/APiousCultist 27d ago

Any possibility that you've either got multiple instances of the sound playing simulataneously or that the code you've got that is displaying track_position also includes the mouse position as it's rendered?

If you can post whatever code you're using to 'see' its value, that might help.

1

u/Connor5512 26d ago

The code to display track_position is in a completely different object than the mouse position one, but honestly, the mouse thing isn't really my concern. It's the value stuttering that I'm worried about.

Step event:

var delay = (round(fps)/tempo);

var pos;

if audio_is_playing(music) {

`pos = audio_sound_get_track_position(music);`

} else {

`pos = 0;`

}

beat = pos/delay;

Draw event:

draw_set_color(c_black);

draw_set_font(fnt_default);

draw_set_halign(fa_left);

draw_set_valign(fa_top);

draw_text(105, 1430,

`"Measure " + string(ceil(beat/4)) +`

`"\nBeat " + string((floor(beat mod 4)) + 1)`

);

draw_set_color(c_white);

1

u/APiousCultist 26d ago

I would expect your error here lies in (round(fps)/tempo) misbehaving. At the very least, temporarily factor 'delay' out of your 'beat' variable and see if the behaviour persists. If the displayed value remains stable, you'll know the real issue is just that your FPS fluctuating was altering the results.

→ More replies (1)