Home > SimpleFMOD > Installation Instructions

Installation Instructions

February 18, 2013 Leave a comment Go to comments

Basic usage

Include SimpleFMOD header

At the top of a source code file:

#include <SimpleFMOD.h>
Import namespace

Everything in SimpleFMOD is defined in a namespace called SFMOD, so be sure to import this after you include the header:

using namespace SFMOD;
Create a SimpleFMOD instance

One-time initialization when your application loads:

SimpleFMOD fmod;

All interaction with SimpleFMOD occurs through this object.

Load sound files

Load a song:

Song song = fmod.LoadSong("Song.mp3");

Load a sound effect:

SoundEffect effect = fmod.LoadSoundEffect("Effect.mp3");

LoadSong streams files from disk, while LoadSoundEffect loads the files into memory. Songs and sound effects have their own channel groups – see Cutting Your Teeth on FMOD Part 2: Channel Groups for more information.

Note you do not have to use the convenience factory functions. You can instead create a Song or SoundEffect object directly using their constructors, and specify your own channel group and loading mode (see FMOD_MODE in the official FMOD Programmers API documentation).

Play songs with auto-looping
song.Start();

You can pass true as the first argument if you want to start the song paused.

Play one-shot sound effects
effect.Play();
Set/toggle pause

To toggle the pause state of a song:

song.TogglePause();

To specifically pause or unpause a song:

song.SetPaused(true); // or false

You can get the pause state of a track with Song::GetPaused().

Stop a song
song.Stop();

This resets the pause state and if you start the song again it will play from the beginning.

Set volume of an individual audio channel
song.SetVolume(1.0f);

The argument is a float from 0.0-1.0 where 0.0 is silent and 1.0 is full volume. Note the volume is automatically set relative to the master volume of the channel group for you.

Set volume of a channel group

For music:

fmod.SetMasterVolumeMusic(1.0f);

For sound effects:

fmod.SetMasterVolumeEffects(1.0f);

You can fetch the current master volumes with GetMasterVolumeMusic and GetMasterVolumeEffects() respectively.

Fade
song.Fade(3000); // fades a song out over 3 seconds (3000 ms) then pauses it
song.Fade(3000, 1.0f, false); // fades a song in over 3 seconds to full volume
song.Fade(x, y, z); // fades a song from its current volume to volume y over x ms, pausing if z is true
Loading sound files from embedded resources
Song song = fmod.LoadSong(IDMP3_Song1, "MP3");
SoundEffect effect = fmod.LoadSoundEffect(IDMP3_Effect1, "MP3");

where the identifiers are resource handles defined in your project’s .rc file and MP3 is the type name you have assigned to audio objects in Visual Studio’s resource editor.

Get the channel of playing audio
FMOD::Channel *channel = song.GetChannel();

This is useful if you want to perform operations on audio not supported by SimpleFMOD.

Retrieve the official FMOD API

To perform operations not supported by SimpleFMOD, you can retrieve a handle to the official FMOD API core:

FMOD::System *fmod_api = fmod.FMOD();
Per-frame update

You must always update FMOD each time you render a new frame:

fmod.Update();
Custom resource types

Song and SoundEffect derive from SimpleFMODResource. If you don’t like the behaviour of these example classes, you can create your own by deriving from SimpleFMODResource yourself and overriding the virtual Update() function. See the source code for additional details.

Teardown

None required. SimpleFMOD handles all memory management and resources for you.

Learning FMOD

Please see my series Cutting Your Teeth on FMOD for some basic information on how to get started with FMOD programming!

Pages: 1 2

  1. nabsuh
    May 12, 2013 at 14:18

    Hi there!

    I was attempting to use SimpleFMOD with my program and I get the following error:
    ” 1. IntelliSense: identifier “SimpleFMOD” is undefined”

    I followed your instructions to the letter and I’m unsure why I’m getting this error. Could you please advise what could be the cause of this problem?

    Thanks

    • May 12, 2013 at 17:38

      Do the examples included with the library compile correctly or do they give the same error?

    • May 12, 2013 at 17:40

      Follow-up: try adding “using namespace SFMOD;” after you include SimpleFMOD.h. Everything in the library is defined in a namespace called SFMOD. I will add this to the instructions on page 2 🙂

  2. nabsuh
    May 12, 2013 at 18:15

    There we go, that did the trick 🙂

    Thank you!

    • May 12, 2013 at 18:17

      Good stuff. I’m not perfect at writing instructions hehe, thanks for pointing that out 🙂 If you have any more problems just have a look through the examples folder, they should all work nicely 🙂

      • nabsuh
        May 12, 2013 at 19:23

        No issues 🙂

        After wrangling with the original FMOD for a couple of hours, SFMOD really puts it in terms of plain english!

  3. BMAC
    May 24, 2013 at 12:54

    How do you go about releasing sounds once you are finished? I see the struct ReleaseFMODResource with
    void operator()(FMOD::Sound *r) const
    {
    r->release();
    }

    but how do you use it / call it?

  4. Alex
    August 7, 2013 at 05:09

    I tried to include this in my VS2010 project but I get a linking error:

    SimpleFMODd.lib(SimpleFMOD.obj) : error LNK2038: mismatch detected for ‘_MSC_VER’: value ‘1700’ doesn’t match value ‘1600’

    Maybe the libraries aren’t good for VS2010 anymore?

    • August 7, 2013 at 16:35

      Argh, yes, the latest versions I uploaded are compiled against VS2012. It’s easy to fix though, the source code is included, just re-compile it with VS2010 🙂

  5. Forivinx
    February 21, 2016 at 04:20

    First of all thank you for the effort to write this great library and tutorials.
    I’ve tried to get this to work for days now, without any luck. 😦
    At first I was trying to make it compile with GCC, but after hours and hours of headaches I surrendered. So I’m now trying to compile the Frequency Analyzer, but there are just soo many issues.. After adding some includes ( and “tchar.h”) which apparently are necessary I finally got through the compiling process for the first time, but now there are linking issues: [text]The object or library file ‘Release\BeatDetecter.obj’ was created with an older compiler than other objects; rebuild old objects and libraries[/text]. After a while I found your comment about it actually not being compiled to work in VS2010… So now I’m at the point where I have to compile the lib… But neither have I ever compiled a static lib, nor have I seriously used Visual Studio. So I just created a new project, selected “static library” and then tried to build it with SimpleFMOD.h as the header file and SimpleFMOD.cpp as the source file, which gave me the following error messages:
    [text]1>..\..\..\..\..\..\..\Program Files (x86)\DJKaty.com\SimpleFMOD\src\SimpleFMOD.cpp(102): error C2143: syntax error : missing ‘,’ before ‘:’
    1>..\..\..\..\..\..\..\Program Files (x86)\DJKaty.com\SimpleFMOD\src\SimpleFMOD.cpp(102): error C2530: ‘r’ : references must be initialized
    1>..\..\..\..\..\..\..\Program Files (x86)\DJKaty.com\SimpleFMOD\src\SimpleFMOD.cpp(102): error C3531: ‘r’: a symbol whose type contains ‘auto’ must have an initializer[/text]
    I added the fmod include and lib dirs and even tried to add the fmod lib as a dependency, but it keeps giving me the same errors.

    Any help would be highly appreciated.

    • Forivinx
      February 21, 2016 at 16:34

      Okay, after spending a couple more hours on this I figured out that instead of

      for (auto &r : updateableResources)

      we can use

      for each (auto &r in updateableResources)

      and then the library finally compiles.
      Then I replaced the resulting .lib with the original one of the installation. Then in the Frequency Analyzer project I set the Runtime Library to “Multi-threaded DLL (/MD)” and put the fmodex.dll in the Release directory and it finally worked. BUT I should mention I have removed all the Simple2D stuff in advance and created a console application.

  1. February 19, 2013 at 00:12
  2. February 19, 2013 at 01:50
  3. February 27, 2013 at 03:05
  4. February 27, 2013 at 03:07
  5. February 27, 2013 at 03:07
  6. February 27, 2013 at 22:27
  7. February 28, 2013 at 01:09
  8. March 15, 2013 at 15:15
  9. November 24, 2013 at 15:19

Share your thoughts! Note: to post source code, enclose it in [code lang=...] [/code] tags. Valid values for 'lang' are cpp, csharp, xml, javascript, php etc. To post compiler errors or other text that is best read monospaced, use 'text' as the value for lang.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: