0
0

Hi, i’m new to this forum and new to FMOD. I read the tutorial to integrate FMOD in my application. My application is a metronome that use FMOD to output a sound for every beat. The sound loaded from these application are 2: one for the first beat, and a second sound for the subsequents beats.

The sounds are contained in two oggs file. After createSound, I play the sounds paused, set the volume in the returned channel, and then call setPaused(false) to play the sound, as the documentation stated.

I have no problems if I pass values as low as 1 or 10 to maxchannels in the System::init call.

If I use, for example, 100 in maxchannels, at a certain point (not immediately, but after the sounds are played a few times each), Channel::setPaused return a 59 FMOD_ERR_OUTPUT_DRIVERCALL error, and no sounds are played anymore :(

This happen no matter what driver I choose, DirectSound or ASIO (i’m on windows xp SP3, with a motherboard integrated Realteck AC’97)

My code for the sound is all in one class and i will post it here:

EDIT: My FMOD version is 4.30

[code:15u90lma]

static const int SOUNDS_NUM = 2;

class SoundMgr
{
public:

FMOD::System* system;
FMOD::Sound* sounds[SOUNDS_NUM];
FMOD::Channel* channels[SOUNDS_NUM];
float volume;

SoundMgr():system(NULL) 
{
    for(int i=0; i<SOUNDS_NUM; i++)
    {
        this->channels[i] = NULL;
    }
}

~SoundMgr()
{
    if(this->system != NULL)
        this->system->release();
}

void setVolume(float value)
{
    this->volume = value;

    for(int i=0; i<SOUNDS_NUM; i++)
    {
        if(this->channels[i] != NULL)
            this->channels[i]->setVolume(value);
    }
}

inline void fatalError(FMOD_RESULT result, wxString additional = wxT(""))
{
    if (result != FMOD_OK)
    {
        wxString message;
        message << wxT("FMOD error ") << result << " : " << FMOD_ErrorString(result);
        message << "\n" << additional;
        wxMessageBox(message);
        exit(-1);
    }
}

void ini(ConfigOptions opts)
{
    FMOD_RESULT result; 

    result = FMOD::System_Create(&this->system);     // Create the main system object.
    fatalError(result); 
    /*      
    result = this->system->setOutput(FMOD_OUTPUTTYPE_ASIO);
    fatalError(result); 
    */      
    result = this->system->init(1, FMOD_INIT_NORMAL, NULL);   // Initialize FMOD.
    fatalError(result);   

    result = this->system->createSound(
        opts.sound1.c_str(),
        FMOD_DEFAULT, //mode
        NULL, //extended information
        &this->sounds[0] //sound object
    );
    fatalError(result); 

    result = this->system->createSound(
        opts.sound2.c_str(),
        FMOD_DEFAULT, //mode
        NULL, //extended information
        &this->sounds[1] //sound object
    );
    fatalError(result);   
}

void update()
{
    this->system->update();
}

void play(unsigned int snd_index)
{

    FMOD_RESULT result;

    result = this->system->playSound(
        FMOD_CHANNEL_FREE, //channel id
        this->sounds[snd_index], //sound
        true, //true for paused
        &this->channels[snd_index] //channel handle
    );
    fatalError(result, wxT("Error occured after playSound"));

    result = this->channels[snd_index]->setVolume(this->volume);
    fatalError(result, wxT("Error occured after setVolume"));

    result = this->channels[snd_index]->setPaused(false);
    fatalError(result, wxT("Error occured after setPaused"));

//The error is shown here, if I substitute ‘1’ in the System::init call with something as ‘100’
}
};

SoundMgr soundmgr;
[/code:15u90lma]

  • You must to post comments
0
0

it turned out I wasn’t calling System::update properly 😆

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.