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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - WrathfulProgrammer

Pages: [1]
1
Audio / Sounds stop suddenly
« on: March 21, 2010, 02:34:21 pm »
My apologies, found the problem, I wasn't deleting the instances.

2
Audio / Sounds stop suddenly
« on: March 21, 2010, 02:26:44 pm »
Hello, for some reason my sounds stop after a while, music continues playing as normal though.

I suspect it could have something to do with the frequency of the sound instance creation(Quite often), could it have something to do with that?

Init, called once on init.
Code: [Select]
if (!Music.OpenFromFile("DJYeoh0.ogg"))
{
MessageBox(hWnd,"Failed to load DJYeoh0.ogg.","Warning",MB_ICONEXCLAMATION | MB_OK);
return false;
}


if (!Buffer.LoadFromFile("laser0.ogg"))
{
MessageBox(hWnd,"Failure to load from file.","Warning",MB_ICONEXCLAMATION | MB_OK);
return false;
}


Create, this gets called each time a unit shoots/dies.
Code: [Select]
sf::Sound *temp_sound = new sf::Sound;
temp_sound->SetBuffer(ps->app->Buffer);
ps->sound_vec.push_back(temp_sound);
temp_sound->SetPitch(3);
temp_sound->Play();



Update called each frame
Code: [Select]
std::vector<sf::Sound*>::iterator sound_it = sound_vec.begin();
while(sound_it != sound_vec.end()){
int duration = (*sound_it)->GetBuffer()->GetDuration();
int elapsed = (*sound_it)->GetPlayingOffset();

if(elapsed >= duration){
sound_it = sound_vec.erase(sound_it);
}
else
sound_it++;
}


Thanks.

Pages: [1]