SFML community forums
Help => Audio => Topic started by: ShadowDancer on November 16, 2009, 10:02:01 pm
-
I have problem with playing sounds. Sometimes sound not playing but it have good buffer and Play() is called. I have menu class that contains sf::Sound and global SoundBuffer. Menu is maked like tree, sounds work in 1st lvl, but in lower not. Setting new sound instance manually and using Play() works only on 1st lvl of menu(or main function), in lower not. When i get up from menu sounds are played normaly.
I am sure, that buffer are not changed after entering menu(find al references). Can someone help? Here is limit of instances that can use one buffer, or smthing?
-
Can you show a small code sample that reproduces the same problem?
-
So i have class menu, that organizes things like buttons, lists, boards etc.
sf::Sound Button_Click;
I'm loading sounds with this:
void Menu::Create_Buttons((...), sf::SoundBuffer &Snd_Over, sf::SoundBuffer &Snd_Click)
{
for(unsigned int i = 0; i < Number buttons(); i++)
{
sf_gui::Button New_Window;
[...]
New_Window.Button_Over.SetBuffer(Snd_Over);
New_Window.Button_Click.SetBuffer(Snd_Click);
Windows.insert(Windows.end(), New_Window);
}
}
And menu have method thad moves touch all buttons and playing sound if necessary:
if clicked on button
{
if(Clicked == true)
{
if(Is_Click_Played == false)
{
Button_Click.Play();
Is_Click_Played = true;
}
State = 2;
Result = true;
}
}
else Is_Click_Played = false;
-
Are your sound buffers still alive when you play the sounds? Are you sure that you never copy them?
-
Ya, sound buffer is global value, that is loaded in main function and never changes. I asked friend and on he's computer it works fine. If u have redists for MSV2k8 mb u can check too( http://www.unreal_world.w.interia.pl/Debug.rar )? Maybe my soundcard is broken or smthing...
-
Ya, sound buffer is global value
You mean it is declared at global scope? You shouldn't do that, try to make it local to a smaller scope (a class, or main).
-
Notching changed...
-
Can you provide a complete and minimal code sample that reproduces this problem? Something that I can copy and paste in one file and test directly.
-
Project is too complicated, but some pples tested my app and on their pc's all is ok.
-
I'm sure it's your code's fault...
Maybe you should consider using pointers and new&delete.
-
Project is too complicated
So the only way to find the source of this problem is to eliminate all the stuff that is unrelated to it, so that it appears clearly ;)
If a simple code that just declares a sound and plays it works, then the error is definitely from your code.