Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
hi i use irrKlang for the first time and i have some problems. i want to playing multi sounds in different time . i mean in my game i create engine starting in background .also create interface for winning and loss and for both of them i create new engine . my question is how can i stopped the engine in the background and start another one if the user winning or loss and gain stopped the winning or loss engins if the user want to play again !! i did code somthing like this [codeinclude "include/irrKlang.h" using namespace std; using namespace irrklang; pragma comment(lib, "irrKlang.lib") ISoundEngine* engine = createIrrKlangDevice(); ISoundEngine* engine2 = createIrrKlangDevice(); ISoundEngine* engine3 = createIrrKlangDevice(); void winscreen() { engine->removeSoundSource("pp.mp3"); engine2->play2D("ww.mp3", true, false, true); } void gameoverscreen() { engine->removeSoundSource("pp.mp3"); engine3->play2D("oo.mp3", true, false, true); } void specialKeys(unsigned char key, int x, int y) { if (key == 27) exit(0); else if (key == 'p') {//ask user to play again press p engine3->removeSoundSource("oo.mp3"); engine2->removeSoundSource("ww.mp3"); engine->play2D("pp.mp3", true, false, true); } glutPostRedisplay(); } int main() { glutDisplayFunc(myDisplay); if (!engine) return 0; // error starting up the engine // play sound in the background engine->play2D("pp.mp3", true, false, true); glutMainLoop(); } [/code] the code is run but not very good .it creates Disturbing and interlocking sounds!! any one can help me please ..thanks and sorry for bad english |
||||
|
newprogrammer24 wrote:
hi i use irrKlang for the first time and i have some problems. i want to playing multi sounds in different time . i mean in my game i create engine starting in background .also create interface for winning and loss and for both of them i create new engine . my question is how can i stopped the engine in the background and start another one if the user winning or loss and again stopped the winning or loss engins if the user want to play again !! i did code somthing like this
the code is run but not very good .it creates Disturbing and interlocking sounds!! any one can help me please ..thanks and sorry for bad english |
||||
|
You create multiple instances of an irrKlang device. Don't do that. Only create one. It is a very heavy object, and you only need one of it. This might cause your problems already. Also, don't call removeSoundSource everytime before you play the sound. That's not necessary either. |
|