Jan 14, 2017 10:44:54 PM java.util.prefs.WindowsPreferences WARNING: Could not open / create prefs root node Software \ JavaSoft \ Prefs at root 0x80000002. Windows RegCreateKeyEx (...) returned error code 5.
import javax.sound.midi.*; public class MiniMusicCmdLine { public static void main(String[] args) { MiniMusicCmdLine mini = new MiniMusicCmdLine(); int instrument = 80; int note = 20; mini.play(instrument , note); } public void play(int instrument, int note) { try { Sequencer player = MidiSystem.getSequencer(); player.open(); Sequence seq = new Sequence(Sequence.PPQ, 4); Track track = seq.createTrack(); MidiEvent event = null; ShortMessage first = new ShortMessage(); first.setMessage(192, 1, instrument, 0); MidiEvent changeInstrument = new MidiEvent(first, 1); track.add(changeInstrument); ShortMessage a = new ShortMessage(); a.setMessage(144, 1, note, 100); MidiEvent noteOn = new MidiEvent(a, 1); track.add(noteOn); ShortMessage b = new ShortMessage(); b.setMessage(128, 1, note, 100); MidiEvent noteOff = new MidiEvent(b, 1); track.add(noteOff); player.setSequence(seq); player.start(); } catch (Exception ex) { ex.printStackTrace(); } } } Is there something wrong with the arguments? I removed the check and the parsint method for the instrument and note arguments from Maine, replacing them with numbers .. for changing the instrument and the note .. gives an error .. but I don’t hear any sounds) The console program was initially .. but I changed the code in Maine and tried run it in IDEA, because I don’t understand how to run it through cmd