FMOD and cocos2d-x

I want to use FMOD as my audio engine for my game. I wonder why there is no any simple C++ wrapper for it and that works with cocos2d-x for iOS and android.
You can say that this is https://github.com/fmod/EarthWarrior3D but I will say, just no, that it.

In my game I need simple functions such as play, stop, pause, fade, pitch and so on for “.caf”, “mp4” and “.wav”, “.ogg”. I’m just looking for wrapper that helps me easy integrate FMOD with cocos2d-x. I’m very new to C++ and it’s hard for me to deal with this. Is anyone here already done this? Really looking for help.

@dumganhar any ideas?

@anon98020523
Sorry, I can’t help you since I have not used FMOD.
If you wanna use FMOD, I think you should refer to the official website and read their documentation.
Then, it will be easier for you to wrap it in c++.

AudioEngine-linux.h

#ifndef __AUDIO_ENGINE_LINUX_H_
#define __AUDIO_ENGINE_LINUX_H_

#include <functional>
#include <iostream>
#include <map>
#include "fmod.hpp"   ## bomp
#include "fmod_errors.h"
#include "audio/include/AudioEngine.h"
1 Like

@dumganhar yea… what strange, even creators of FMOD ignores asking for help:
https://github.com/fmod/ue4integration/issues/10 I’ve created this issue in ue repo because other thier without issues. Anyway, I even contacted them asking for help, but they ignore and again pointing to that old not updated example for 3d cocos…

I really wonder why cocos not using FMOD for iOS and android? It’s stable and powerfu, has no bugs at all and it’s free. Closed source? Who cares… you never need it.

seems there is another audio engine

1 Like

Hmm, looks interesting. Limbo used FMOD but INSIDE used Wwise… playdead chosen another for some reason…

iOS,Android,Mac

I’ve asked them by support and answer was really rude, like they really don’t care…
Also https://github.com/superpoweredSDK/Low-Latency-Android-Audio-iOS-Audio-Engine/issues/305

Thank you for registering your project!
Please allow some time for project approval. You will be contacted if we require any clarification.

They have a bit complicated form of registration, but will see it they will approve me.

Anyway FMOD looks more interesting for me…

UPD: while downloading and installing it I saw this:

WTF! On my Mac. No please no :smiley: and using wine… omg.

Please, just FMOD wrapper or integration with cocos2d-x, please…

FMOD is already written in c++, writing a wrapper on top of it wouldn’t make any sense. Only the setup is a bit difficult since you’ll have to add separate libraries for every platform.

But after you have done this step playing audio files is very straightforward, like that:

#include "fmod.hpp"

class HelloWorld : public cocos2d::Scene
{
    FMOD::System *system;
    FMOD::Sound *sound;
};

bool HelloWorld::init()
{
    if ( !Scene::init() )
    {
        return false;
    }

    // Initialize FMOD
    FMOD::System_Create(&system);
    system->init(32, FMOD_INIT_NORMAL, nullptr);
    
    // Create a sound instance from a file
    std::string path = FileUtils::getInstance()->fullPathForFilename("mysound.wav");
    system->createSound(path.c_str(), FMOD_LOOP_OFF, 0, &sound);

    return true;
}

void HelloWorld::playSound()
{
    FMOD::Channel *channel;
    system->playSound(sound, 0, false, &channel);
}

I believe it’s- C.

I don’t think so.

That’s why I’m interested in just work solution for iOS and android, better built into cocos…

Yes, tha’[quote=“domp, post:11, topic:37065”]
But after you have done this step playing audio files is very straightforward, like that:
[/quote]
And what about update?
Update

FMOD should be ticked once per game update. When using FMOD Studio, call Studio::System::update, which internally will also update the Low Level system. If using Low Level directly, instead call System::update.

You are right, it’s actually written in c but has a full fledged c++ layer on top of it. You’ll never need to call any c functions directly, which is why I said a wrapper wouldn’t make sense, at least in my opinion.

I forgot about updating it, just call scheduleUpdate() somewhere in your code, override the update function and update the FMOD system inside of it:

void HelloWorld::update(float dt)
{
    system->update();
}

Anyway simple wrapping is required. Easy to use, like with couple lines of code…

And so, result from official guys :slight_smile:
Ask1 to FMOD: Closed. They don’t care - will not provide example for cocos2d-x.
Ask1 to superpowered: Closed. They don’t care - will not provide example for cocos2d-x.

Well, too bad, but strange, cocos2d-x looks really popular, why they ignore it? but care about crappy unity and unreal…

My posts flagged as off-topic? I was brainstorming ways to make FMOD more straightforward for other developers to use. I get that I mentioned “Cocos Creator” in a topic talking about cocos2d-x but it’s not like they’re unrelated exactly…

Have you tried to integrate it already? Because I looked at the example and it does not seem that it would be difficult if you use C ++.

Do not pay attention to these flags, your posts are quite consistent with the topic.

But I do not think that we will have FMOD in the SDKBOX, since the SDKBOX seems designed to easily integrate SDKs from partners of cocos. And if FMOD does not want to be a partner, then there is no chance for it.
In addition, the cocos has its own audio engines, well, a bit buggy now, but I believe that they will fix it.

I just want cocos2d-x utilize best quality products. Using stable and well knows cross-platform audio engine should be a priority. This increases the quality overall.

2 Likes

Cocos2d-x doesn’t use them probably because they are both not open-source.

FMOD has by far more features then the other audio engines currently used in cocos2d-x. You have 3d sound, channels, groups and all that shit and is therefore very different to SimpleAudioEngine etc. Thats why a gernalized wrapper that covers all the functions that FMOD offers will be really big and will not differ too much from the FMOD API itself. Thats why nobody will implement such a thing :wink:
The FMOD Api itself is not bad at all and the documentation is also ok. Just get familiar with C++ and write the wrapper that suits your game.

@dumganhar so why cocos creator closed source? Why do you need sources for sound? It’s has no bugs at all, it just works. And that sources is C and a lot of low level code, again why its needed?