NativeFmodEx — Tutorial02

Historical project documentation. Versions and platform requirements describe the original releases.

  •  Introduction

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

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

  •  Getting start

  •  Loading

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.
 

  •  Versions

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.
 

  •  FMOD EX System

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.

 

  •  Getting start exemples

Here is  a list of basic FMOD Ex examples :

  •  PlaySound / PlayStream play some musics from the hard drive.

  •  LoadFromMemory play some musics from the memory (usefull to play musics packed into a jar).

  •  NetStream play a music from the web (using http protocol)

  •  CDPlayer play an Audio CD

  •  Recording/RecordToDisc record

  •  DspPluginViewer plugins and spectrum/oscillator display

  •  Geometry_ 3D scene with musical environment

  •  ... and more such as ChannlGroups, CodecRaw, DspCustom, DspEffectPerSpeaker, DspGainMain, Effects, FileCallbacks, GenerateTone, MultipleSoundcard, MultiSpeakerOutput, OfflineDecoding, PitchDetection, PlayList, ReadTags, RealtimeStitching, SubMixing, UsePlugins, UserCreatedSound, VirtualVoices.

and FMOD Designer examples :

  •  SimpleEvent Getting start with FMOD Designer

  •  RealtimeTweaking use the 'Net Event System' library to connect the FMOD Designer application to a currently running program using FMOD Designer library. This allow to change in realtime the settings of the FMOD Designer project used by this program.

  •  Demo3D aquivalent of Geometry_ with FMOD Designer

  •  ProgrammerSound use of EVENT_CALLBACK callback.
     

Previous Projectt

Back

Next Project