ambiera home ambiera home

Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name:  Password:
Ambiera Forum > irrKlang
play multiple sound in different time
Author Text

newprogrammer24
Guest
Quote
2017-05-08 04:38:29

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
Registered User
Quote
2017-05-08 20:32:09

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



include "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();
}



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



niko
Moderator
Quote
2017-05-09 07:52:30

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.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Inte?national" (you are not logged in)


Text:

 

  

Forum Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   





Software: Ambiera Light Forum. © 2008-2019 Nikolaus Gebhardt, Ambiera e.U.