Problem Playing Ogg file for more than 10 times

tejasvinnakota

19-10-2010 11:46:20

Hi all

I somehow manged to play a .ogg file using the below code


Class :: Constructor()
{
mSoundManager = OgreOggSound ::OgreOggSoundManager::getSingletonPtr();
//mSoundManager = new OgreOggSound::OgreOggSoundManager();
mSoundManager->init();

newSound = mSoundManager->createSound("testSound", "./KDE-Im-Cant-Connect.ogg", true, false, false);
}
//On Selection of menu button , Below file is played
void MenuButtonSelection()
{
newSound->play();
}


WHen ever i selcet a menu item,sound is being played ,but after 2 or 3 selection.No sound is played.
Souond is being played for 2 or 3 times..or 10 times maximum
DOnt really have clue of how is it happening


Thanks for the replies..

stickymango

19-10-2010 12:01:17

Couple of things:

* How big is the sound file?

If the sound is short, set the stream flag to false as streaming is really only for long sound files.

* Is the sound mono/single channel?

If its single channel it will automatically be spatialised, its possible depending upon what happens in your scene you may move out of the range of the sound... Having said that, if thats the only sound code in your app at the moment its an unlikely scenario. To be sure either make the sound multi-channel or mark it as not 3D
OgreOggISound::disable3D()

tejasvinnakota

19-10-2010 12:25:40

Sorry I did really get it as today is the first time iam trying this..
I dont even know what flags are used for what..
PLease can u help me out on where can i find the correct documentation of 3d...

How should i disable3D...

Thanks

stickymango

19-10-2010 12:31:04

download doxygen and then run the BuildDocs.bat file in the docs folder of OgreOggSound, that will build the documentation for OgreOggSound for you.

First try the following:
Class :: Constructor()
{
mSoundManager = OgreOggSound ::OgreOggSoundManager::getSingletonPtr();
mSoundManager->init();

newSound = mSoundManager->createSound("testSound", "KDE-Im-Cant-Connect.ogg", false);
}
//On Selection of menu button , Below file is played
void MenuButtonSelection()
{
newSound->play();
}

I do this myself and it works fine.

tejasvinnakota

19-10-2010 12:34:16

Well this is the only sound in my application and i have to play it when evert a button is selected.But the sound is being played only for some selections.

stickymango

19-10-2010 12:38:55

Have you tried what I've suggested?

Have you established your callback is being called EVERY time you click a button?

tejasvinnakota

19-10-2010 12:43:40

Yes. I have tried whatever u ve told.But i have the same result. The thing is if i click slowly, its played for around 15 to 20 time and then its not being played..

And About CALLBACK.i have no idea..Can you please educate me on that.
Juse tell me how to establish a call back.Iam trying OGGsound for the first time and have no idea of what is it
Thanks for your time

stickymango

19-10-2010 12:53:14

Your MenuButtonSelection() function must be a callback, how do you trigger this function on a button click? what GUI system are you using?

I use CEGUI and have attached a callback function to every button in my menu system which does exactly what your doing and it works fine.

tejasvinnakota

19-10-2010 13:09:20

No. i dont have any such call backs..(iam using Quick Gui ,)

I actually do not click on the buttons , its done by hand gestures
If place my hand near a button ,it is selected(i dont touch a button)

// get the Matching Pixels value. If Matching pixels is more than acceptance rate of the ROI, then hand is on the button
if( ( (float)NumPixels / (float)TotalPixels ) >= g_ButtonSensitivity ) (i come to conclusion by using Opencv Techniques)

In the above way i find whether the hand ois on button or not, if yes i play the sound

stickymango

19-10-2010 13:53:43

You need to debug your code and trace exactly whats happening.

Note: Playing an already playing sound will effectively do nothing, you could try stop()/play()

There is no reason why the sound should only play for so many repetitons and stop, I do this exact same thing myself without any problems.

tejasvinnakota

19-10-2010 19:06:06

Yes.I will tdebug and Test it
Thanks a lot for your replies..

tejasvinnakota

20-10-2010 06:26:00

One more problem i ve seen is..
neither iam using OggSound in my code nor incleude a library

Only in Plugins.cfg i ve written a line PLUGIN = OgreOggsound.so and iam getting a segmentation fault when i end the application
Is that a problem with shared Object.
As i ve commented everything related to OgreOggSound,just had the above line in plugins.cfg

When i ve deleted the above line from Plugins.cfg, My Application Seemed to end well without problem
Whats could be th problem


Thank You

stickymango

20-10-2010 13:48:02

Hi,

That could be a bug, I can't say I've ever tested that scenario, if you could debug it and find out where it crashes that would be helpful otherwise I'll get around to having a look sometime.

tejasvinnakota

20-10-2010 14:00:19

Hey

I ve noticed that iam playing the sound in a function which is called frameStarted( const FrameEvent &Event ) almost every frame

And iam playing the sound by checking a conidtion in the function above.
Would that be a problem behind the Sound being played only for some period.

And iam unable to get into the play() function of newsound->play() while debugging

And can you please tell me what could be another way to come out of this problem
Thank you

stickymango

20-10-2010 14:54:22

Well calling play repeatedly will have the effect of doing nothing whilst the sound is already playing, play() first checks to see if it already playing and if so it just returns.

If you called stop() then play() then you should here a sound for each call of play(). However if thats happening every frame you won't hear much..

Looking back over your code it seems you test whether your hand is within a button area and call play() when it is, does this not have the effect of clicking the button every frame?

What you should be doing is firing a 'click' event only when the mouse enters the button area, NOT whilst the mouse is in the button area, no?

I've never looked at QuickGui but I'd imagine it has a system which fires particular events, like button pressed, button released, mouseOverButton, mouseLeaveButton, which you can subscribe to by means of a function call (callback). This way your function gets called only when necessary.

tejasvinnakota

20-10-2010 16:05:19

No..Mouse is nt needed for this projects..
As u ve said ..Item is selected when hand is on button area.

Then i need to play the sound..And i search for the hand every frame..THat is the issue


Thanks

stickymango

20-10-2010 16:28:16

Sounds like an interesting project, but yeah, you need to trigger play() on a 'hand enter' state.

tejasvinnakota

20-10-2010 16:40:11

Thts what iam worried about,
Triggering play...Any Code snippet tht can help me out..
As i ran out of all the ideas..PLease tell me how to enable a callback..as i ve not coded a call back till now

Thanks

stickymango

22-10-2010 16:32:25

Have you got anywhere with this yet?

tejasvinnakota

26-10-2010 06:18:16

Well, Not really
This is something i ve coded as u ve told me.
I will send you the whole sequence..
But the number of repetetions have increased , but sometimes aim unable to hear..Still donot hav any idea of what a perfect cde would be
//MY cONSTRUCTOR WHERE I VE INITIALIZED EVERYTHING
cMcodaCV::cMcodaCV()
{
mSoundManager = OgreOggSound ::OgreOggSoundManager::getSingletonPtr();
mSoundManager->init();
newSound = mSoundManager->createSound("MenuClick", "./button-pressed.ogg", false);
newSound1 = mSoundManager->createSound("CameraFlash", "./camera1.wav", false);
}

bool UpdateInput() //THis function gets called every frame thorugh (bool cMcodaFL::frameStarted( const FrameEvent &Event ))
{
{
if( MODE_CAMERA ) //CAMERA MODE IS ACTULLY FOR THE USERS GESTURES
{
if(g_HandonButton) // I ACTIVATE THIS BOOL VARIABLE WHEN HAND OIS ON BUTTON
{
newSound->play();
g_HandonButton = false;
}
}
}

But when i work with mouse mode..It works perfectly,...I ve tried working with mouse and its events...It fine there....

stickymango

26-10-2010 13:38:11

Thats not how I suggested you implement that, that is still going to execute every frame the hand is over the button, not what you want to do..

tejasvinnakota

27-10-2010 06:19:03

Well, this method actually works...
Ya sound misses once or twice if we do things rapidly..
But it is again audile for the next time...
And i thought this is the way u ve suggested...