Game Music Slowdown

Hi, I'm making a 2D platformer and I added a thread (with the lowest priority) that will play midi files. The game now runs noticeably slower (it used to use roughly 2 -10% of my 1.73 gHz CPU, now with midi music it now uses about 40-75%)

I've also tried this with .ogg and .mp3 files and they all have the same problem

Here is the thread class I'm using:

publicclass MusicThreadextends Thread

{

public MusicThread(String filename)

{

super(filename);

}

publicvoid run()

{

try

{

Sequencer seqr = MidiSystem.getSequencer();

Sequence seq = MidiSystem.getSequence(new File(this.getName()));

seqr.open();

seqr.setSequence(seq);

seqr.start();

}

catch(Exception ex)

{

ex.printStackTrace();

}

}

}

does anyone know how I can improve the performance?

[1532 byte] By [Rabid_Sponge] at [2007-9-30 11:54:01]
# 1
How are you guys doing music?
Rabid_Sponge at 2007-7-4 13:51:28 > top of Java-index,Other Topics,Java Game Development...
# 2
I haven't tried adding music to my games yet, but you may find some tips [url http://fivedots.coe.psu.ac.th/~ad/jg/ch05/index.html]here[/url] or [url http://www.brackeen.com/javagamebook/]here[/url]I hope they help-JBoeing
jboeing at 2007-7-4 13:51:28 > top of Java-index,Other Topics,Java Game Development...
# 3
I think that your problem is in the run method that you are always creating and reading the file. Try put it on the constructor
luisoft at 2007-7-4 13:51:28 > top of Java-index,Other Topics,Java Game Development...
# 4

The way that a thread's run method works is that it doesn't execute the run method over and over again, it simply executes the run method until it returns.(At least I think this is the way it works) But, I moved everything but the "seqr.start()" call to the constructor and it still runs slowly.

Also, when the music thread or the game are run in separate progams, each has a very minimal CPU usage (2-10%). But when they're run in the same application, they eat up resources.

Rabid_Sponge at 2007-7-4 13:51:28 > top of Java-index,Other Topics,Java Game Development...