Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Sounds not playing  (Read 7717 times)

0 Members and 2 Guests are viewing this topic.

ShadowDancer

  • Newbie
  • *
  • Posts: 26
    • View Profile
Sounds not playing
« 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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Sounds not playing
« Reply #1 on: November 16, 2009, 10:27:29 pm »
Can you show a small code sample that reproduces the same problem?
Laurent Gomila - SFML developer

ShadowDancer

  • Newbie
  • *
  • Posts: 26
    • View Profile
Sounds not playing
« Reply #2 on: November 16, 2009, 10:57:39 pm »
So i have class menu, that organizes things like buttons, lists, boards etc.

Code: [Select]
sf::Sound Button_Click;

I'm loading sounds with this:

   
Code: [Select]

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:

Code: [Select]

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;

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Sounds not playing
« Reply #3 on: November 17, 2009, 07:38:16 am »
Are your sound buffers still alive when you play the sounds? Are you sure that you never copy them?
Laurent Gomila - SFML developer

ShadowDancer

  • Newbie
  • *
  • Posts: 26
    • View Profile
Sounds not playing
« Reply #4 on: November 17, 2009, 09:00:43 am »
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...

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Sounds not playing
« Reply #5 on: November 17, 2009, 03:52:04 pm »
Quote
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).
Laurent Gomila - SFML developer

ShadowDancer

  • Newbie
  • *
  • Posts: 26
    • View Profile
Sounds not playing
« Reply #6 on: November 17, 2009, 04:04:30 pm »
Notching changed...

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Sounds not playing
« Reply #7 on: November 17, 2009, 06:24:40 pm »
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.
Laurent Gomila - SFML developer

ShadowDancer

  • Newbie
  • *
  • Posts: 26
    • View Profile
Sounds not playing
« Reply #8 on: November 17, 2009, 06:47:26 pm »
Project is too complicated, but some pples tested my app and on their pc's all is ok.

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
Sounds not playing
« Reply #9 on: November 17, 2009, 07:45:42 pm »
I'm sure it's your code's fault...

Maybe you should consider using pointers and new&delete.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Sounds not playing
« Reply #10 on: November 17, 2009, 08:27:35 pm »
Quote
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.
Laurent Gomila - SFML developer