Created
February 26, 2013 14:11
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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