About Store Forum Documentation Contact



Post Reply 
FMOD wrapper
Author Message
yvanvds Offline
Member

Post: #1
FMOD wrapper
Hello people!

After releasing the first beta of my game, it was time to clean up some messy code. I used the FMOD sound engine instead of the standard esenthel objects for sound, but by using that library directly, my code wasn't as clear as it could be. (FMOD is a bit more lowlevel.)

Now I've spent this week rewriting the sound part of my program, wrapping all FMOD code in a way that makes it look more like esenthel objects and structs. And of course, combining lots of functions you don't really need to know about if you're just making a game.

Anyway... If someone is interested in using FMOD, take a look at this package: http://attr-x.net/index.php?option=com_c...&Itemid=10 (the download near the bottom of the page)

I have included esenthel's sound tutorials, altered for this wrapper. And some other code snippets that can be handy.

Advantages of the EE sound library are:
* logarithmic sound rolloff to make sound behave more realistic in 3D. (As opposed to linear rolloff, which is not like sound behaves in the real world.)

* Volumegroups are replaced by channelgroups, because you can also add effects to them.

* Improved and flexible doppler effect on moving sounds and the listener position.

* Underwater effect, with depth factor.

* You can select what sound driver you want to use.

* Reverb can be added to world positions. There are about 20 presets (room, cave, hall, dizzy etc.) which will blend into another if they overlap.

Things to do:

* working with pak files. (Dunno if it is possible. FMOD supports callbacks for filesystem handling though.)
* DSP sounds. (not difficult, but a lot of work)
* support for vst plugins. (is available in fmod, but I have to think about how to add it in a logical way.)
* Geometry (to add wall reflections and such. FMOD has a very crude geometry system, but it is good enough for audio reflections. It won't be easy to generate it from meshes I guess.)
* ...

cheers!

yvan
01-15-2011 10:45 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: FMOD wrapper
I haven't checked it, but sounds great! Thanks for sharing
01-15-2011 10:59 PM
Find all posts by this user Quote this message in a reply
JayJay Offline
Member

Post: #3
RE: FMOD wrapper
Works fine! Thanks Yvan!
(This post was last modified: 03-14-2011 12:09 AM by JayJay.)
03-13-2011 11:15 PM
Find all posts by this user Quote this message in a reply
yvanvds Offline
Member

Post: #4
RE: FMOD wrapper
I've just updated the FMOD wrapper. The new version introduces sound occlusion. You can now make a sound geometry object from a PhysBody that will be used in 3D sound calculations. It doesn't deal with reflections (FMOD limitation) but if there is an object between the sound source and the listener, you can completely or partly damp the sound and the reverb.

Download is available from my website.
05-29-2011 07:59 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: FMOD wrapper
Great!

But is this correct: ?
Code:
void FM::SoundStream::save(File &f) {
    if(_channel != NULL) {
        f.putStr(_name);
        f << _is3D;
        f << pos();
        f << playing();
//        f << raw();
//        f << loop();
        f << volume();
//        f << speed();
        f << range();
        f << _channel_group;
    }
}

Bool FM::SoundStream::load(File &f) {
    _channel->stop();
    Vec pos;
    Flt raw, volume, speed, range;
    Bool loop, playing;
    f.getStr(_name);
    f >> _is3D;
    f >> pos;
    f >> playing;
    f >> raw;
    f >> loop;
    f >> volume;
    f >> speed;
    f >> range;
    f >> _channel_group;
some elements are commented when writing, but they are still being read
05-29-2011 09:02 PM
Find all posts by this user Quote this message in a reply
yvanvds Offline
Member

Post: #6
RE: FMOD wrapper
You're right. I am still working on the SoundStream code. I forgot to exclude it when I zipped the file. In other words it's not ready for use yet.

But now that I have your attention, I have another question :-)

You might know that even an indie license for FMOD is still quite expensive. € 3000 for a casual license. I'm still using the freeware license for now, since I will be beta testing and adding features for at least 6 more months. When I started using FMOD they still had an indie license for € 150, but it's gone.

But when you look at garagegames.com (Torque game engine, really bad) you'll see they made a deal with FMOD, offering an FMOD license for Torque developers at only $100. Do you think you could perhaps close a similar deal with them?

If you think it's any good, you may even start from my code to get the FMOD functionality implemented in EE. I'd donate the copyrights to you in exchange for the extra work.
05-29-2011 11:12 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #7
RE: FMOD wrapper
Indeed they changed the cheap license, actually 2 years ago. :o
05-30-2011 07:20 AM
Find all posts by this user Quote this message in a reply
yvanvds Offline
Member

Post: #8
RE: FMOD wrapper
I guess it is about time for an update to this. I've put a new version online, with the following improvements:

1. Streaming sounds over a network (or playing a live stream from the net) are now possible.
2. Loading sounds from disk now uses EE's filesystem. So you can include all sounds in a pakfile.
3. Added a DSP system (more about this below.)
4. Several small bugfixes

The occlusion code can still be used, but I don't use it anymore myself. I've discovered that it's easier just to do a physics ray from the sound towards the listener. I there's an object in the way, just block the sound yourself. I works just as fast, and doesn't have any noticeable overhead. And it also works with the terrain.

About dsp
----------
The implementation of dsp programming goes much further than just wrapping what is in FMOD. I created a flexible system to modify sound in realtime.

It works like this: you create a dsp and add it to a sound. After that you can add dsp elements to the dsp and they will be processed before the sound is played. I have included one element as an example: a ring modulator. It should be easy enough to write your own elements and add them to a sound.

Every sound has its own dsp and you can add elements to them as much as you want, or until your computer can't process them all in time. DSP processing happens in a separate thread, so you don't have to worry that much about FPS.

I included all the basics needed dsp programming:
  • sample objects, with all basic calculations
  • delay
  • envelope measurement
  • vcf, hipass, lowpass, bandpass and biquad filter
  • basic audio math functions like clip, wrap, midiToFrequency, Db to RMS conversion, Db to Power conversion, exp, abs and log.
  • sine, saw, square and noise oscillators
  • audio ramps (no high definition yet)

If you know about DSP programming, the tutorials will be quite enough to get you started.

WARNING: If you don't know anything about DSP's please take care. This stuff is quite useful, but you can damage your speakers with them if you don't know what you're doing. (For example by outputting samples with only positive numbers you'll push the membrane outwards all the time, which is really bad.) Just trying out the example is completely safe though.

Download can still be found here: http://attr-x.net/downloads/fmod_wrapper.zip



Other good news is that FMOD reintroduced the cheaper indie license. (at 500$ instead of 1500$)
(This post was last modified: 08-10-2012 06:40 PM by yvanvds.)
08-10-2012 06:38 PM
Find all posts by this user Quote this message in a reply
eLeMenCy Offline
Member

Post: #9
RE: FMOD wrapper
Oooh Woow this sounds just great - big thumbs up - thank you for this amazing update!! smile
08-10-2012 08:06 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #10
RE: FMOD wrapper
Cool.
Is it okay if I put this into Esenthel Store (as Free Item) and credit you in the source code description?
08-10-2012 11:33 PM
Find all posts by this user Quote this message in a reply
yvanvds Offline
Member

Post: #11
RE: FMOD wrapper
Sure :-)

But if you do, it would make me real happy if you contacted FMOD and see if you can't get a similar deal as Garagegames and some other lower priced game engines. They are still offering an FMOD license for $100. While the cheapest license on the FMOD site is $500.

Perhaps you could get a similar deal for licensed Esenthel users? If they refuse, so be it. Worth a try though.
08-11-2012 09:17 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #12
RE: FMOD wrapper
Thank you, I'll put this into the store.

If I'd try to go into some deal with FMOD developers, then I'm pretty sure I'd need to take over FMOD integration development into the engine (take all sources and include them precompiled in the engine lib files, test them thoroughly, and maintain the source code) for which at the moment unfortunately I don't have the time.
08-11-2012 01:00 PM
Find all posts by this user Quote this message in a reply
Post Reply