Cara, assim funcionou aqui na minha máquina:
channel.noteOn(nota, 90);
Thread.sleep(1000);
channel.noteOff(nota, 90);
Entendi que é preciso um tempo entre ligar e desligar a nota.
No caso do seu piano, pode dar o noteOn quando apertar a tecla e noteOff quando soltar.
Só não entendi porque é que no notebook funciona!!
E finalizando, uma observação: que negócio da hora!
Queria agradecer ao autor do tópico por ter me apresentado essa API :D
De quebra, segue minha obra-prima:
private static void playSong() throws MidiUnavailableException, InterruptedException {
Synthesizer synth;
synth = MidiSystem.getSynthesizer();
synth.open();
MidiChannel channel = synth.getChannels()[1];
int doo = 60;
int re = 62;
int mi = 64;
int fa = 65;
int sol = 67;
int silencio = 0;
int umtempo = 250;
int doistempos = 500;
playNote(channel, doo, umtempo);
playNote(channel, re, umtempo);
playNote(channel, mi, umtempo);
playNote(channel, fa, doistempos);
playNote(channel, fa, umtempo);
playNote(channel, fa, umtempo);
playNote(channel, silencio, umtempo);
playNote(channel, doo, umtempo);
playNote(channel, re, umtempo);
playNote(channel, doo, umtempo);
playNote(channel, re, doistempos);
playNote(channel, re, umtempo);
playNote(channel, re, umtempo);
playNote(channel, silencio, umtempo);
playNote(channel, doo, umtempo);
playNote(channel, sol, umtempo);
playNote(channel, fa, umtempo);
playNote(channel, mi, doistempos);
playNote(channel, mi, umtempo);
playNote(channel, mi, umtempo);
playNote(channel, silencio, umtempo);
playNote(channel, doo, umtempo);
playNote(channel, re, umtempo);
playNote(channel, mi, umtempo);
playNote(channel, fa, doistempos);
playNote(channel, fa, umtempo);
playNote(channel, fa, doistempos);
synth.close();
}
private static void playNote(MidiChannel channel, int nota, int tempo) throws InterruptedException {
channel.noteOn(nota, 90);
Thread.sleep(tempo);
channel.noteOff(nota, 90);
}