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();
}
}
I was faced this issue on Windows 10 64-bit and was able to resolve the problem by manually creating the following registry key.
HKEY_LOCAL_MACHINE\Software\JavaSoft\Prefs
Hope this helps for the Windows users.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With