On Tuesday, September 18, 2012 at 8:19 PM, Spencer Salazar wrote:
Hey Jeff,One issue that popped up on 10.7 is that builtin trackpads would showup twice in the list of available mouse devices, and only the secondone (index #1) would actually produce input. So changing the devicenumber to 1 when opening the mouse will probably fix it for 10.7users, as it does on my (10.7) machine.Its curious that this is not an issue on 10.8, though. Weird.spencerOn Wed, Sep 19, 2012 at 1:14 AM, Jeff Albert <jvalbert@loyno.edu> wrote:Hi all,We are doing a piece in our laptop orch that uses Hid input from thekeyboard and mouse. The group does not have matching machines. All but 1 areMacs, with the OS ranging from 10.6.x to 10.8.2. The code (pasted below)works on the windows machine and the 10.6 and 10.8 Macs, but not on any ofthe machines running OS 10.7.4.Thoughts?Thanks,Jeff--Jeff AlbertAssistant Professor (Extraordinary) of Music Industry StudiesLoyola University New OrleansOffice: Communications/Music Complex 428POffice Phone: (504) 865-2606Google Voice: (504) 315-5167// ----------------------------------------------------------------// Mouse Bow (v1)// by Jeff Lipscomb (February 9, 2010)//// The keyboard controls the pitch of this instrument,// while the mouse controls both the loudness and the timbre.// Clicking any button will turn the note on,// while unclicking that button will turn it off.// The SPEED of the left-right motion controls how loud the note is// (the faster the motion, the louder it will be.)// The up-down position of the mouse on the screen controls how// bright/complex the note's timbre will be.// (the higher up, the more brighter it will be.)//// (push key that wasn't mapped for a really cool sound, like '~')// ----------------------------------------------------------------//// some tuning and timbre-related variables600.0 => float cFrq;18.07 => float nDiv;2.01 => float mRat;950.0 => float hFlt;400.0 => float lFlt;// initialize and test for a mouseHid hi;HidMsg msg;0 => int device;if( me.args() ) me.arg(0) => Std.atoi => device;if( !hi.openMouse( device ) ) me.exit();// UGen gutsSinOsc mod => SinOsc car => ADSR e => LPF f1 => HPF f2 => Chorus c => JCRevr => dac;e.set( 10::ms, 5::ms, .85, 10::ms );e.keyOff();// initial parameters for the UGenscFrq => car.freq;cFrq * mRat => mod.freq; //1.07aahFlt => f1.freq;lFlt => f2.freq;1000.0 => mod.gain;0.0 => e.gain;// sync is for an FM instrument2 => car.sync;// initializing variables for controlling functionint base;float a0;float a1;float a2;float a3;int count;// initialize keyboard array// MIDI pitch numbers are assigned to most of the keys// which are represented by their ASCII numbersint kb[112];49 => kb[90]; // z50 => kb[88]; // x51 => kb[67]; // c52 => kb[86]; // v53 => kb[66]; // b54 => kb[78]; // n55 => kb[77]; // m56 => kb[44]; // ,57 => kb[46]; // .58 => kb[47]; // /59 => kb[65]; // a60 => kb[83]; // s61 => kb[68]; // d62 => kb[70]; // f63 => kb[71]; // g64 => kb[72]; // h65 => kb[74]; // j66 => kb[75]; // k67 => kb[76]; // l68 => kb[59]; // ;69 => kb[81]; // q70 => kb[87]; // w71 => kb[69]; // e72 => kb[82]; // r73 => kb[84]; // t74 => kb[89]; // y75 => kb[85]; // u76 => kb[73]; // i77 => kb[79]; // o78 => kb[80]; // p79 => kb[49]; // 180 => kb[50]; // 281 => kb[51]; // 382 => kb[52]; // 483 => kb[53]; // 584 => kb[54]; // 685 => kb[55]; // 786 => kb[56]; // 887 => kb[57]; // 988 => kb[48]; // 0// initialize tuning function// for a 10-TET tuning scheme instead of 12-TETfun float midiTune( int x ){return cFrq * Math.pow( 2.0, ( x - 69 ) / nDiv );}//the keyboard detect functionfun void thePits(){Hid hi2;HidMsg msg2;0 => int device2;if( me.args() ) me.arg(0) => Std.atoi => device2;if( !hi2.openKeyboard( device2 ) ) me.exit();while( true ){hi2 => now;while( hi2.recv( msg2 ) ){if( msg2.isButtonDown() ){midiTune( kb[msg2.ascii] ) => a3;a3 * mRat => a2;set( base, a0, a1, a2, a3 );}}}}//sporking out the keyboard functionspork ~ thePits();// custom function controls parameters of noteset( base, a0, a1, a2, a3 );// infinite loopwhile( true ){// time advances when the mouse does somethinghi => now;// determines how to respond when mouse does somethingwhile( hi.recv( msg ) ){if( msg.isMouseMotion() ){// X-Axis controls how loud the note isif( msg.deltaX ){Std.fabs( msg.deltaX ) * .0083 - .0083 => a1; //sets gainset( base, a0, a1, a2, a3 );}// Y-Axis controls how bright the note isif( msg.deltaY ){Std.fabs( -msg.deltaY * .0083 + a0 ) => a0; //sets index(brightness)set( base, a0, a1, a2, a3 );}}else if( msg.isWheelMotion() ){// for now the mouse wheel controls pitchif( msg.deltaY ){msg.deltaY * .8333 + a2 => a2; //sets carrier freqset( base, a0, a1, a2, a3 );}}else if( msg.isButtonDown() ){// pressing button presses the "bow" into the "string"msg.which => base;count++;if( count == 1 ) e.keyOn();10::ms => now;set( base, a0, a1, a2, a3 );}else if( msg.isButtonUp() ){// lifting button also lifts "bow" from the "string"msg.which => base;count--;if( !count ){e.keyOff();0.0 => a1; // just making sure each note starts from 0dB}}}}fun void set( int base, float v0, float v1, float v2, float v3 ){//changes pitchesv3 => car.freq;//changes mod freqv2 => mod.freq;//gainv1 => e.gain;//mod index( 500 * ( v0 + 1 ) ) => mod.gain;}_______________________________________________chuck-users mailing list_______________________________________________chuck-users mailing list