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

Pages: [1]
1
Audio / Re: Slow downs when using sounds
« on: March 04, 2015, 06:39:44 pm »
Ah... That was such a dumb mistake...

Yeah, it was running in debug mode, it explains everything now, thanks a lot.

Should've checked that -.-.

2
Audio / [SOLVED] Slow downs when using sounds
« on: March 03, 2015, 09:43:35 pm »
Hi, I've been using the SFMl audio library to play sounds on a game and I noticed that the game started lagging.

I know that the sound starts playing in another thread so I don't really see why this would happen. Here's the relevent code:

// Constructor
PaletteAnimator::PaletteAnimator()
{
        a_angle_max_z = 60.0;
        a_angle_min_z = 0.0;
        a_angle_z = 0.0;
        m_acceleration = 15;

        if (!m_startSound.loadFromFile("./../bin/media/audio/sound/animation_palette_start.wav"))
                std::cout << "Error loading file <animation_palette_start.wav> \n";
                m_sound.setBuffer(m_startSound);

}

void PaletteAnimator::animate(float temps, bool animate)
{
        if (animate && a_angle_z < a_angle_max_z)
        {
                if (m_sound.getStatus() != m_sound.Playing) {
                        m_sound.play();
                }
               

                a_angle_z += temps * a_angle_max_z * m_acceleration;
        }
        else if (!animate && a_angle_z > a_angle_min_z)
        {
                a_angle_z -= temps * a_angle_max_z * m_acceleration;
        }

        validateParameters();
}

Commenting the line

m_sound.play();

will solve the problem, but, obviously, the sound will not play.


The animate() method is called once a frame and m_sound is a sf::Sound and m_startSound is a sf::SoundBuffer.

Pages: [1]