import rwmidi.*; import processing.opengl.*; PFont myFont; Effect[] efs = new Effect[10]; int efCnt = 0; MidiOutput output; int ch_s = 0; int pit_s = 60; int vel_s = 120; int program_s; int device_s; int org_mouseX; int org_mouseY; void setup() { size( 800,380 ); stroke( #05F060 ); noFill(); strokeWeight(10); for(int i=0; i= RWMidi.getOutputDevices().length ){ device_s=0; } output = RWMidi.getOutputDevices()[device_s].createOutput(); println( output.getName() ); int retx = output.sendProgramChange(program_s); } else { program_s = program_s+1; if( program_s > 127 ){ program_s =0; } int retx = output.sendProgramChange(program_s); } } else { org_mouseX = mouseX; org_mouseY = mouseY; // line(); efs[efCnt].startObj( mouseX, mouseY ); efCnt++; if( efCnt == efs.length ){ efCnt=0; } // Midi Out int iw; iw = int( width / 24 ); pit_s = 60 + int( mouseX/iw ); vel_s = 100; // int(mouseY/(height/128.0)); println( vel_s ); if( vel_s < 128 ){ // output.sendPitchBend( ch_s, 8192 ); output.sendController( ch_s, 11, vel_s ); output.sendNoteOn( ch_s, pit_s, vel_s); } } } void mouseReleased() { println( "mouse released" ); output.sendNoteOff( ch_s, pit_s, vel_s); } void mouseDragged() { // Xdrag で Bent print( "mouse dragged " ); int bend = (mouseX - org_mouseX)*8+8192; if( bend<0 ){ bend=0; } if( bend>16383 ){ bend=16383; } println( bend ); output.sendPitchBend( ch_s, bend ); // Ydrag で Volume... int v = vel_s - int(( org_mouseY-mouseY )/4); if( v < 0 ){ v=0; } if( v > 127 ){ v=127; } output.sendController( ch_s, 11, v ); } class Effect { int px; int py; int dBright = 10; boolean drawFlg = false; int cR = 0; int cG = 240; int cB = 96; float angle=0; int objType = 0; int strokeW = 20; float rAngle; float dAngle = 20; int rSize; int dSize = 20; Effect() { } void startObj(int x,int y ) { this.px = x; this.py = y; this.drawFlg = true; this.angle = random(0, 360 ); cR = 0; cG = 240; cB = 96; objType = int(random(0,4)); rAngle = angle; rSize = strokeW; noFill(); } void display() { if( drawFlg ){ // 座標形の変更 strokeWeight(strokeW); stroke( cR, cG, cB ); cR = cR - dBright; if( cR<0 ){ cR=0; } cG = cG - dBright; if( cG<0 ){ cG=0; } cB = cB - dBright; if( cB<0 ){ cB=0; } if( cR==0 && cG==0 && cB==0 ){ drawFlg = false; } pushMatrix(); translate( px,py ); rotate( radians( angle ) ); if( objType==0 ){ // 線 strokeWeight(strokeW*2); line( 1024,0, -1024,0 ); } else if( objType == 1 ){ // ○ ellipse( 0,0, rSize, rSize ); ellipse( 0,0, rSize+50, rSize+50 ); rSize = rSize + dSize; } else if( objType == 2 ){ // □ rectMode( CENTER ); rotate( radians( rAngle ) ); rect( 0, 0, rSize, rSize ); rSize = rSize + dSize; rAngle = rAngle + dAngle; } else if( objType == 3 ){ // △ // dx = sin( 60 ); float dx,dy; dx = rSize * cos( radians( 60 ) ); dy = rSize * sin( radians( 60 ) ); rotate( radians( rAngle ) ); triangle( 0, int(dy*2/3), int(dx), int(-dy/3), int(-dx), int(-dy/3) ); rSize = rSize + dSize; rAngle = rAngle + dAngle; } popMatrix(); } } }