|
(ma.a/255.0+aa)/2;}//c1.circle(0.01*sin(5*(1 -ar*ag*ab)*t));//c1.arc(0.01*sin(5*(1 -ar*ag*ab)*t));//c1.zoom(0.01*sin(5*(1 -ar*ag*ab)*t));//if(c1.fov>2.0){//c1.fov=2.0;//}elseif(c1.fo v<0.5){//c1.fov=0.5;//}//println(""+c1.fov);//c1.tumble(0.01 *sin(5*ag*t),0.01*sin(5*ab*t));cursor(CROSS);floatsoglia=ran dom(1);if(alv<16){if(soglia>0.9){floats2=random(1);if(s2>0.5 ||automas.size()==0){MAutomaa=newMAutoma();a.moveTo(random(W ),random(H));try{automas.addElement(a);}catch(Exceptionexhi) {println("[1]");exhi.printStackTrace();}}else{intmother= -1;intfather= -1;MAutomam=null;MAutomaf=null;intcount=0;try{while(((m==nul l&&f==null)||(!m.alive)||(!f.alive))&&count<5){count++;mothe r=round(random(automas.size() -1));father=round(random(automas.size() -1));m=(MAutoma)automas.elementAt(mother);f=(MAutoma)automas .elementAt(father);}if(mother!=father){m=(MAutoma)automas.el ementAt(mother);f=(MAutoma)automas.elementAt(father);MAutoma son=newMAutoma();son.baseFrequency=(m.baseFrequency+f.baseFr equency)/2.0;son.expressivity=(m.expressivity+f.expressivity )/2.0;son.x=(m.x+f.x)/2.0;son.y=(m.y+f.y)/2.0;son.r=(m.r+f.r )/2.0;son.g=(m.g+f.g)/2.0;son.b=(m.b+f.b)/2.0;son.a=(m.a+f.a )/2.0;automas.addElement(son);}}catch(Exceptionexhi){println ("[2]");exhi.printStackTrace();}}}}t=t+tInc;if(!pf){colorbk= color(255,0,0,255);//background(bk);noStroke();fill(bk);rect (-10*W, -10*H,20*W,20*H);pf=true;bk=color(255,255,255,255);noStroke( );fill(bk);rect(0,0,W,H);pf=true;}dimension=sqrt(W*W+H*H);// c1.roll((howManyDeaths+1)/(automas.size()+1));//c1.zoom(2000 .0*sin(t));//rotateY(t);for(inti=0;i wards(mouseX,mouseY,130);a.socialize(automas,bfDiv,expDiv);a .draw(bfDiv,expDiv);}}catch(Exceptionexhi){println("[3]");ex hi.printStackTrace();}}try{floatbarsiz=(float)H/(float)sound Trees.length;floatbx=8;intdc=8;colorbc1=color(255,255,255,10 0);colorbc2=color(80,0,80,100);for(inti=0;i ].size()*bx,barsiz-dc);rect(W -soundTrees[i].size()*bx,i*barsiz+dc,soundTrees[i].size()*bx ,barsiz -dc);}}catch(Exceptionexhi){println("[4]");exhi.printStackTr ace();}}catch(ExceptionexGen){exGen.printStackTrace();}}void liveOutputEvent(){//PopulatetheLiveOutput.data[]dataarraywit hasine -wave./*intpart=round((float)LiveOutput.data.length/(float)( automas.size() -howManyDeaths));floatmaxDist=sqrt((W/2.0)*(W/2.0)+(H/2.0)*( H/2.0));intwhich=0;for(intk=0;k a=sqrt((a.x-W/2.0)*(a.x-W/2.0)+(a.y-H/2.0)*(a.y -H/2.0));//floatval=3*(1 -a.stress)*(a.baseFrequency*a.x+a.expressivity)*dista/maxDis t;//println("dista/maxDist="+dista/maxDist+"1-a.stress="+(1 -a.stress)+"bf="+a.baseFrequency);//floatval=(5*(1 -a.stress)*a.baseFrequency*(dista/maxDist)*cos(a.expressivit y));for(inti=0;i -a.stress)*(a.x/W*a.baseFrequency+a.y/H*a.expressivity)+(flo at)i/(float)8);LiveOutput.data[which*part+i]=val;}}}*/intwhi ch=0;try{for(intk=0;k 0;}//println("["+a.stress);if(a.stress>MIN_STRESS_TO_SING){t ry{intpan=0x0A;floatv=a.x;if(v>=W){v=W -1;}elseif(v<0){v=0;}intvalue=127 -round(v/W*127);//println("[which="+which+"][v="+v+"][W="+W+ "][a.x="+a.x+"]");tt++;inttick=tt;intlazyness=round(a.r/16.0 );doublecalmness=round(a.g);intinstrument=round(a.b/255.0*12 7.0);intvelocity=round((a.y/H)*127.0);if(velocity<=10){veloc ity=10;}if(velocity>127){velocity=127;}intnote=round(((((((a .r+a.g)/2)+a.b)/2))/255.0)*(a.x/W)*100.0)+2;if(note>127){not e=127;}elseif(note<0){note=0;}//println("[t="+tick+"]["+valu e+"]["+lazyness+"]["+calmness+"]["+instrument+"]["+velocity+ "]["+note+"]");//synchronized(soundTrees[which]){ ShortMessagemyMsg=newShortMessage(); myMsg.setMessage(ShortMessage.CONTROL_CHANGE,a.which,pan,val ue); SoundEventse=newSoundEvent(); se.message=myMsg; se.timeStamp=tt++; se.waitAfter=(long)(lazyness); se.calmness=calmness;if(soundTrees[which]==null){soundTrees[ which]=newTreeSet();} soundTrees[which].add(se);//println("[2]"); myMsg=newShortMessage(); myMsg.setMessage(ShortMessage.PROGRAM_CHANGE,a.which,instrum ent,1); se=newSoundEvent(); se.message=myMsg; se.timeStamp=tt++; se.waitAfter=(long)(lazyness); se.calmness=calmness;if(soundTrees[which]==null){soundTrees[ which]=newTreeSet();} soundTrees[which].add(se);//println("[3]"); myMsg=newShortMessage(); myMsg.setMessage(ShortMessage.NOTE_ON,a.which,note,velocity) ; se=newSoundEvent(); se.message=myMsg; se.timeStamp=tt++; se.waitAfter=(long)(lazyness); se.calmness=calmness;if(soundTrees[which]==null){soundTrees[ which]=newTreeSet();} soundTrees[which].add(se);//println("[4]"); myMsg=newShortMessage(); myMsg.setMessage(ShortMessage.NOTE_OFF,a.which,note,velocity ); se=newSoundEvent(); se.message=myMsg; se.timeStamp=tt++;//round(tick+10*(a.baseFrequency/MAutoma.M AX_BASE_FREQUENCY));//println("lz="+((long)(5*(v/W)*lazyness ))); se.waitAfter=(long)(5*(v/W)*lazyness); se.calmness=calmness;if(soundTrees[which]==null){soundTrees[ which]=newTreeSet();} soundTrees[which].add(se);//}}catch(Exceptionex){println("[5 ]");//ex.printStackTrace();//System.out.println("***TheGoMwa snotabletoconnect\ntothecosmicforcesneeded\n\ntochant\n\nrea sonisaverse....\n"+ex.toString());}}}//if(a.alive){}//for(in tk=0;k useReleased(){MAutomaa=newMAutoma();a.moveTo(mouseX,mouseY); automas.addElement(a);}voidkeyPressed(){if(key==CODED){if(ke yCode==UP){//bfDiv+=0.1;c1.dolly(0.1);}elseif(keyCode==DOWN) {//bfDiv-=0.1;c1.dolly( -0.1);}elseif(keyCode==RIGHT){expDiv+=0.1;}elseif(keyCode==L EFT){expDiv -=0.1;}}else{if(key=='a'||key=='A'){c1.zoom(0.1);}elseif(key =='z'||key=='Z'){c1.zoom( -0.1);}}}publicclassMAutoma{publicstaticfinalfloatMIN_BASE_F REQUENCY=100;publicstaticfinalfloatMAX_BASE_FREQUENCY=5000;p ublicstaticfinalfloatMIN_EXPRESSIVITY=10;publicstaticfinalfl oatMAX_EXPRESSIVITY=500;publicstaticfinalfloatMIN_GUARD_DIST ANCE=100;publicintMAX_DEATH_NUM=10;publicfloatbaseFrequency; publicfloatexpressivity;publicintage;publicintwhich;publicfl oatx;publicfloaty;publicfloatr;publicfloatg;publicfloatb;pub licfloata;publicfloatstress;booleanalive;publicintdeathCycle ;publicMAutoma(){alive=true;age=0;deathCycle=0;baseFrequency =random(MAutoma.MAX_BASE_FREQUENCY -MAutoma.MIN_BASE_FREQUENCY)+MAutoma.MIN_BASE_FREQUENCY;expr essivity=random(MAutoma.MAX_EXPRESSIVITY -MAutoma.MIN_EXPRESSIVITY)+MAutoma.MIN_EXPRESSIVITY;stress=0 ;r=random(255);g=r;//random(255);b=r;//random(255);a=180;//2 0.0+random(70);which=round(random(15));}publicMAutoma(floatb F,floatexpr,floatrc,floatgc,floatbc,floatac){alive=true;whic h=round(random(15));age=0;deathCycle=0;if(bF a.MAX_BASE_FREQUENCY){bF=MAutoma.MAX_BASE_FREQUENCY;}if(expr ITY;}baseFrequency=bF;expressivity=expr;stress=0;if(rc<0){rc =0;}if(rc>255){rc=255;}if(gc<0){gc=0;}if(gc>255){gc=255;}if( bc<0){bc=0;}if(bc>255){bc=255;}if(ac<20){ac=20;}if(ac>90){ac =90;}r=rc;g=gc;b=bc;a=ac;}publicvoidbirth(){}publicvoidsocia lize(Vectorautomas,floatbfDiv,floatexpDiv){age++;stress=0;in thm=0;try{for(inti=0;i equency&&expressivity!=a.expressivity){floatdx=a.x -x;floatdy=a.y -y;floatdistaa=sqrt(dx*dx+dy*dy);floatstresso=1 -(distaa/dimension);if(stresso>stress){stress=stresso;}if(di staa<(MAutoma.MIN_GUARD_DISTANCE)){hm++;moveTowards(x -dx*(r/a.r),y-dy*(g/a.g),(255.0 -(b/a.b)*255.0));}}}}println("s["+stress+"]");}catch(Excepti onexhi){println("[6]");exhi.printStackTrace();}if(hm>=automa s.size()/2){expressivity=expressivity+stress;}else{expressiv ity=expressivity -stress;}if(expressivity<0){deathCycle++;}else{deathCycle- -;}if(deathCycle>MAX_DEATH_NUM){death();}}publicvoidcoma(){} publicvoiddeath(){alive=false;howManyDeaths++;}publicvoidmov eTo(floatxt,floatyt){x=xt;y=yt;}//speedis%publicvoidmoveTowa rds(floatxt,floatyt,floatspeed){floatfrac=speed;if(frac<=1){ frac=1;}if(frac>255){frac=255;}x=x+(xt-x)/frac;y=y+(yt -y)/frac;}publicvoiddraw(floatbfDiv,floatexpDiv){colorc=colo r(r,g,b,a);if(stress>MIN_STRESS_TO_SING){c=color(r,0,0,a);}c olorbk=color(255,255,255,a);//noStroke();//stroke(bk);//stro keWeight(abs(baseFrequency/(3.0*expressivity)));floatsizb=ba seFrequency/bfDiv;floatsizex=expressivity/expDiv;if(sizb<=0) {sizb=1;}if(sizex<=0){sizex=1;}//translate(0,0,age);//noStro ke();//fill(c);//rect(x-sizb/2.0,y -sizex/2.0,sizb,sizex);stroke(c);noFill();floatmx=stress/2.0 ;floatmy=(1.0 -stress)/2.0;floatq=TWO_PI*(stress)*sin((float)which*t);//bk =color(round(sizex)%255,round(sizb)%255,round(expressivity)% 255,round(baseFrequency)%255);//fill(bk);translate(x,y);rota te(q);beginShape(POLYGON);/*curveVertex(mx*r,my*r);curveVert ex(-mx*g,-my*g);curveVertex(mx*b,-my*b);curveVertex( -mx*a,my*a);*/curveVertex(mx*r,my*0);curveVertex(mx*0,my*g); curveVertex(-mx*b,my*0);curveVertex(mx*0, -my*a);endShape();rotate(-q);translate(-x, -y);//translate(0,0, -age);}}/****Thevoiceofthesingingmultiverseshallbe*expressed bytheGoMSound**thusitwillbeavailableforthe*pleasureoftheGoM* */publicclassGoMSoundextendsThread{publicintchannel;/**Creat esanewinstanceofGoMSound*/publicGoMSound(intch){this.channel =ch;}publicvoidrun(){booleanlive=true;//thesoundofthemultive reshall//existtilltheendoflifewhile(live){if(goOn){longw=10; doubleeventCalmness=1;//democracywillrulethemultiverse////th esongsofthehappyautomataswill//belistenedto//andtheGoMwillre joicein//themwithnopreferences////allinthejoyofpeacetry{if(s oundTrees[channel]==null){soundTrees[channel]=newTreeSet();} if(soundTrees[channel].size()!=0){SoundEventsoundEvent=null; if(soundTrees[channel]==null){soundTrees[channel]=newTreeSet ();}soundEvent=(SoundEvent)soundTrees[channel].iterator().ne xt();if(soundTrees[channel]==null){soundTrees[channel]=newTr eeSet();}soundTrees[channel].remove(soundEvent);if(soundEven t!=null){try{w=round((float)soundEvent.waitAfter/15.0);event Calmness=soundEvent.calmness;synthReceiver.send(soundEvent.m essage, -1);}catch(Exceptionem){println("[a1]");em.printStackTrace() ;}}}}catch(Exceptionexhi){println("[7]");exhi.printStackTrac e();}try{Thread.currentThread().sleep((long)(w));}catch(Exce ptionex){System.out.println("TheCycleofsound["+channel+"]ise nding...");live=false;}}}}}/****Eachsoundoftehuniversewillbe the*aniconforitstime**/publicclassSoundEventimplementsCompar able{/**CreatesanewinstanceofSoundEvent*/publicSoundEvent(){ timeStamp=-1;message=null;waitAfter=0;}publicSoundEvent(Shor tMessagemsg,longt,longw,doublec){timeStamp=t;message=msg;wai tAfter=w;calmness=c;}//hereisthetimetowhichthissoundbelongst opubliclongtimeStamp;//thissoundwillinfluencethecourseoftime ////thelongerthistimelapse,//themoreimportantthesignificance //tothehistoryofthemultiversepubliclongwaitAfter;//soundsare playedinaccordance//withtheanvironmentinwhichtheyare//produc edpublicdoublecalmness;//eachsinglesongwillbeamessageto//the GoM//tohelpHimrejoiceinthe//extasyofHispeoplepublicShortMess agemessage;publicbooleanequals(Objectobj){booleanretValue;re tValue=super.equals(obj);returnretValue;}publicintcompareTo( Objecto){intr=0;if(oinstanceofSoundEvent){r=(int)(this.timeS tamp-((SoundEvent)o).timeStamp);}returnr;}} |
|
(ma.a/255.0+aa)/2;}//c1.circle(0.01*sin(5*(1 -ar*ag*ab)*t));//c1.arc(0.01*sin(5*(1 -ar*ag*ab)*t));//c1.zoom(0.01*sin(5*(1 -ar*ag*ab)*t));//if(c1.fov>2.0){//c1.fov=2.0;//}elseif(c1.fo v<0.5){//c1.fov=0.5;//}//println(""+c1.fov);//c1.tumble(0.01 *sin(5*ag*t),0.01*sin(5*ab*t));cursor(CROSS);floatsoglia=ran dom(1);if(alv<16){if(soglia>0.9){floats2=random(1);if(s2>0.5 ||automas.size()==0){MAutomaa=newMAutoma();a.moveTo(random(W ),random(H));try{automas.addElement(a);}catch(Exceptionexhi) {println("[1]");exhi.printStackTrace();}}else{intmother= -1;intfather= -1;MAutomam=null;MAutomaf=null;intcount=0;try{while(((m==nul l&&f==null)||(!m.alive)||(!f.alive))&&count<5){count++;mothe r=round(random(automas.size() -1));father=round(random(automas.size() -1));m=(MAutoma)automas.elementAt(mother);f=(MAutoma)automas .elementAt(father);}if(mother!=father){m=(MAutoma)automas.el ementAt(mother);f=(MAutoma)automas.elementAt(father);MAutoma son=newMAutoma();son.baseFrequency=(m.baseFrequency+f.baseFr equency)/2.0;son.expressivity=(m.expressivity+f.expressivity )/2.0;son.x=(m.x+f.x)/2.0;son.y=(m.y+f.y)/2.0;son.r=(m.r+f.r )/2.0;son.g=(m.g+f.g)/2.0;son.b=(m.b+f.b)/2.0;son.a=(m.a+f.a )/2.0;automas.addElement(son);}}catch(Exceptionexhi){println ("[2]");exhi.printStackTrace();}}}}t=t+tInc;if(!pf){colorbk= color(255,0,0,255);//background(bk);noStroke();fill(bk);rect (-10*W, -10*H,20*W,20*H);pf=true;bk=color(255,255,255,255);noStroke( );fill(bk);rect(0,0,W,H);pf=true;}dimension=sqrt(W*W+H*H);// c1.roll((howManyDeaths+1)/(automas.size()+1));//c1.zoom(2000 .0*sin(t));//rotateY(t);for(inti=0;i wards(mouseX,mouseY,130);a.socialize(automas,bfDiv,expDiv);a .draw(bfDiv,expDiv);}}catch(Exceptionexhi){println("[3]");ex hi.printStackTrace();}}try{floatbarsiz=(float)H/(float)sound Trees.length;floatbx=8;intdc=8;colorbc1=color(255,255,255,10 0);colorbc2=color(80,0,80,100);for(inti=0;i ].size()*bx,barsiz-dc);rect(W -soundTrees[i].size()*bx,i*barsiz+dc,soundTrees[i].size()*bx ,barsiz -dc);}}catch(Exceptionexhi){println("[4]");exhi.printStackTr ace();}}catch(ExceptionexGen){exGen.printStackTrace();}}void liveOutputEvent(){//PopulatetheLiveOutput.data[]dataarraywit hasine -wave./*intpart=round((float)LiveOutput.data.length/(float)( automas.size() -howManyDeaths));floatmaxDist=sqrt((W/2.0)*(W/2.0)+(H/2.0)*( H/2.0));intwhich=0;for(intk=0;k a=sqrt((a.x-W/2.0)*(a.x-W/2.0)+(a.y-H/2.0)*(a.y -H/2.0));//floatval=3*(1 -a.stress)*(a.baseFrequency*a.x+a.expressivity)*dista/maxDis t;//println("dista/maxDist="+dista/maxDist+"1-a.stress="+(1 -a.stress)+"bf="+a.baseFrequency);//floatval=(5*(1 -a.stress)*a.baseFrequency*(dista/maxDist)*cos(a.expressivit y));for(inti=0;i -a.stress)*(a.x/W*a.baseFrequency+a.y/H*a.expressivity)+(flo at)i/(float)8);LiveOutput.data[which*part+i]=val;}}}*/intwhi ch=0;try{for(intk=0;k 0;}//println("["+a.stress);if(a.stress>MIN_STRESS_TO_SING){t ry{intpan=0x0A;floatv=a.x;if(v>=W){v=W -1;}elseif(v<0){v=0;}intvalue=127 -round(v/W*127);//println("[which="+which+"][v="+v+"][W="+W+ "][a.x="+a.x+"]");tt++;inttick=tt;intlazyness=round(a.r/16.0 );doublecalmness=round(a.g);intinstrument=round(a.b/255.0*12 7.0);intvelocity=round((a.y/H)*127.0);if(velocity<=10){veloc ity=10;}if(velocity>127){velocity=127;}intnote=round(((((((a .r+a.g)/2)+a.b)/2))/255.0)*(a.x/W)*100.0)+2;if(note>127){not e=127;}elseif(note<0){note=0;}//println("[t="+tick+"]["+valu e+"]["+lazyness+"]["+calmness+"]["+instrument+"]["+velocity+ "]["+note+"]");//synchronized(soundTrees[which]){ ShortMessagemyMsg=newShortMessage(); myMsg.setMessage(ShortMessage.CONTROL_CHANGE,a.which,pan,val ue); SoundEventse=newSoundEvent(); se.message=myMsg; se.timeStamp=tt++; se.waitAfter=(long)(lazyness); se.calmness=calmness;if(soundTrees[which]==null){soundTrees[ which]=newTreeSet();} soundTrees[which].add(se);//println("[2]"); myMsg=newShortMessage(); myMsg.setMessage(ShortMessage.PROGRAM_CHANGE,a.which,instrum ent,1); se=newSoundEvent(); se.message=myMsg; se.timeStamp=tt++; se.waitAfter=(long)(lazyness); se.calmness=calmness;if(soundTrees[which]==null){soundTrees[ which]=newTreeSet();} soundTrees[which].add(se);//println("[3]"); myMsg=newShortMessage(); myMsg.setMessage(ShortMessage.NOTE_ON,a.which,note,velocity) ; se=newSoundEvent(); se.message=myMsg; se.timeStamp=tt++; se.waitAfter=(long)(lazyness); se.calmness=calmness;if(soundTrees[which]==null){soundTrees[ which]=newTreeSet();} soundTrees[which].add(se);//println("[4]"); myMsg=newShortMessage(); myMsg.setMessage(ShortMessage.NOTE_OFF,a.which,note,velocity ); se=newSoundEvent(); se.message=myMsg; se.timeStamp=tt++;//round(tick+10*(a.baseFrequency/MAutoma.M AX_BASE_FREQUENCY));//println("lz="+((long)(5*(v/W)*lazyness ))); se.waitAfter=(long)(5*(v/W)*lazyness); se.calmness=calmness;if(soundTrees[which]==null){soundTrees[ which]=newTreeSet();} soundTrees[which].add(se);//}}catch(Exceptionex){println("[5 ]");//ex.printStackTrace();//System.out.println("***TheGoMwa snotabletoconnect\ntothecosmicforcesneeded\n\ntochant\n\nrea sonisaverse....\n"+ex.toString());}}}//if(a.alive){}//for(in tk=0;k useReleased(){MAutomaa=newMAutoma();a.moveTo(mouseX,mouseY); automas.addElement(a);}voidkeyPressed(){if(key==CODED){if(ke yCode==UP){//bfDiv+=0.1;c1.dolly(0.1);}elseif(keyCode==DOWN) {//bfDiv-=0.1;c1.dolly( -0.1);}elseif(keyCode==RIGHT){expDiv+=0.1;}elseif(keyCode==L EFT){expDiv -=0.1;}}else{if(key=='a'||key=='A'){c1.zoom(0.1);}elseif(key =='z'||key=='Z'){c1.zoom( -0.1);}}}publicclassMAutoma{publicstaticfinalfloatMIN_BASE_F REQUENCY=100;publicstaticfinalfloatMAX_BASE_FREQUENCY=5000;p ublicstaticfinalfloatMIN_EXPRESSIVITY=10;publicstaticfinalfl oatMAX_EXPRESSIVITY=500;publicstaticfinalfloatMIN_GUARD_DIST ANCE=100;publicintMAX_DEATH_NUM=10;publicfloatbaseFrequency; publicfloatexpressivity;publicintage;publicintwhich;publicfl oatx;publicfloaty;publicfloatr;publicfloatg;publicfloatb;pub licfloata;publicfloatstress;booleanalive;publicintdeathCycle ;publicMAutoma(){alive=true;age=0;deathCycle=0;baseFrequency =random(MAutoma.MAX_BASE_FREQUENCY -MAutoma.MIN_BASE_FREQUENCY)+MAutoma.MIN_BASE_FREQUENCY;expr essivity=random(MAutoma.MAX_EXPRESSIVITY -MAutoma.MIN_EXPRESSIVITY)+MAutoma.MIN_EXPRESSIVITY;stress=0 ;r=random(255);g=r;//random(255);b=r;//random(255);a=180;//2 0.0+random(70);which=round(random(15));}publicMAutoma(floatb F,floatexpr,floatrc,floatgc,floatbc,floatac){alive=true;whic h=round(random(15));age=0;deathCycle=0;if(bF a.MAX_BASE_FREQUENCY){bF=MAutoma.MAX_BASE_FREQUENCY;}if(expr ITY;}baseFrequency=bF;expressivity=expr;stress=0;if(rc<0){rc =0;}if(rc>255){rc=255;}if(gc<0){gc=0;}if(gc>255){gc=255;}if( bc<0){bc=0;}if(bc>255){bc=255;}if(ac<20){ac=20;}if(ac>90){ac =90;}r=rc;g=gc;b=bc;a=ac;}publicvoidbirth(){}publicvoidsocia lize(Vectorautomas,floatbfDiv,floatexpDiv){age++;stress=0;in thm=0;try{for(inti=0;i equency&&expressivity!=a.expressivity){floatdx=a.x -x;floatdy=a.y -y;floatdistaa=sqrt(dx*dx+dy*dy);floatstresso=1 -(distaa/dimension);if(stresso>stress){stress=stresso;}if(di staa<(MAutoma.MIN_GUARD_DISTANCE)){hm++;moveTowards(x -dx*(r/a.r),y-dy*(g/a.g),(255.0 -(b/a.b)*255.0));}}}}println("s["+stress+"]");}catch(Excepti onexhi){println("[6]");exhi.printStackTrace();}if(hm>=automa s.size()/2){expressivity=expressivity+stress;}else{expressiv ity=expressivity -stress;}if(expressivity<0){deathCycle++;}else{deathCycle- -;}if(deathCycle>MAX_DEATH_NUM){death();}}publicvoidcoma(){} publicvoiddeath(){alive=false;howManyDeaths++;}publicvoidmov eTo(floatxt,floatyt){x=xt;y=yt;}//speedis%publicvoidmoveTowa rds(floatxt,floatyt,floatspeed){floatfrac=speed;if(frac<=1){ frac=1;}if(frac>255){frac=255;}x=x+(xt-x)/frac;y=y+(yt -y)/frac;}publicvoiddraw(floatbfDiv,floatexpDiv){colorc=colo r(r,g,b,a);if(stress>MIN_STRESS_TO_SING){c=color(r,0,0,a);}c olorbk=color(255,255,255,a);//noStroke();//stroke(bk);//stro keWeight(abs(baseFrequency/(3.0*expressivity)));floatsizb=ba seFrequency/bfDiv;floatsizex=expressivity/expDiv;if(sizb<=0) {sizb=1;}if(sizex<=0){sizex=1;}//translate(0,0,age);//noStro ke();//fill(c);//rect(x-sizb/2.0,y -sizex/2.0,sizb,sizex);stroke(c);noFill();floatmx=stress/2.0 ;floatmy=(1.0 -stress)/2.0;floatq=TWO_PI*(stress)*sin((float)which*t);//bk =color(round(sizex)%255,round(sizb)%255,round(expressivity)% 255,round(baseFrequency)%255);//fill(bk);translate(x,y);rota te(q);beginShape(POLYGON);/*curveVertex(mx*r,my*r);curveVert ex(-mx*g,-my*g);curveVertex(mx*b,-my*b);curveVertex( -mx*a,my*a);*/curveVertex(mx*r,my*0);curveVertex(mx*0,my*g); curveVertex(-mx*b,my*0);curveVertex(mx*0, -my*a);endShape();rotate(-q);translate(-x, -y);//translate(0,0, -age);}}/****Thevoiceofthesingingmultiverseshallbe*expressed bytheGoMSound**thusitwillbeavailableforthe*pleasureoftheGoM* */publicclassGoMSoundextendsThread{publicintchannel;/**Creat esanewinstanceofGoMSound*/publicGoMSound(intch){this.channel =ch;}publicvoidrun(){booleanlive=true;//thesoundofthemultive reshall//existtilltheendoflifewhile(live){if(goOn){longw=10; doubleeventCalmness=1;//democracywillrulethemultiverse////th esongsofthehappyautomataswill//belistenedto//andtheGoMwillre joicein//themwithnopreferences////allinthejoyofpeacetry{if(s oundTrees[channel]==null){soundTrees[channel]=newTreeSet();} if(soundTrees[channel].size()!=0){SoundEventsoundEvent=null; if(soundTrees[channel]==null){soundTrees[channel]=newTreeSet ();}soundEvent=(SoundEvent)soundTrees[channel].iterator().ne xt();if(soundTrees[channel]==null){soundTrees[channel]=newTr eeSet();}soundTrees[channel].remove(soundEvent);if(soundEven t!=null){try{w=round((float)soundEvent.waitAfter/15.0);event Calmness=soundEvent.calmness;synthReceiver.send(soundEvent.m essage, -1);}catch(Exceptionem){println("[a1]");em.printStackTrace() ;}}}}catch(Exceptionexhi){println("[7]");exhi.printStackTrac e();}try{Thread.currentThread().sleep((long)(w));}catch(Exce ptionex){System.out.println("TheCycleofsound["+channel+"]ise nding...");live=false;}}}}}/****Eachsoundoftehuniversewillbe the*aniconforitstime**/publicclassSoundEventimplementsCompar able{/**CreatesanewinstanceofSoundEvent*/publicSoundEvent(){ timeStamp=-1;message=null;waitAfter=0;}publicSoundEvent(Shor tMessagemsg,longt,longw,doublec){timeStamp=t;message=msg;wai tAfter=w;calmness=c;}//hereisthetimetowhichthissoundbelongst opubliclongtimeStamp;//thissoundwillinfluencethecourseoftime ////thelongerthistimelapse,//themoreimportantthesignificance //tothehistoryofthemultiversepubliclongwaitAfter;//soundsare playedinaccordance//withtheanvironmentinwhichtheyare//produc edpublicdoublecalmness;//eachsinglesongwillbeamessageto//the GoM//tohelpHimrejoiceinthe//extasyofHispeoplepublicShortMess agemessage;publicbooleanequals(Objectobj){booleanretValue;re tValue=super.equals(obj);returnretValue;}publicintcompareTo( Objecto){intr=0;if(oinstanceofSoundEvent){r=(int)(this.timeS tamp-((SoundEvent)o).timeStamp);}returnr;}} |