Midi-Sound in Java 1.5?

R

Rene Schmidt

Why doen't the following code work in Java 1.5. It used to work in Java 1.4,
but in 1.5 I get nothing but silence.

Thanks for any help.

---------------------- snip

import javax.sound.midi.*;

public class Test
{ static boolean Warning=false;

public static void beep (int note, int dur)
{ try
{ Synthesizer synth=MidiSystem.getSynthesizer();
synth.open();
MidiChannel[] channels=synth.getChannels();
MidiChannel channel=channels[0];
channel.programChange(0);
channel.noteOn(note,50);
Thread.sleep(dur);
channel.noteOff(50);
synth.close();
}
catch (Exception e)
{ System.out.println(e);
}
}

public static void main(String[] args)
{ beep(60,1000);
beep(62,1000);
beep(60,2000);
System.exit(0);
}
}
 
A

Andrew Thompson

Why doen't the following code work in Java 1.5. It used to work in Java 1.4,
but in 1.5 I get nothing but silence.

I suspect the problem is your hardware or sound card.

I tested your code on WinXP running both 1.4.2_01 and 1.5.0-beta
and got three piano notes each run.

HTH
 
R

Rene Schmidt

It is not a bug, it's a feature! Sun has removed the midi sounds from the
JRE. You can copy the old sounds from lib/audio/soundbank.gm to the new JRE,
or download a sound bank from Sun.

Midi seems to be widely unused, or at least, Sun thinks so. Why else would
they jeopardize my Web applet?

I sent a bug report, nevertheless.

Rene
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,262
Messages
2,571,056
Members
48,769
Latest member
Clifft

Latest Threads

Top