Skip to content

Instantly share code, notes, and snippets.

@Crydust
Created February 26, 2013 14:11
Show Gist options
  • Save Crydust/5038675 to your computer and use it in GitHub Desktop.
Save Crydust/5038675 to your computer and use it in GitHub Desktop.
Beeper.java is a replacement for the failing System.out.prinln('\007'); it simply beeps, which is useful for debugging
import javax.sound.midi.MidiChannel;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.Synthesizer;
public class Beeper {
public static void main(String[] args) throws Exception {
beep();
}
private static void beep() {
try {
Synthesizer synth = MidiSystem.getSynthesizer();
synth.open();
MidiChannel channels[] = synth.getChannels();
channels[1].noteOn(64, 127);
Thread.sleep(1000);
channels[1].noteOff(64);
synth.close();
} catch (Exception exc) {
exc.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment