FMOD i Dont hear sound

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
SilverLadon
Gnoblar
Posts: 12
Joined: Sun Aug 24, 2014 5:26 pm

FMOD i Dont hear sound

Post by SilverLadon »

Hello.

I am using Ogre in Ubuntu and I am using FMOD for the sound.

This is my .cpp

Code: Select all

#include "SoundEngine.h"
#include <iostream>
using namespace std;
FMOD_RESULT result;
bool SoundEngine::initSystem()
{
    result = FMOD_System_Create(&system);
    unsigned int version;
    cout<<result<<endl;
    result = FMOD_System_Init(system, 1, FMOD_INIT_NORMAL, NULL);
    cout<<result<<endl;

    cout<<"Sonido"<<endl;
    //load sounds
    result = FMOD_System_CreateSound(system, "Media/NMG.mp3", FMOD_CREATESAMPLE, 0, &sound1);
    cout<<result<<endl;
    result = FMOD_System_CreateChannelGroup(system,"canal",&channels);
    cout<<result<<endl;
    result = FMOD_System_PlaySound(system,  sound1,channels, 1, NULL);
    cout<<result<<endl;
    //FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, )
    //sound1->setMode(FMOD_LOOP_OFF);    /* drumloop.wav has embedded loop points which automatically makes looping turn on, */

    /* so turn it off here.  We could have also just put FMOD_LOOP_OFF in the above CreateSound call. */
    //system->playSound(FMOD_CHANNEL_FREE, sound1, false, 0);
    cout<<"Sonido"<<endl;
    return true;
}
And my .h

Code: Select all

    #ifndef SOUNDENGINE_H_
#define SOUNDENGINE_H_

#include "FMOD/inc/fmod.hpp" //fmod c++ header
//#include "FMODEX/inc/fmodlinux.h"

class SoundEngine{
public:
    bool initSystem(void);
    void update(void);
private:
    //FMod Stuff
        FMOD_SYSTEM     *system; //handle to FMOD engine
        FMOD_SOUND      *sound1, *sound2; //sound that will be loaded and played
        FMOD_CHANNELGROUP *channels;
};
And I use Update() in every frame, but I dont hear the sound.

I also try put

Code: Select all

while(true) FMOD_System_Update(system);
Inside the initSystem method but dont work.
Any idea?
User avatar
insider
Orc
Posts: 462
Joined: Thu Sep 15, 2011 12:50 pm
x 31

Re: FMOD i Dont hear sound

Post by insider »

Well I don't use FMOD.
Perhaps you can have a look at how it is supposed to be initialized and played from the link below.

http://www.ogre3d.org/tikiwiki/tiki-ind ... e=Cookbook

The link is a little out of date but it should give you the idea I hope :)

Regards
SilverLadon
Gnoblar
Posts: 12
Joined: Sun Aug 24, 2014 5:26 pm

Re: FMOD i Dont hear sound

Post by SilverLadon »

insider wrote:Well I don't use FMOD.
Perhaps you can have a look at how it is supposed to be initialized and played from the link below.

http://www.ogre3d.org/tikiwiki/tiki-ind ... e=Cookbook

The link is a little out of date but it should give you the idea I hope :)

Regards
I reed this article and I dont find anything, but thanks anyway ^^
User avatar
insider
Orc
Posts: 462
Joined: Thu Sep 15, 2011 12:50 pm
x 31

Re: FMOD i Dont hear sound

Post by insider »

SilverLadon wrote:
insider wrote:Well I don't use FMOD.
Perhaps you can have a look at how it is supposed to be initialized and played from the link below.

http://www.ogre3d.org/tikiwiki/tiki-ind ... e=Cookbook

The link is a little out of date but it should give you the idea I hope :)

Regards
I reed this article and I dont find anything, but thanks anyway ^^
I have solved it and yes I am hearing the sound as I type.
Let me have a cup of coffee and I ll be back :D
User avatar
insider
Orc
Posts: 462
Joined: Thu Sep 15, 2011 12:50 pm
x 31

Re: FMOD i Dont hear sound

Post by insider »

Alright download the file I have zipped.

http://www.4shared.com/archive/GfLq3GHcce/FMOD.html

It has the edited source files of the SoundManager.cpp and .h
Add all the .cpp and .h files that I have attached to your project.

In your Main.cpp add
#include "SoundManager.h"

SoundManager * soundMgr;
int ff06SoundIndex;
int ff06SoundChannel;
SceneNode * ff06Node;
int gunSoundIndex;
int gunSoundChannel;
Entity * ent;

const int flightRadius = 200.0; // radius of the circle the plane flies in -- These are optional
const float flightSpeed = 1.0; // multiplier for the plane speed -- These are optional
const float fireGunInterval = 3.0; // how often to fire the guns -- These are optional


In CreateScene function add

soundMgr = new SoundManager;
soundMgr->Initialize();

ff06SoundIndex = soundMgr->CreateLoopedSound(Ogre::String("Sound050.ogg"));
// or you can use the generic CreateSound, specifying the sound type directly:
// ff06SoundIndex = soundMgr->CreateSound(Ogre::String("Sound050.ogg"), SOUND_TYPE_3D_SOUND_LOOPED);
ff06SoundChannel = INVALID_SOUND_CHANNEL;

// Create a 3D, single-shot sound for the plane's gunfire noise
gunSoundIndex = soundMgr->CreateSound(Ogre::String("Sound035.ogg"));
gunSoundChannel = INVALID_SOUND_CHANNEL;

ent = mSceneMgr->createEntity("FF06", "FF06.mesh");
ff06Node = mSceneMgr->getRootSceneNode()->createChildSceneNode("FF06Node", Vector3(0,5,-5.3));
ff06Node->attachObject(ent);
ff06Node->setScale(1.0f, 1.0f, 1.0f);

// Start playing the plane's engine noise
soundMgr->PlaySound(ff06SoundIndex, ff06Node, &ff06SoundChannel);
// Allow the plane's engine to be heard farther away than normal sounds.
soundMgr->Set3DMinMaxDistance(ff06SoundChannel, 100.0, 500.0);


In the frameRenderingQueued function add

soundMgr->FrameStarted(ff06Node,evt.timeSinceLastFrame);

I have also attached a folder called Data which you will find in the attachment.
Copy and paste in next to your Debug / Release folder
As below

Image

Open your resources.cfg and add

Code: Select all

[Popular]
FileSystem=Data
FileSystem=Data/Models
FileSystem=Data/Materials/scripts
FileSystem=Data/Materials/textures
FileSystem=Data/Sounds
#Zip=Data/packs/Sounds.zip
And you should hear sound playing. :D

Edit:

You should have
C:\Program Files (x86)\FMOD SoundSystem\FMOD Programmers API Windows\api\inc
in your C++ Project Directories.
And
C:\Program Files (x86)\FMOD SoundSystem\FMOD Programmers API Windows\api\lib
in Your Additional Library Directories.

I am on 64bit Windows so you may different file paths if you are on 32bit Windows or Linux .

And finally copy the dlls from
C:\Program Files (x86)\FMOD SoundSystem\FMOD Programmers API Windows\api

fmodex.dll to the bin of your project.
I guess its fmodexL.dll for the Linux OS

Regards

Insider
SilverLadon
Gnoblar
Posts: 12
Joined: Sun Aug 24, 2014 5:26 pm

Re: FMOD i Dont hear sound

Post by SilverLadon »

insider wrote:Alright download the file I have zipped.

http://www.4shared.com/archive/GfLq3GHcce/FMOD.html

It has the edited source files of the SoundManager.cpp and .h
Add all the .cpp and .h files that I have attached to your project.

In your Main.cpp add
#include "SoundManager.h"

SoundManager * soundMgr;
int ff06SoundIndex;
int ff06SoundChannel;
SceneNode * ff06Node;
int gunSoundIndex;
int gunSoundChannel;
Entity * ent;

const int flightRadius = 200.0; // radius of the circle the plane flies in -- These are optional
const float flightSpeed = 1.0; // multiplier for the plane speed -- These are optional
const float fireGunInterval = 3.0; // how often to fire the guns -- These are optional


In CreateScene function add

soundMgr = new SoundManager;
soundMgr->Initialize();

ff06SoundIndex = soundMgr->CreateLoopedSound(Ogre::String("Sound050.ogg"));
// or you can use the generic CreateSound, specifying the sound type directly:
// ff06SoundIndex = soundMgr->CreateSound(Ogre::String("Sound050.ogg"), SOUND_TYPE_3D_SOUND_LOOPED);
ff06SoundChannel = INVALID_SOUND_CHANNEL;

// Create a 3D, single-shot sound for the plane's gunfire noise
gunSoundIndex = soundMgr->CreateSound(Ogre::String("Sound035.ogg"));
gunSoundChannel = INVALID_SOUND_CHANNEL;

ent = mSceneMgr->createEntity("FF06", "FF06.mesh");
ff06Node = mSceneMgr->getRootSceneNode()->createChildSceneNode("FF06Node", Vector3(0,5,-5.3));
ff06Node->attachObject(ent);
ff06Node->setScale(1.0f, 1.0f, 1.0f);

// Start playing the plane's engine noise
soundMgr->PlaySound(ff06SoundIndex, ff06Node, &ff06SoundChannel);
// Allow the plane's engine to be heard farther away than normal sounds.
soundMgr->Set3DMinMaxDistance(ff06SoundChannel, 100.0, 500.0);


In the frameRenderingQueued function add

soundMgr->FrameStarted(ff06Node,evt.timeSinceLastFrame);

I have also attached a folder called Data which you will find in the attachment.
Copy and paste in next to your Debug / Release folder
As below

Image

Open your resources.cfg and add

Code: Select all

[Popular]
FileSystem=Data
FileSystem=Data/Models
FileSystem=Data/Materials/scripts
FileSystem=Data/Materials/textures
FileSystem=Data/Sounds
#Zip=Data/packs/Sounds.zip
And you should hear sound playing. :D

Edit:

You should have
C:\Program Files (x86)\FMOD SoundSystem\FMOD Programmers API Windows\api\inc
in your C++ Project Directories.
And
C:\Program Files (x86)\FMOD SoundSystem\FMOD Programmers API Windows\api\lib
in Your Additional Library Directories.

I am on 64bit Windows so you may different file paths if you are on 32bit Windows or Linux .

And finally copy the dlls from
C:\Program Files (x86)\FMOD SoundSystem\FMOD Programmers API Windows\api

fmodex.dll to the bin of your project.
I guess its fmodexL.dll for the Linux OS

Regards

Insider

I will tranform it to fit in my project (I am on Ubuntu and Ecplise) and I will tell you how it is, thanks!
SilverLadon
Gnoblar
Posts: 12
Joined: Sun Aug 24, 2014 5:26 pm

Re: FMOD i Dont hear sound

Post by SilverLadon »

insider wrote: Insider
I get an error in:

Code: Select all

ent = mSceneMgr->createEntity("FF06", "FF06.mesh");
I tried to put

Code: Select all

ent = mSceneMgr->createEntity("FF06", "./Data/Models/FF06.mesh");
and the absolute direction and nothing.

Do you now why occurs this??
User avatar
insider
Orc
Posts: 462
Joined: Thu Sep 15, 2011 12:50 pm
x 31

Re: FMOD i Dont hear sound

Post by insider »

SilverLadon wrote:
insider wrote: Insider
I get an error in:

Code: Select all

ent = mSceneMgr->createEntity("FF06", "FF06.mesh");
I tried to put

Code: Select all

ent = mSceneMgr->createEntity("FF06", "./Data/Models/FF06.mesh");
and the absolute direction and nothing.

Do you now why occurs this??
Never mind the entity comment out the entity code as below

//ent = mSceneMgr->createEntity("FF06", "FF06.mesh");
ff06Node = mSceneMgr->getRootSceneNode()->createChildSceneNode("FF06Node", Vector3(0,5,-5.3));
//ff06Node->attachObject(ent);
//ff06Node->setScale(1.0f, 1.0f, 1.0f);

Now can you hear the sound ?
And make sure this line is being update every frame soundMgr->FrameStarted(ff06Node,evt.timeSinceLastFrame);

If you still can't hear the sound post the Ogre.log and resources.cfg let me have a look.
SilverLadon
Gnoblar
Posts: 12
Joined: Sun Aug 24, 2014 5:26 pm

Re: FMOD i Dont hear sound

Post by SilverLadon »

insider wrote:
SilverLadon wrote:
insider wrote: Insider
I get an error in:

Code: Select all

ent = mSceneMgr->createEntity("FF06", "FF06.mesh");
I tried to put

Code: Select all

ent = mSceneMgr->createEntity("FF06", "./Data/Models/FF06.mesh");
and the absolute direction and nothing.

Do you now why occurs this??
Never mind the entity comment out the entity code as below

//ent = mSceneMgr->createEntity("FF06", "FF06.mesh");
ff06Node = mSceneMgr->getRootSceneNode()->createChildSceneNode("FF06Node", Vector3(0,5,-5.3));
//ff06Node->attachObject(ent);
//ff06Node->setScale(1.0f, 1.0f, 1.0f);

Now can you hear the sound ?
And make sure this line is being update every frame soundMgr->FrameStarted(ff06Node,evt.timeSinceLastFrame);

If you still can't hear the sound post the Ogre.log and resources.cfg let me have a look.
Yes! Finally I have sound.

But I have a problem, when I use :

Code: Select all

result = system->createSound("./Data/Sounds/NoMoreMagic.ogg", FMOD_LOOP_NORMAL | FMOD_3D  , 0, &sound);
I need to put the path of the sound, because newSoundInstance get me error, (File not Found)
User avatar
insider
Orc
Posts: 462
Joined: Thu Sep 15, 2011 12:50 pm
x 31

Re: FMOD i Dont hear sound

Post by insider »

SilverLadon wrote:
Yes! Finally I have sound.

But I have a problem, when I use :

Code: Select all

result = system->createSound("./Data/Sounds/NoMoreMagic.ogg", FMOD_LOOP_NORMAL | FMOD_3D  , 0, &sound);
I need to put the path of the sound, because newSoundInstance get me error, (File not Found)
Just add the filename no need for the path.
So it should be as below.
ff06SoundIndex = soundMgr->CreateSound(Ogre::String("NoMoreMagic.ogg"),SOUND_TYPE::SOUND_TYPE_3D_SOUND_LOOPED);

Make sure your data folder is under the group Popular in resources.cfg as I have mentioned above.
Double check that you have the below in your resources.cfg. else it will give the cannot find sound error.

[Popular]
FileSystem=Data
FileSystem=Data/Models
FileSystem=Data/Materials/scripts
FileSystem=Data/Materials/textures
FileSystem=Data/Sounds
#Zip=Data/packs/Sounds.zip

And ofcourse all sound files have to be in Data/Sounds

Glad to hear it worked at last :D

Edit:
Yep confirmed adding the path was the problem so just add "NoMoreMagic.ogg" instead of "./Data/Sounds/NoMoreMagic.ogg" and you will have sound.
RodrigoMarques
Gnoblar
Posts: 1
Joined: Fri Sep 05, 2014 9:02 pm

Re: FMOD i Dont hear sound

Post by RodrigoMarques »

crazy thing
Post Reply