From: owner-sc-users-digest@lists.io.com (sc-users-digest) To: sc-users-digest@lists.io.com Subject: sc-users-digest V1 #209 Reply-To: sc-users Sender: owner-sc-users-digest@lists.io.com Errors-To: owner-sc-users-digest@lists.io.com Precedence: bulk sc-users-digest Thursday, December 7 2000 Volume 01 : Number 209 ---------------------------------------------------------------------- Date: 5 Dec 2000 04:11:52 -0800 From: kevin parks <---@---.---> Subject: key bindings possible in SC? Are key bindings possible in SC? What I would like to do is make a MIDI-free patch that used the keys of the keyboard to play sounds, not for any musical performance, but so that i can use SC as a tuning tool/demo, like i used to use Just.app on the NeXT. For example, it would be cool to have a synthesis engine with a harmonically rich source, specify a fundamental in Hz and the ratios for a 12-note scale and have those notes mapped as: 1/1--16/15--9/8--6/5--5/4--4/3--45/32--3/2--8/5--5/3--16/9--15/8--2/1 - --Q-----W-------E-----R-----T-----Y------U-------I------O------P----[---------]------| with perhaps the arrow keys functioning as an up/down octave keys. This way one could explore different turnings and also it would be cool to uses as a tuner. Would this kind of asci keyboard mapping be possible in SC? I've never seen this, only MouseX, MouseY, Tablet, & MIDI. I suppose that if this was not possible then just a button GUI, or somehow breaking the screen into zones and using MouseX, MouseY would be the alternative way to go. Possible? Anyone have a patch that does this or something similar that i could look at? Cheers, - -kevin kevin@raven.dartmouth.edu _______________________________________________________________________ Free Unlimited Internet Access! Try it now! http://www.zdnet.com/downloads/altavista/index.html _______________________________________________________________________ ------------------------------ Date: Tue, 5 Dec 2000 09:32:12 -0500 From: rkuivila@mail.wesleyan.edu (Ron Kuivila) Subject: Re: key bindings possible in SC? - --============_-1236095764==_============ Content-Type: text/plain; charset="us-ascii" Hi Kevin, Attached are some classes I use to do this sort of thing. The basic idea is to poll the keyboard in a Task using getKeys (a method of Integer that provides access to the MacOS GetKeys routine). However, these classes use my SC and Control classes (Control is a container class that hides Plugs and GUI details from the user, SC sets up a TSpawn to allow multiple sound tasks to be started from independent blocks of code). Since a lot of that functionality will be built into SC3, it may be easier to just take the polling code and bitmasks and make a more standard SuperCollider realization. However, if you want it, I can send you my whole library. RJK - --============_-1236095764==_============ Content-Type: text/plain; name="NewKeyedControls.sc"; charset="us-ascii" Content-Disposition: attachment; filename="NewKeyedControls.sc" KeyedControlSet { var <>keySelector; // which of the words of key flags to use var <>keyMasks; // array of mask bits for identifying specific keys var <>keyStates; // the current state of those keys var <>externalControlSources; // the control sources to use as inputs var <>momentaryControls; // list of Controls to be turned on/off by key closures var <>connectedControls; // list of Controls to be scaled by external control sources // with key closures var <>keyState; var <>keyDelta; *new { arg argKeyMasks, argExternalControls; ^super.new.init(argKeyMasks, argExternalControls) } init { arg argKeyStateOffset, argKeyMasks, argExternalControls; keyState = 0; keyDelta = 0; keySelector = argKeyStateOffset ? 3; keyMasks = argKeyMasks ? [4,1,134217728,16384,16777216,33554432,67108864,268435456,536870912, 2097152, -2147483647-1, 8388608]; externalControlSources = argExternalControls ? [MouseX(0,1), MouseY(0,1)]; keyStates = keyMasks.collect({ 0 }); this.clearConnections; } clearConnections { connectedControls = externalControlSources.collect({ keyMasks.collect({Control})}); momentaryControls = keyMasks.collect({Control}); } connect{ arg items, keyIndex = 0, controlIndex = 0; // default: controlIndex = 0 -> MouseX, 1 -> MouseY if ((keyMasks.size >= (items.size + keyIndex)) && (externalControlSources.size > controlIndex) , { items.do({ arg it, i; if (it.notNil, { connectedControls.at(controlIndex).put(i + keyIndex,it); }); }); }); } momentary{ arg items, keyIndex = 0; if (keyMasks.size >= (keyIndex + items.size) , { items.do({ arg it, i; if (it.notNil, { momentaryControls.put(i + keyIndex, it); }); }); }); } poll { var activeKeys, deltaKeys, newControlValues; keyDelta = keyState bitXor: (keyState = keySelector.getKeys); newControlValues = externalControlSources.collect({arg control; control.value }); keyStates = keyState & keyMasks; if(keyState != 0, { keyStates.do({ arg keyState, i; var val; if (keyState != 0, { newControlValues.do({ arg val, j; connectedControls.at(j).at(i).input_(val); }); }); }); }); if (keyDelta != 0, { deltaKeys = keyDelta & keyMasks; deltaKeys.do({arg deltaKey, i; var val; if (( deltaKey != 0), { if ( keyStates.at(i) == 0, { val = 0 }, {val = 1}); momentaryControls.at(i).value_(val); if (val == 1, { momentaryControls.at(i).action.value(momentaryControls.at(i)); }); }); }); }); } } NewKeyedControls { var <>pollrate; var <>fkControlSet; var <>digitControlSet; *new { ^super.new.init } init { pollrate = 0.01; fkControlSet = KeyedControlSet(3, [4,1,134217728,16384,16777216,33554432,67108864,268435456,536870912, 2097152, -2147483647-1, 8388608, 131072, 524288, 512]); digitControlSet = KeyedControlSet(0, [1024,2048,4096,8192,32768,16384,4,16,2,32]); } connectToFKeys{ arg items, keyIndex = 0, controlIndex = 0; fkControlSet.connect(items,keyIndex, controlIndex); } momentaryToFKeys{ arg items, keyIndex = 0; fkControlSet.momentary(items,keyIndex); } connectToDigits{ arg items, keyIndex = 0, controlIndex = 0; digitControlSet.connect(items,keyIndex, controlIndex); } momentaryToDigits{ arg items, keyIndex = 0; digitControlSet.momentary(items,keyIndex); } poll { fkControlSet.poll; digitControlSet.poll; } run { SC.task( { loop({ this.poll; SC.wait(pollrate); }) }); } } - --============_-1236095764==_============ Content-Type: text/plain; name="NewKeyedControls.help"; charset="us-ascii" Content-Disposition: attachment; filename="NewKeyedControls.help" NewKeyedControls superclass: Object This class allows the computer keyboard and mouse to be used together as a performance control device. Keys on the keyboard serve to map the current Mouse x and y position to different Control's. Alternatively, the state of the keys themselves (pressed or not) may be mapped to Control's, simulating a MIDI keyboard Creation *new Accessing connectToFKeys (arrayOfControls, keyIndex = 0, controlIndex = 0) connect a set of Control's to MouseX or MouseY whenever a corresponding Function Key is pressed. arrayOfControls the Control's to be mapped keyIndex lowest Function key to use (it is mapped to the 1st entry in arrayOfControls) controlIndex ControlIndex = 0 --> MouseX is the control source ControlIndex = 1 --> MouseY is the control source connectToDigits (arrayOfControls, keyIndex = 0, controlIndex = 0) connect a set of Control's to MouseX or MouseY whenever a corresponding number is pressed. arrayOfControls the Control's to be mapped keyIndex lowest number key to use (it is mapped to the 1st entry in arrayOfControls) controlIndex ControlIndex = 0 --> MouseX is the control source ControlIndex = 1 --> MouseY is the control source momentaryToFKeys (arrayOfControls, keyIndex = 0) gate a set of Control's to 0 or 1 depending on whether a corresponding Function Key is pressed. arrayOfControls the Control's to be mapped keyIndex lowest Function key to use (it is mapped to the 1st entry in arrayOfControls) momentaryToDigits (arrayOfControls, keyIndex = 0) gate a set of Control's to 0 or 1 depending on whether a corresponding number key is pressed. arrayOfControls the Control's to be mapped keyIndex lowest number key to use (it is mapped to the 1st entry in arrayOfControls) ( Preset.funcInit({arg items, controls = 9; var keys; items.sound_({}); controls.numerical; keys = NewKeyedControls.new.pollrate_(0.02); // keys.performList('connectKeys', controls); keys.connectToFKeys( controls); controls.at(0).action_({ arg ctl; "hi".postln; if (ctl.value != 0, { items.prevGoal});}); keys.momentaryToDigits( controls); SC.initRoutine_({keys.run}); }).show; ) ( Preset.funcInit({arg items, controls = 9; var keys; items.sound_({}); controls.numerical; keys = NewKeyedControls.new.pollrate_(0.02); keys.connectToFKeys( controls); controls.at(0).action_({ arg ctl; if (ctl.value != 0, { items.prevGoal});}); keys.momentaryToDigits( controls); SC.initRoutine_({keys.run}); }).show; ) - --============_-1236095764==_============-- ------------------------------ Date: Tue, 5 Dec 2000 10:23:56 -0600 (CST) From: "AUDIOSYNTH.COM" <---@---.---> Subject: Re: key bindings possible in SC? See "key down actions" in the "gui examples" file. ------------------------------ Date: Tue, 05 Dec 2000 08:51:44 -0800 From: cramakrishnan@acm.org Subject: Keyword method arguments Hey James (and everyone else). I recently noticed that code using the keyword style for method arguments is not as fast as using the positional style. I'm just wondering why the compiler can't resolve the positions for the keyword arg and generate the same bytecode as the positional style at compile time? - - sekhar - -- C. Ramakrishnan cramakrishnan@acm.org ------------------------------ Date: Tue, 05 Dec 2000 19:39:52 -0600 From: James McCartney <---@---.---> Subject: Re: Keyword method arguments on 12/5/00 10:51 AM, cramakrishnan@acm.org at cramakrishnan@acm.org wrote: > > Hey James (and everyone else). > > I recently noticed that code using the keyword style for method > arguments is not as fast as using the positional style. > > I'm just wondering why the compiler can't resolve the positions for > the keyword arg and generate the same bytecode as the positional style > at compile time? Because at compile time the class of the receiver is not known, thus which method will be called is not known, thus what the argument names or their order is not known. - --- james mccartney james@audiosynth.com SuperCollider - a real time synthesis programming language for the PowerMac. ------------------------------ Date: Wed, 06 Dec 2000 00:32:07 -0700 From: James Coker <---@---.---> Subject: Re: architecture christian adam hresko wrote: > > since there's a number of programmers on this list, i was wondering if > anyone had any recommendations regarding books discussing computer > architecture. > > the book i'm planning on buying is Computer Organization and Design by > Hennessy and Patterson. That would probably be a very good choice. Their book on microprocessor design is the standard (now in it's 2nd edition, I think). Jim ------------------------------ Date: Thu, 07 Dec 2000 15:34:25 +0100 From: Wouter Snoei <---@---.---> Subject: multichannel startup bug Hi James, I have been working on a way to let SC play something at startup by inserting my function in the Main.sc file. This does work, but it doesn't play multichannel functions properly: I tested this by adding this function myPatch {Synth.scope({[GrayNoise.ar(0.15), SinOsc.ar(300, 0, 0.15)]});} in the "Main.sc" file within the "Main : Process" brackets and calling it with: this.myPatch; The scope gives me two channels looking the way they should, but I only hear the same Graynoise on all of my MOTU 324PCI outputs at the same time. This problem only occurs when I starup the program. When I run it by recompiling the library or by calling "this.myPatch;" via the "Run Main" function, it plays the right way! I don't see how this could be my mistake, so I guess I have discovered a bug...anyway, I'd very much like a solution for this problem cheers, Wouter - -- -- -- -- Wouter Snoei J.H. v. Heekpad 3 1024 BD Amsterdam tel: 020 4922366 fax: 020 6343068 woutersnoei@zonnet.nl ------------------------------ End of sc-users-digest V1 #209 ******************************