ataylor Posted May 24, 2016 Share Posted May 24, 2016 I have a short beep sound I would like to play repeatedly when a key is held, tied to the keyboard repeat rate. The function that plays the sound is being called at the correct intervals, but the sound is not re-playing often enough. The length of the beep sample is longer than the period between the function calls, so it would seem that when the function is re-triggered and the previous beep is still playing, it does not re-start playback. I added calls to stop() and setTime(0.f), but nothing seems to have changed. class MyClass{ Unigine::AmbientSourcePtr m_beep; void MyKeyCallback(); } ... void MyClass::MyKeyCallback(){ m_beep->stop(); m_beep->setTime(0.f); m_beep->play(); } How can I get beep sound to play from beginning each time MyKeyCallback is called? Any advice is appreciated. Link to comment
maxi Posted May 25, 2016 Share Posted May 25, 2016 Hi Adam, sound events like play or stop do not updated immediately, sound has it's own thread that is updated at 30fps. You need to call force sound rendering to stop source first and then call play like this: m_beep->stop(); m_beep->setTime(.0f); Unigine::Sound()->get()->renderWorld(1); m_beep->play(); Link to comment
ataylor Posted May 25, 2016 Author Share Posted May 25, 2016 Thanks, can mark this as solved. Link to comment
Recommended Posts