3

I'm using javax's midi classes to play a MIDI in the background of my program.

When I compile in Eclipse, the MIDI plays fine but there is some sort of weird echoing feedback noise which is almost as loud as the MIDI itself.

My code:

public class BGM {

private String filename;
Sequencer sequencer;
Sequence sequence;

public BGM(String filename){

try{

    sequence = MidiSystem.getSequence(new File(filename));
    sequencer = MidiSystem.getSequencer();
    sequencer.open();
    sequencer.setSequence(sequence);

    sequencer.start();
    } catch(Exception e){


}

}
}

This has been the case with every sound file i've tried to play from Java, in my code or anyone else's. MP3, wav or midi.

If you'd like a sample of the sound I can get that too

Thanks for the help! :D

Celeritas
  • 14,489
  • 36
  • 113
  • 194
  • Do you get that effect from the two samples on the [JavaSound info. page](http://stackoverflow.com/tags/javasound/info)? You may need to change the sound for the first source, as it might be hard to detect an echo in such a basic sample (monotones oscillating in loudness). BTW - never ignore exceptions in broken code, call `e.printStackTrace()` inside the `catch`. – Andrew Thompson Mar 01 '12 at 13:59
  • It would be useful to know your OS. Might be something to do with a particular Java implementation, such as on a Linux OS. If it happens with all code, the problem is probably not in the code, yes? I assume non-Java sounds are fine. Echos are very specific--the sound you heard repeats. Are there actual repetitions at certain time intervals? There is also aliasing that can happen which sounds "weird". – Phil Freihofner Mar 02 '12 at 18:50
  • The question seems to imply this only happens when you compile with Eclipse, is this the case? Is that what you mean to imply? – Celeritas Jan 09 '13 at 04:34
  • Or could it be, that setting a sequence implies that this sequence gets looped? –  Sep 03 '13 at 06:37

0 Answers0