• 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!

[SOLVED] function works different after click than after alarm

J

jana

Guest
I've set up a regular triggering effect, where I'm playing a string of piano notes, one note at a time, moving higher and higher in pitch. I start it with a mouse click on a button, then alarms are set, and the notes play indefinitely.

The problem is, when I click the button, the first five notes play all at once, then it plays one note at a time after that.
This is what it's supposed to sound like (15-sec clip):
https://www.screencast.com/t/y8DeEfDi

This is what it currently sounds like:
https://www.screencast.com/t/DjUKMeMB0wF

I have a button with a left mouse event and two alarms, and in the left mouse event I play the note and set alarm 0 to two seconds.;
Code:
scr_play_next(); // Plays a note
alarm[0] = global.PIANOTIMING; // Sets alarm 0 to two seconds
Then, in the alarm 0 event, I play the next note and set alarm 1 to two seconds
Code:
scr_play_next();
alarm[1] = global.PIANOTIMING;
Then to complete the loop, in the alarm 1 event, I play the next note and set alarm 0 to two seconds.
Code:
scr_play_next();
alarm[0] = global.PIANOTIMING;
This is partly working right. I get sound every two seconds indefinitely. What's weird is that when I click the button, it plays the first five notes, very close together. Then two seconds later it plays just the sixth note, and one note at a time after that indefinitely (15-second clip):
https://www.screencast.com/t/DjUKMeMB0wF

If I go to the left mouse event and comment out the note:
Code:
// scr_play_next(); // Plays a tone
alarm[0] = global.PIANOTIMING; // Sets alarm 0 to two seconds
there's a two-second silence after clicking the button, then it starts at the first note and plays one at a time after that (15-second clip):
https://www.screencast.com/t/y8DeEfDi

Why are those extra tones playing at the beginning? It's like the alarms are going off four extra times, then they settle down to normal. I tried to stop it by setting both alarms to -1 in the button's create event, but it makes no difference (I also tried setting them to 0):
Code:
alarm[0] = -1;
alarm[1] = -1;
This button is the only object that has an alarm event.
I searched all code on the action side of my objects for the word "alarm" and found none.
I did the same for all my scripts and found no word "alarm."
My script scr_play_next(), which appears in the left mouse event and the alarm events, is the only place the game maker function audio_play_sound() is.

Is there a cache being emptied or something?

Any ideas gratefully appreciated.
 
Last edited by a moderator:
?

!!!!!

Guest
Could it be you're using the 'Left Button' event instead of 'Left Button pressed' ? So it plays notes very fast for as long as you hold the mouse button, then starts your loop when you release? !
 
Top