Hello Guest

FMOD slows down my project

  • 4 Replies
  • 19453 Views
FMOD slows down my project
« on: June 06, 2005, 14:18:37 »
I use FMOD in a program with a JFileChooser and other Swing components. The problem is that the moment fmod is created, the filechooser is slow to move between directories.
Are there any specific reasons for this?

FMOD slows down my project
« Reply #1 on: June 06, 2005, 14:29:21 »
Never mind. I seem to have solved the problem by explcitly creating FMOD earlier in my project. It's odd though...

*

Offline Matzon

  • *****
  • 2242
FMOD slows down my project
« Reply #2 on: June 06, 2005, 15:40:09 »
hmm, I am not aware of any performance issues by just creating FMOD ??

FMOD slows down my project
« Reply #3 on: June 06, 2005, 16:10:46 »
If I referenced this class early in my project, the slow browsing problem disappeared. This class is supposed to be created only once, right? But isn't instantiated before the instance is referenced, so it can't have anything to do with garbage collection?

Code: [Select]

import org.lwjgl.fmod3.FMOD;
import org.lwjgl.fmod3.FMODException;
import org.lwjgl.fmod3.FSound;
import org.lwjgl.fmod3.FSoundStream;
import static org.lwjgl.fmod3.FSound.*;

public class SoundPlayer {
    public static final SoundPlayer instance = new SoundPlayer();

    private SoundPlayer() {
        init();
    }

    private void init() {
        try {
            FMOD.create();
            FSOUND_SetOutput(FSOUND_OUTPUT_DSOUND);
            FSOUND_Init(44100, 32, 0);
        } catch (FMODException e) {
            System.out.println("Error:" + FMOD.FMOD_ErrorString(FSOUND_GetError()));
            e.printStackTrace();
        }
    }

    public void play(String file) {
        file = file.replaceAll("\\\\", "/");

        FSoundStream stream = FSound.FSOUND_Stream_Open(file, FSound.FSOUND_NORMAL, 0, 0);
        FSOUND_Stream_SetMode(stream, FSOUND_LOOP_OFF);
        FSound.FSOUND_Stream_Play(1, stream);
    }

    public void stop() {
        FSOUND_StopSound(FSOUND_ALL);
    }

    public static void destroy() {
        FSOUND_Close();
        FMOD.destroy();
    }
}

FMOD slows down my project
« Reply #4 on: June 08, 2005, 16:08:32 »
Making sure that FMOD is created early and not when used, solved my problem.

Thanks for the work on this API, it's great!