Tutorial 02 : Getting Start

This tutorial will introduce you some basis of FMOD Ex & NativeFmodEx.

If you don't have installed NativeFmod[Ex] yet, look at Tutorial 01.
 

NativeFmodEx use native libraries (dll, so or jnilib depending on the platform).

The first thing to do is to check that all requiered libraries can be found and are well loaded.
This can be done with :

Loading

try
{
    Init.loadLibraries(INIT_MODES.INIT_FMOD_EX_MINIMUM);
}
catch(InitException e)
{
    out.printf("NativeFmodEx error! %s\n", e.getMessage());
    exit(1);
}


  What are ***_MINIMUM mode ?

These modes are associated with Callbacks. If you don't need callbacks, use this mode.
At start, some internal memory is initialized for objects used only by callbacks. Using this mode will allow you control this memory initialization (ie memory not allocated).


  What happens if loadLibraries is not called ?

An exception (RuntimeException) occure :

Not loaded

java.lang.RuntimeException: Libraries not loaded ! Use Init.loadLibraries() before using NativeFmodEx.

 How to solve "Libraries not loaded" ?

There is two ways to solve this :
 - add the path of the libraries in java.library.path
 - copy libraries in the bin (Windows) or in lib/i386 (Linux) folder of your JRE/JDK.
 

This is not requiered, but I advise you to check that the version of the jar and the library are the same.
If versions are different, this means you use a bad jar or library. ALWAYS use a jar and a library with the same version !
 

Version checking (NativeFmodEx)

if(NATIVEFMODEX_LIBRARY_VERSION != NATIVEFMODEX_JAR_VERSION)
{
    out.printf("Error! NativeFmodEx library version (%08x) is different to jar version (%08x)\n",
        NATIVEFMODEX_LIBRARY_VERSION, NATIVEFMODEX_JAR_VERSION);
    exit(0);
}

After this, you are ready for your first steps with FMOD Ex & Java.
 

This is the first FMOD Ex object you will use.
An FMOD Ex System object is used to initialize the sound device, create Sound, DSP and Geometry objects ...

Like for NativeFmodEx, you can check the version.
Here, you CAN use any versions of FMOD Ex >= to the advice version (FMOD_VERSION). Don't use an older version (< FMOD_VERSION).
It is even higly recommended to use the last FMOD library available !
 

Creating a System & Check version (FMOD Ex)

 //Create an instance
 System system = new System();
 FMOD_RESULT result = FmodEx.System_Create(system);
 ERRCHECK(result);

 //Check version
 result = system.getVersion(buffer.asIntBuffer());
 ERRCHECK(result);
 version = buffer.getInt(0);

 if(version < FMOD_VERSION)
 {
     out.printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
     exit(0);
 }

Note: we will see what is ERRCHECK in the following.

Then, you need to initialize the System.
You can either let FMOD use default settings or use a specific output, driver ...

Be carefull, this code (output, driver ...) is a platform dependant code. You have to take attention on which system is running the application and made the right initialization depending it.
This should be done before initializing the system.
 

Custom initializaion

if(FmodEx.getPlatform() == WIN32 || FmodEx.getPlatform() == WIN64)
{
    ...
}
else if(FmodEx.getPlatform() == LINUX || FmodEx.getPlatform() == LINUX64)
{
    ...
}
else if(FmodEx.getPlatform() == MAC)
{
    ...
}

Then, initilize :

Initialize

 result = system.init(32, FMOD_INIT_NORMAL, null);
 ERRCHECK(result);

Now, you are ready to do all you want with FMOD Ex.
Take a look to FMOD Ex examples (included in SDK archive) to learn the basis and more.

 

Here is  a list of basic FMOD Ex examples :

and FMOD Designer examples :

Previous Projectt

Back

Next Project

Last modified on 01/07/2010
Copyright © 2004-2010 Jérôme JOUVIE - All rights reserved. http://jerome.jouvie.free.fr/