2

I have a problem with Soundmanager (class) (wrapper) for fmod in ogre3d engine. Here is the code just in case :

ISoundManager.h If somebody wants I will upload it but I can't upload more than 2 hyperlinks now.

SoundManager.h http://codeviewer.org/view/code:18c9

SoundManager.cpp http://codeviewer.org/view/code:18ca

I have a simple code piece to play the sound :

`   SoundManager *soundManagerPtr = new SoundManager;

    soundManagerPtr->Initialize();

    int mySound1 = soundManagerPtr->CreateStream(Ogre::String("boing.wav") );
    int channel1 = 0;

    soundManagerPtr->PlaySound(mySound1, headNode, &channel1);

    delete soundManagerPtr;`

Everything is fine, sound is loading, but PlaySound() function does not throw any error and does not play the sound either. I was asking on the ogre3d forum but no solution yet.

Patryk
  • 22,602
  • 44
  • 128
  • 244
  • Ogre doesn't seem to use exceptions, but error codes. Maybe you can look whether an error gets logged? – Karl von Moor Mar 27 '11 at 14:01
  • @Polybos: Ogre DOES use exceptions. But it's probably the SoundManager that doesn't. I haven't looked at the CPP file yet. – Vite Falcon Mar 27 '11 at 22:41
  • @ViteFalcon I've looked at SoundManager at it doesnt. – Karl von Moor Mar 28 '11 at 05:49
  • I'm voting to close this question because the [links to codeviewer.org no longer work](https://meta.stackoverflow.com/questions/345443/what-should-happen-to-questions-using-codeviewer-org-for-sharing-code). Without these links, the question has no clear [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). – g00glen00b Mar 16 '17 at 21:32

2 Answers2

2

I quickly checked the SoundManager code, and it appears the "PlaySound" function calls through to FMODs "playSound" function. In FMOD "playSound" is not a blocking operation, it will start playing the sound in another thread, then return. So since you are deleting the sound manager right away, it hasn't had a chance to play anything yet.

Mathew Block
  • 1,613
  • 1
  • 10
  • 9
  • 1
    thanks for reply, that was my problem. I removed the delete soundManagerPtr; line and everything works fine fine. I just have to put it somewhere else in the destructor and ... it should be fine :) – Patryk Mar 29 '11 at 11:43
0

I believe the SoundManager needs to get updated and this is done by frameStarted(). This means for your sound to start playing you have to start running your Ogre application using root->startRendering();. Have you tried that? The above code is either incomplete (in which case you really do have a problem) or you just have to get the update of the SoundManager started off by starting the graphics to render and thus call frameStarted of SoundManager.

Vite Falcon
  • 6,575
  • 3
  • 30
  • 48