[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-dev] SF.net SVN: quarks:[2674] KeyPlayer/HelpSource



Revision: 2674
          http://sourceforge.net/p/quarks/code/2674
Author:   decampo
Date:     2013-12-28 02:14:06 +0000 (Sat, 28 Dec 2013)
Log Message:
-----------
new style help files.

Added Paths:
-----------
    KeyPlayer/HelpSource/KeyPlayer.schelp
    KeyPlayer/HelpSource/KeyPlayerGui.schelp
    KeyPlayer/HelpSource/KeyPlayerRec.schelp

Added: KeyPlayer/HelpSource/KeyPlayer.schelp
===================================================================
--- KeyPlayer/HelpSource/KeyPlayer.schelp	                        (rev 0)
+++ KeyPlayer/HelpSource/KeyPlayer.schelp	2013-12-28 02:14:06 UTC (rev 2674)
@@ -0,0 +1,207 @@
+TITLE:: KeyPlayer
+summary:: a simple keyboard playing interface
+categories:: Undocumented classes
+related:: Classes/KeyPlayerGui, Classes/KeyPlayerRec, Classes/KeyChain
+
+
+
+DESCRIPTION::
+KeyPlayer allows using the computer keyboard keys for
+executing functions when given keys are pressed or released
+(keyDown and keyUp).
+
+How to link to this file, in quarks/KeyPlayer? link::../KeyPlayerExample.scd::
+
+CLASSMETHODS::
+
+METHOD:: all
+Global dict for all KeyPlayers
+
+METHOD:: at
+Look up KeyPlayers by name in KeyPlayer.all
+
+METHOD:: verbose
+get or set verbose flag to posts debug messages. default = false.
+code::
+KeyPlayer.verbose_(true);
+	// debugging, posts:
+	// [KeyPlayer, char, modifiers, unicode, keycode]
+KeyPlayer.verbose_(false);
+::
+
+METHOD:: new
+create a new KeyPlayer
+code::
+k = KeyPlayer(\k);		// create an instance
+KeyPlayer(\k) == k;		// same name accesses same instance
+KeyPlayer.at(\k) == k;  // just access to an existing instance
+::
+ARGUMENT:: key
+key under wich to store it
+ARGUMENT:: inDict
+an optional dict of keyDown and keyUp functions - not well tested yet.
+ARGUMENT:: ignoreCase
+a flag whether to ignore upper/lowercase letter distinction.
+
+METHOD:: gui
+make a global gui for up to ten KeyPlayers.
+
+METHOD:: initClass
+
+
+INSTANCEMETHODS::
+
+subsection::Instance Variables
+
+METHOD:: key
+The KeyPlayer's name/key
+
+METHOD:: actions, upActions, bothActions
+dicts where the down and up actions kept.
+
+METHOD:: pressed
+a dict with the currently pressed keys
+
+METHOD:: put, putDown, putUp, putBoth, putAll
+set actions for keyDown and keyUp on given characters
+code::
+	// put in some functions
+k.put($a, { "A down!".postln });		// or equivalent:
+k.putDown($a, { "A down!".postln });
+k.actions;	// they are stored here by unicode numbers
+
+	// upActions are separate
+k.putUp($a, { "A up!".postln });
+k.upActions;
+
+	// both dictionaries are kept here:
+k.bothActions.postcs; "";
+
+	// you can put things in both:
+k.putBoth($a, { "A upOrDown!".postln });
+
+	// put in a dict at once
+k.putAll(($x: { "x!".postln }, $y: { "y not?".postln }), true, \down);
+
+	// avoid retriggering keyDowns: try holding the s-key down
+k.putDown($s, { "yo again".postln }, noRep: true);
+k.putUp($s, { "yo again".reverse.postln });
+	// retriggers by default
+k.putDown($s, { "yo again".postln });
+::
+
+ARGUMENT:: char
+the char for which to put the action
+
+ARGUMENT:: func
+the action
+
+ARGUMENT:: both
+flag whether to distinguish upper/lower or to respond to both.
+
+ARGUMENT:: noRep
+on keyDown, flag whether to swallow auto-repeated keystrokes.
+
+METHOD:: gui
+make its own gui for KeyPlayer
+code::
+g = k.gui;
+// now try typing the colored keys
+::
+
+
+METHOD:: keyDown, keyUp
+evaluate keyActions by hand
+code::
+k.keyDown($a);
+k.keyUp($a);
+k.keyDown($a.asUnicode);
+k.keyUp($a.asUnicode);
+::
+
+METHOD:: removeAt
+remove actions from down or up dicts.
+code::
+k.removeAt($a);
+k.removeAt($a, \up);
+k.upActions;
+k.removeAt($a, \down);
+k.actions;
+::
+
+METHOD:: isUp, isDown
+check wether a char is currently down (pressed) or not.
+
+METHOD:: makeRec
+make an instance of KeyPlayerRec for the KeyPlayer
+
+METHOD:: rec
+get and set the KeyPlayerRec for the KeyPlayer
+
+METHOD:: saveDoc
+post current actions as code into a Document.
+Works if all functions are closed.
+
+subsection:: Private methods
+
+METHOD:: keyAction, makeKeyAction, makeKeyUpAction
+
+EXAMPLES::
+
+code::
+	// the random keyboard:
+(
+s.latency = nil;	// make sure we respond quickly
+thisThread.randSeed = 2008;
+"qwertzuiopasdfghjklyxcvbnm".do { |char|
+	var note = (midinote: rrand(36, 96), dur: rrand(0.1, 1.0));
+	KeyPlayer(\rand).put(char, { |char| char.postln; note.postln.play });
+};
+KeyPlayer.gui.front;
+)
+
+KeyPlayer(\rand).bothActions
+
+	// random keyboard, no retrig, hold until release with keyUp
+(
+q = q ? ();	// create a dict to keep things:
+q.notes = ();
+q.synths = ();
+thisThread.randSeed = 2008; // it is not that new
+
+"qwertzuiopasdfghjklyxcvbnm".do { |char|
+	q.notes.put(char, rrand(36, 96));
+
+	KeyPlayer(\hold).putDown(char, { |char|
+		char.post;
+		q.synths[char].release;
+		q.synths.put(char, Synth(\default, [\freq, q.notes[char].postln.midicps]));
+	}, noRep: true);
+
+	KeyPlayer(\hold).putUp(char.postln, { |char| q.synths.removeAt(char).release });
+};
+KeyPlayer.gui.front;
+)
+
+KeyPlayer(\px);
+// stop and resume a proxyspace:
+p = ProxySpace.push;
+KeyPlayer(\px).put($p, { p.do(_.pause) });
+KeyPlayer(\px).put($r, { p.do(_.resume) });
+
+	// David Cottle example IIRC
+~test = { SinOsc.ar(LFNoise0.kr([10, 15], 200, [300, 500])) * 0.2 };
+~test.play;
+
+	// re-send or rebuild the sound
+(
+~test = {
+	SinOsc.ar(
+		LFNoise0.kr([10, 15] * exprand(0.5, 4.0), 200, [300, 500])
+		* exprand(1.0, 4.0)
+	) * XLine.kr(0.5, 0.005, exprand(0.1, 10), doneAction: 2);
+};
+KeyPlayer(\px).put($t, { ~test.send });
+KeyPlayer(\px).put($u, { ~test.rebuild });
+)
+::
\ No newline at end of file

Added: KeyPlayer/HelpSource/KeyPlayerGui.schelp
===================================================================
--- KeyPlayer/HelpSource/KeyPlayerGui.schelp	                        (rev 0)
+++ KeyPlayer/HelpSource/KeyPlayerGui.schelp	2013-12-28 02:14:06 UTC (rev 2674)
@@ -0,0 +1,81 @@
+TITLE:: KeyPlayerGui
+summary:: a simple gui for KeyPlayer
+categories:: Undocumented classes
+related:: Classes/SomeRelatedClass, Reference/SomeRelatedStuff, etc.
+
+DESCRIPTION::
+
+strong::To understand KeyPlayerGui, see KeyPlayer.help for examples!::
+
+Notes:
+
+Several aspects of this class could be made more flexible:
+supporting different display sizes, keyboard layouts,
+and ways of switching between several KeyPlayers may be useful.
+
+Dragging and dropping actions could also be supported;
+not sure how to do that consistently with keyUp actions,
+retriggering, putting things on shifted keys, etc.
+
+Also, KeyPlayerGui should be a JITGui.
+
+
+(Method doc will be completed when reworking KeyPlayerGui.)
+
+CLASSMETHODS::
+
+subsection:: Class Variables
+
+METHOD:: colors
+a list of colors used for the keys.
+
+METHOD:: keyboard
+the list of characters the physical keyboard shows.
+Default is a Macbook Pro with US Extended key caps.
+
+METHOD:: initClass
+
+METHOD:: keyboardNoShift
+the list of characters that will be printed when typed.
+
+METHOD:: keyboardShift
+the list of characters that will be printed when typed while the keyboard shift key is pressed.
+
+METHOD:: lineOffsets
+a list of offsets used for keyboard line layout/geometry.
+
+
+subsection:: Class Methods
+
+METHOD:: gui
+Make a KeyPlayerGui for up to 10 KeyPlayers.
+
+METHOD:: new
+make a new KeyPlayerGui for a keyplayer.
+
+METHOD:: initClass
+...
+
+
+INSTANCEMETHODS::
+
+subsection:: Instance Variables
+
+METHOD:: player
+the KeyPlayer displayed.
+
+strong::GUI elements, visual aspects: ::
+METHOD:: w, zone, buttons, drags, listview
+METHOD:: font, activeColor
+
+METHOD:: skipjack
+
+subsection:: Instance Methods
+METHOD:: front
+
+strong::GUI creation: ::
+METHOD:: makeWindow, makeButtons, makeDrags, makeListView, makeKey
+
+strong::GUI updating: ::
+
+METHOD:: updateAll, updateDrags, updateButtons, runUpdate, stopUpdate

Added: KeyPlayer/HelpSource/KeyPlayerRec.schelp
===================================================================
--- KeyPlayer/HelpSource/KeyPlayerRec.schelp	                        (rev 0)
+++ KeyPlayer/HelpSource/KeyPlayerRec.schelp	2013-12-28 02:14:06 UTC (rev 2674)
@@ -0,0 +1,124 @@
+TITLE:: KeyPlayerRec
+summary:: a simple recorder for KeyPlayer
+categories:: Undocumented classes
+related:: Classes/KeyPlayer, Reference/KeyPlayerGui
+
+DESCRIPTION::
+KeyPlayerRec can record a series of key presses made with KeyPlayer,
+and play it back with some flexibility, e.g. with variable speed.
+
+
+
+CLASSMETHODS::
+
+METHOD:: new
+create a KeyPlayerRec for an existing KeyPlayer
+
+code::
+	// make a KeyPlayerRec explicitly:
+r = KeyPlayerRec.new();
+k = KeyPlayer(\help);
+k.rec = r;
+
+KeyPlayer.gui;
+
+	// or simpler, make it implicitly from KeyPlayer:
+k.makeRec;
+::
+
+ARGUMENT:: player
+the player KeyPlayerRec will record.
+
+METHOD:: verbose
+get and set flag whether to post debug messages.
+
+
+
+INSTANCEMETHODS::
+
+subsection:: Instance Variables
+
+METHOD:: player
+the player KeyPlayerRec records
+
+METHOD:: list
+current list of/for recorded/recording events
+
+METHOD:: lists
+all recorded lists of events since creation
+
+METHOD:: isOn
+flag whether recording isOn.
+
+METHOD:: loop
+get and set flag whether playback will loop isOn.
+
+METHOD:: speed
+get and set relative playback speed. default = 1 = orig. speed.
+
+
+subsection:: Instance Methods
+
+METHOD:: startRec, stopRec, toggleRec
+start, stop and toggle recording keystroke events
+
+METHOD:: recordEvent
+record a keystroke event
+
+METHOD:: play
+start playback of current event list. will stop recording.
+
+METHOD:: togglePlay
+toggle playback on/off
+
+METHOD:: playOnce
+play once through list. this is polyphonic, like Tdef.fork.
+
+METHOD:: changeSpeed
+change speed by a factor
+
+EXAMPLES::
+
+code::
+k = KeyPlayer(\kRec);
+k.makeRec;
+k.gui;
+
+// prepare some random notes to play
+(
+var notes = ();
+thisThread.randSeed = Date.getDate.year;
+"qwertzuiopasdfghjklyxcvbnm".do { |char|
+    notes.put(char, rrand(36, 96));
+
+    KeyPlayer(\kRec).put(char, { |char|
+        char.postln;
+        (midinote: notes[char], dur: 0.1).play
+    });
+};
+)
+
+// now play and record something ...
+
+k.rec.startRec; KeyPlayerRec.verbose = true;
+
+// then stop
+k.rec.stopRec;
+
+k.rec.play;
+k.rec.loop = true;
+
+k.rec.playOnce; // polyphonic, like fork
+
+k.rec.list.printcsAll;
+k.rec.lists;
+
+
+    // try using extra keys for record and play on/off
+    // this is not ideal, as these keys get recorded as well...
+    // would be better if rec params were shown on gui.
+k.putDown($,, { k.rec.toggleRec }, noRep: true);
+k.putDown($., { k.rec.togglePlay }, noRep: true);
+
+
+::
\ No newline at end of file

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


_______________________________________________
sc-dev mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-dev/
search: https://listarc.bham.ac.uk/lists/sc-dev/search/