I am trying to get MIDI audio to play, but when ever I do this it keeps returning the error `
May 18, 2014 10:23:29 AM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root
0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
I have gone into regedit
and my permissions are on EVERYONE
, but it just doesn't want to work.
CODE
import javax.sound.midi.Instrument;
import javax.sound.midi.MidiChannel;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Synthesizer;
public class Sound {
public static void main(String args[]) throws MidiUnavailableException {
int channel = 0;
int volume = 80;
int duration = 200;
Synthesizer synth;
synth = MidiSystem.getSynthesizer();
synth.open();
MidiChannel[] channels = synth.getChannels();
channels[channel].noteOn(60, volume); // C note
synth.close();
}
}