0

Finally, I have been able to execute playSound with no errors, but now I don't hear sound.

SoundEngine,h

    #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 SoundEngine.cpp

#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;
}

I think that it's correct and must play sound, but I don't hear anying( and I have the computer volume turned on and it works). Is there any other method that I need to use?

I also use FMOD_System_Update() in every frame.

EDIT: I also tried to put

while(true) FMOD_System_Update();

Inside the initSystem methor but it doesnt work.

mhatch
  • 4,441
  • 6
  • 36
  • 62
Elseine
  • 741
  • 2
  • 11
  • 23

1 Answers1

0

The issue will be the following line

result = FMOD_System_PlaySound(system,  sound1,channels, 1, NULL);

The second last parameter is 'paused', which is being set to 1 (or true), set it to false.

Mathew Block
  • 1,613
  • 1
  • 10
  • 9