Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Hi, I'm developing a game, and I want to add some footsteps effect when users press moving keys (for example WASD). I set background music playing iteratively ("SoundEngine -> Play2D(A, true)"), and when I wanted to call "SoundEngine -> Play2D(B, false)" for the footsteps effect, it work, but had some undesirable sound effects like sawing wood... I tried different audios, and only the one bleep.mp3 could work. I don't know why, anyone could help? Thanks a lot!!! |
||||
|
Not sure what you mean with undesirable sound effects like sawing wood But maybe trying anothe sound file format like .ogg or .wav might help |
||||
|
an unusual sound, like the tape is stuck. I tried different audio types, not work, I think the position of my second audio is the problem, but I'm not sure. I place the play() function of my second audio at a while loop, after a check of the press key function. My code is like this: int main(){ musicEngine->play2D(M1, true); while (!glfwWindowShouldClose(window)){ if (checkIfPressKey() == true){ musicEngine->play2D(M2, false); } } } |
||||
|
If I play the second music outside the while loop, there is no problem with the sound, but not the effect that I want (if the user presses a key, then make some sound effect). int main(){ musicEngine->play2D(M1, true); musicEngine->play2D(M2, false); while (!glfwWindowShouldClose(window)){} } |
||||
|
Uh, that looks like you are playing hundreds of sounds at nearly the same time, causing this. |
||||
|
yea, I guess so, um, any suggestion on how to avoid this problem? I thought I was only playing music when the user presses a key, and also I set the ‘loop’ attribute to false (so that it finishes playing about 1s), is this still occupy the player every time it plays? Do I have to use drop() to release the occupied engine? But then the background music I've been playing will be affected... |
||||
|
You could probably test if the key was pressed and is now left up. Or just play it once every few seconds. Or only play when a key-up event happened. I don't know much about glfw unfortunately to help you there. |
||||
|
I'll try, thank you so much!! |
|