Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name: Password:
Ambiera Forum > irrKlang
Play two audios together result in bad sound effect
Author Text

imgloria
Guest
Quote
2021-12-13 10:31:09

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


erik
Registered User
Quote
2021-12-13 13:44:59

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


imgloria
Guest
Quote
2021-12-13 16:21:47

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);
}
}
}


imgloria
Guest
Quote
2021-12-13 16:29:31

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)){}
}


erik
Registered User
Quote
2021-12-13 17:36:16

Uh, that looks like you are playing hundreds of sounds at nearly the same time, causing this.


imgloria
Guest
Quote
2021-12-14 07:42:44

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...


erik
Registered User
Quote
2021-12-14 08:59:01

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.


imgloria
Guest
Quote
2021-12-14 18:11:54

I'll try, thank you so much!!


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "In?ernational" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© 2020 Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact