0
0

Hello, I’m a junour "fmod developer" 😳 . With its help I’m trying to build the soundbox of my application. I have a question,
maybe easy for most of you – it will be great if you can to give me some guidance.

Here is the problem:

I have the following pointers:
FMOD::EventSystem* m_EventSystem;
FMOD::EventProject* m_EventProject;
FMOD::System* m_FMODSystem;
FMOD::MusicSystem* m_MusicSystem;
FMOD::ChannelGroup* m_ChannelGroup;

which I initialize in the following way:

[code:3fsuh24p]bool SoundSystem::Initialize()
{

FVERIFY(FMOD::EventSystem_Create(&m_EventSystem));
m_EventSystem->getSystemObject(&m_FMODSystem);

FMOD_CAPS caps;
FMOD_SPEAKERMODE speakerMode;

m_FMODSystem->getDriverCaps(0, &caps, nullptr, nullptr, &speakerMode);

// Set the user selected speaker mode.
FVERIFY(m_FMODSystem->setSpeakerMode(speakerMode));

if(FAILED(m_EventSystem->init(MAX_VIRTUAL_CHANNELS, FMOD_INIT_NORMAL, nullptr)))
{
    FVERIFY(m_FMODSystem->setSpeakerMode(FMOD_SPEAKERMODE_STEREO));
    FVERIFY(m_EventSystem->init(MAX_VIRTUAL_CHANNELS, FMOD_INIT_NORMAL, nullptr));// ... and re-init.        
}

m_EventSystem->setMediaPath( GetLocalResourcePath("Sounds\\").c_str() );
m_FMODSystem->set3DSettings(1.0f, 100.0f, 1.0f);

m_EventSystem->getMusicSystem(&m_MusicSystem);
m_FMODSystem->getMasterChannelGroup(&m_ChannelGroup);

m_EventSystem->load("ER.fev", nullptr, &m_EventProject);

}[/code:3fsuh24p]

I have a method which plays the event:
[code:3fsuh24p]void SoundEventOwner::RaiseOneshotEvent(SoundEventOwner::EventDef eventd, const char* paramName, float param, const mmath::vector3* position, const mmath::vector3* velocity)
{
Event* e = eventd.GetEvent(this);
e->set3DAttributes(position, velocity, nullptr);
EventParameter* p;
e->getParameter(paramName, &p);
p->setValue(param);
e->start();
}[/code:3fsuh24p]

that is, with the help of e->start() I play the sound. What I’m trying to do is to make the metod not just play but loop the sound

And I have not idea how make it so. Any help will be invaluable.
Thanks,
Balki

  • You must to post comments
0
0

Set the event to loop in designer, make sure it all works there first, and it should just work.

  • You must to post comments
0
0

I want to avoid using the designer – I want to be able to sometimes just play an event and some time loop it

  • You must to post comments
0
0

Firstly, it is [i:3b05zjr4]extremely [/i:3b05zjr4]important that you check the FMOD_RESULT being returned from all these functions. You need to be handling any FMOD errors that occur. For example if getEvent fails and you call event->start on an invalid event handle, it will probably cause an access violation causing your application to crash.

In answer to your question, the best way is to make your events loop is to do what a1psx said. If you really want to force a one shot sound instances to loop it can be done. This will work for simple events with exactly one sound. (complex events can have more than one channel in which case it may not be possible to do this way)

After calling event->start the low level channel is created. You can get access to this via the channel group.

Event::getChannelGroup
ChannelGroup::getChannel
Channel->setMode( FMOD_LOOP_NORMAL );

You can loop it a specific number of times using:
Channel::setLoopCount

Hope this helps,

-Pete

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.