java - Error Code Returned when using Midi Sequencer -
i have been playing midi sequencer , doing exercise involving repainting squares on panel in random colors, shapes, , locations based on beat of music using controleventlistener. when on laptop, works fine. however, when on pc, error:
aug 07, 2013 1:10:11 pm java.util.prefs.windowspreferences <init> warning: not open/create prefs root node software\javasoft\prefs @ root 0x80000002. windows regcreatekeyex(...) returned error code 5. build successful (total time: 27 seconds)
the program works fine. compiles , it's supposed do, and, stated earlier, have no problems exact code on laptop.
also, of code taken out of book java, made few changes panel tweak code same thing little differently. know code means? i've googled , found nothing. book states nothing kind of code.
any appreciated. thank in advance time reading , time spend helping question.
this code in entirity: import javax.swing.*; import java.awt.*; import javax.sound.midi.*; public class check implements controllereventlistener{ jframe frame; drawpanel dp; public void controlchange(shortmessage a) { frame.repaint(); } public static void main(string[] args) { new check().buildgui(); } private void buildgui() { frame = new jframe("woot"); frame.setdefaultcloseoperation(jframe.exit_on_close); dp = new drawpanel(); frame.getcontentpane().add(dp); frame.setvisible(true); frame.setsize(500, 500); frame.setresizable(false); frame.setlocation(375, 50); playmusic(); } private void playmusic() { try { sequencer sequencer = midisystem.getsequencer(); sequencer.open(); int[] trackedint = {127}; sequencer.addcontrollereventlistener(this, trackedint); sequence seq = new sequence(sequence.ppq,4); track track = seq.createtrack(); for(int = 0; < 50; i++) { int ri = (int)(math.random()*50)+30; track.add(makeevent(144,9,ri,100,i*10)); track.add(makeevent(176,1,127,0,i*10)); track.add(makeevent(128,9,ri,0,i*2+2)); } sequencer.setsequence(seq); sequencer.settempoinbpm(160); sequencer.start(); } catch(exception exc){} } private midievent makeevent(int comd, int chan, int one, int two, int tick) { midievent event = null; try { shortmessage = new shortmessage(); a.setmessage(comd, chan, one, two); event = new midievent(a, tick); } catch (exception exc){} return event; } } class drawpanel extends jpanel { public void paintcomponent(graphics g) { int r = (int)(math.random()*256); int gr = (int)(math.random()*256); int b = (int)(math.random()*256); g.setcolor(new color(r,gr,b)); int x = (int)(math.random()*200)+20; int y = (int)(math.random()*200)+20; int h = (int)(math.random()*500)+20; int w = (int)(math.random()*500)+20; g.fillrect(x, y, w, h); } }
just let warning log shut up:
platformlogger.getlogger("java.util.prefs") .setlevel(platformlogger.level.severe);
Comments
Post a Comment