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

[sc-dev] SF.net SVN: quarks:[2671] JITLibExtensions



Revision: 2671
          http://sourceforge.net/p/quarks/code/2671
Author:   decampo
Date:     2013-12-26 22:23:23 +0000 (Thu, 26 Dec 2013)
Log Message:
-----------
tests, fixes, and new help file for NPVoicer.

Modified Paths:
--------------
    JITLibExtensions/classes/NPVoicer.sc
    JITLibExtensions/classes/extNodeProxySetAt.sc

Added Paths:
-----------
    JITLibExtensions/HelpSource/
    JITLibExtensions/HelpSource/Classes/
    JITLibExtensions/HelpSource/Classes/NPVoicer.schelp
    JITLibExtensions/HelpSource/Classes/ProxyMeter.schelp

Added: JITLibExtensions/HelpSource/Classes/NPVoicer.schelp
===================================================================
--- JITLibExtensions/HelpSource/Classes/NPVoicer.schelp	                        (rev 0)
+++ JITLibExtensions/HelpSource/Classes/NPVoicer.schelp	2013-12-26 22:23:23 UTC (rev 2671)
@@ -0,0 +1,233 @@
+TITLE:: NPVoicer
+summary:: handle polyphony with nodeproxies
+categories:: Undocumented classes
+related:: JITLib, NodeProxy, Ndef
+
+DESCRIPTION::
+NPVoicer simplifies the use of polyphony in NodeProxies. One can flexibly play, access and release multiple voices of the same synth source with this wrapper around a nodeproxy.
+
+code::
+s.boot;
+s.latency = nil;			// for immediate response;
+
+g = NPVoicer(Ndef(\piano)); 	// make an NPVoicer with an Ndef in it
+g.prime(\default);			// prepare it with the default synthdef
+
+g.play;					// play it
+
+	// start a sound with key 48, with its won set of params
+g.put(48, [\freq, 48.midicps]);
+
+	// a second note at 51
+g.put(51, [\freq, 51.midicps]);
+
+	// release them
+g.release(48);
+g.release(51);
+
+// test with MIDI if you have a controller around:
+MIDIdef.noteOn(\pianOn, { |note, vel, chan|
+	g.put(note, [\freq, note.midicps, amp: (vel/127).squared * 0.25 ]);
+}, nil, 1);
+MIDIdef.noteOff(\pianOff, { |note, vel, chan| g.release(note); }, nil, 1);
+
+::
+
+
+CLASSMETHODS::
+
+METHOD:: new
+make a new NPVoicer
+
+ARGUMENT:: proxy
+required - a nodeproxy to play voices in.
+
+ARGUMENT:: indivParams
+which params will be set for each new voice individually.
+this protects these params from accidental global setting.
+
+INSTANCEMETHODS::
+
+METHOD:: prime
+prepare proxy for playing voices.
+
+ARGUMENT:: obj
+can be anything a nodeproxy accepts  as source :
+a SynthDef, a Symbol (synthdef name), a function, ...
+
+ARGUMENT:: useSpawn
+a flag whether to put obj into slot 0. As voicers usually have 
+individual voices and not a preferred front synth, default = false.
+
+METHOD:: synCtl
+internal - a SynthDefControl created when priming, and used for the voices.
+
+METHOD:: indivParams
+the list of param used individually and not globally.
+
+METHOD:: usesSpawn
+the flag whether a new nodeproxy object will play in slot 0 or not.
+
+
+METHOD:: put
+put a new voice into the objects list at 
+
+ARGUMENT:: key
+at this key, typically a note number. (replaces a playing object there)
+
+ARGUMENT:: args
+with these starting individual arguments.
+
+METHOD:: release
+release voice playing at key with given fadeTime.
+
+METHOD:: playingKeys
+return the keys of all currently playing voices.
+
+METHOD:: releaseAll
+return all currently playing voices withgiven fadetime.
+
+METHOD:: spawn
+if NPVoicer usesSpawn, spawn will create new voices that are only triggered and then take care of themselves, i.e. end automatically and do not allow control settings.
+see example.
+
+ARGUMENT:: args
+args for the spawned voice.
+
+ARGUMENT:: addAction
+addAction for the spawned voice.
+
+
+/* Interfacing to nodeproxy */
+
+METHOD:: proxy
+the nodeproxy used to play the voices
+
+METHOD:: play
+play the nodeproxy. see NodeProxy:play for full info
+
+METHOD:: playN
+playN the nodeproxy. see NodeProxy:playN for full info
+
+METHOD:: pause
+pause the nodeproxy
+
+METHOD:: resume
+resume the nodeproxy
+
+METHOD:: stop
+stop the nodeproxy with fadeTime and reset options.
+
+METHOD:: end
+end the nodeproxy with fadeTime.
+
+METHOD:: set, unset
+set and unset global params of the nodeproxy.
+
+METHOD:: map, unmap
+map and unmap global params of the nodeproxy.
+
+METHOD:: setAt, unsetAt
+set and unset params at individual playing voices.
+
+
+
+EXAMPLES::
+
+	// ToDo
+// An example with KeyPlayer
+// An example with MultiTouchPad
+// An example with NanoKey - MIDI, play and hold notes
+// An example with NanoPad - MIDI, trigger perc notes only
+// An example with Manta controller  any others?
+
+code::
+	// trigger percussion-style notes from computer keyboard while above window.
+	// could also be done without NPVoicer, but it is convenient with NPVoicer.
+(
+s.latency = nil;
+g = NPVoicer(Ndef(\x));
+g.prime({ |freq = 400| SinOsc.ar(freq) * EnvGen.ar(Env.perc(0.001, 0.03, 0.4), doneAction:2) }, true);
+g.play;
+
+w = Window("ascii player - clickies").front;
+w.view.keyDownAction = { |view, char|
+	g.spawn([\freq, char.ascii.midicps])
+};
+)
+
+	// play, hold, and release notes from computer keyboard
+    // see also the KeyPlayer quark
+(
+s.latency = nil;
+g = NPVoicer(Ndef(\x), [\freq, \amp, \pan]);
+g.prime(\default, false);
+g.play;
+
+w = Window("ascii player2 - it IS a keyboard after all...").front;
+w.view.keyDownAction = { |view, char|
+	var key = char.ascii;
+		// no retriggering
+	if (g.playingKeys.includes(key).not) {
+		g.put(key, [\freq, key.midicps])
+	};
+};
+w.view.keyUpAction = { |view, char|
+	var key = char.ascii;
+	if (g.playingKeys.includes(key)) { g.release(key) };
+};
+)
+
+
+// test setting and mapping global vs individual params:
+
+g.play;
+s.scope; // to see panning
+
+// play a note
+g.put(60, [\freq, 60.midicps]);
+
+// global set
+g.set(\amp, 0.5);
+g.set(\amp, 0.1);
+g.set(\pan, -1);
+g.set(\pan, 1);
+g.unset(\pan); // only works the second time?
+
+// add a second note
+g.put(79, [\freq, 79.midicps]);
+// set indiv notes 60 to pan left/right
+g.setAt(60, \pan, -1);
+g.setAt(79, \pan, 1);
+
+// autopan
+Ndef(\lfPan, { |lofreq = 0.3| SinOsc.kr(lofreq) * 2 });
+// and map to global
+g.map(\pan, Ndef(\lfPan));
+// set indiv. afterwards unmaps them
+g.setAt(60, \pan, -1);
+g.setAt(79, \pan, 1);
+
+// a new note still gets autopan
+g.put(87, [\freq, 87.midicps]);
+
+g.release(60);
+g.release(79);
+
+g.unmap(\pan); // autopan should stop ... not working yet! (why?)
+
+
+
+// for comparison, test with a plain Ndef:
+
+Ndef(\a, { |amp=0.1, pan| Pan2.ar(PinkNoise.ar(amp), pan) });
+Ndef(\a).play;
+
+Ndef(\a).set(\pan, 1);
+Ndef(\a).set(\pan, -1);
+Ndef(\a).map(\pan, Ndef(\lfPan));
+Ndef(\a).unmap(\pan); // stops wherever lfo ended
+Ndef(\a).unset(\pan); // unset to default
+
+Ndef(\a).set(\pan, 1); // this does unset properly
+::

Added: JITLibExtensions/HelpSource/Classes/ProxyMeter.schelp
===================================================================
--- JITLibExtensions/HelpSource/Classes/ProxyMeter.schelp	                        (rev 0)
+++ JITLibExtensions/HelpSource/Classes/ProxyMeter.schelp	2013-12-26 22:23:23 UTC (rev 2671)
@@ -0,0 +1,323 @@
+TITLE:: ProxyMeter
+summary:: easy metering of audio proxy levels
+categories:: Undocumented classes
+related:: Classes/SomeRelatedClass, Reference/SomeRelatedStuff, etc.
+
+DESCRIPTION::
+ProxyMeter measures the peak levels of proxies (e.g. those showing on a proxymixer),
+determines pre- and post-slider volume, and can displays these two levels on a mixer,
+or generally, on a MonitorGui.
+
+Written by adc, based on suggestions of / discussions with Ricardo Guerreiro.
+Reuses ideas and code from AudioMeter by A. Bartetzki.
+
+code::
+(
+Server.default = s = Server.local;
+s.makeWindow;
+s.boot;
+p = p ?? { ProxySpace.new }; p.push;
+
+m = ProxyMixer(p, 8);
+)
+	// make some proxies
+(
+~a = { Ringz.ar(Dust.ar([1, 1]), [600, 800], 0.05) };
+~b = { Dust.ar([20, 80, 320]) * 0.5 };
+~y = { SinOsc.ar(0.2).abs * PinkNoise.ar };
+~x = { SinOsc.ar(0.13).abs * BrownNoise.ar };
+
+~a.play(vol: 0.2);
+~b.play(vol: 0.1);
+~x.play(vol: 0.2);
+~y.play(vol: 0.1);
+)
+	// then meter the mixer
+/// - broken, the rangesliders cover the amp sliders!
+ProxyMeter.addMixer(m);
+::
+
+
+CLASSMETHODS::
+
+METHOD:: mixerOwnsMeter
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: cmdPeriod
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: checkGuiObjects
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: sourceFunc
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: checkAdd
+(describe method here)
+
+ARGUMENT:: proxy
+(describe argument here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: addNdefGui
+(describe method here)
+
+ARGUMENT:: gui
+(describe argument here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: mixer
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: removeMixer
+(describe method here)
+
+ARGUMENT:: mixer
+(describe argument here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: checkAll
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: initClass
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: addMonitorGui
+(describe method here)
+
+ARGUMENT:: gui
+(describe argument here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: clear
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: prefix
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: prePostViews
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: hideKrs
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: addMixer
+(describe method here)
+
+ARGUMENT:: mixer
+(describe argument here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: makeSkipJack
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: showKrs
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: removeNdefGui
+(describe method here)
+
+ARGUMENT:: gui
+(describe argument here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: proxyGuis
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: removeMonitorGui
+(describe method here)
+
+ARGUMENT:: gui
+(describe argument here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: showingKrs
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: new
+(describe method here)
+
+ARGUMENT:: proxy
+(describe argument here)
+
+ARGUMENT:: view
+(describe argument here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: all
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: checkSkip
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: checkAddPrePost
+(describe method here)
+
+ARGUMENT:: proxy
+(describe argument here)
+
+ARGUMENT:: ppv
+(describe argument here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: skipjack
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+
+INSTANCEMETHODS::
+
+METHOD:: space
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: remove
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: resp
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: ampName
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: sendPoll
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: addView
+(describe method here)
+
+ARGUMENT:: newview
+(describe argument here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: views
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: showKr
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: arProxy
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: hideKr
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: checkFunc
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: makeResp
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: init
+(describe method here)
+
+ARGUMENT:: proxy
+(describe argument here)
+
+ARGUMENT:: view
+(describe argument here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: ampVals
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: checkRemove
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: makeAmpProxy
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: updateFunc
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: stop
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+METHOD:: ampProxy
+(describe method here)
+
+returns:: (describe returnvalue here)
+
+
+EXAMPLES::
+
+code::
+(some example code)
+::
\ No newline at end of file

Modified: JITLibExtensions/classes/NPVoicer.sc
===================================================================
--- JITLibExtensions/classes/NPVoicer.sc	2013-12-26 11:52:50 UTC (rev 2670)
+++ JITLibExtensions/classes/NPVoicer.sc	2013-12-26 22:23:23 UTC (rev 2671)
@@ -1,53 +1,67 @@
 
-NPVoicer { 
-	
-	var <proxy, <setParams, <synCtl, <usesSpawn = false;
-	
-	*new { | proxy, setParams |
-		^super.newCopyArgs(proxy, setParams ? []);
+NPVoicer {
+
+	var <proxy, <indivParams, <synCtl, <usesSpawn = false;
+
+	*new { | proxy, indivParams |
+		^super.newCopyArgs(proxy, indivParams ? []);
 	}
-	
-	prime { |obj, useSpawn|
-		proxy.prime(obj); 
+
+	prime { |obj, useSpawn = false|
+		proxy.prime(obj);
 		synCtl = proxy.objects.first;
 		usesSpawn = useSpawn ? usesSpawn;
-		proxy.awake_(usesSpawn.not); 
+		proxy.awake_(usesSpawn.not);
 		if (usesSpawn.not) { proxy.put(0, nil) };
 	}
-	
-	put { | index, args | 
-		if (proxy.awake.not) { 
-			warn("NPVoicer: proxy not awake; should be awake for sustained voicing.") 
+
+	put { | key, args |
+		if (proxy.awake.not) {
+			warn("NPVoicer: proxy not awake; should be awake for sustained voicing.")
 		};
-		proxy.put(index, synCtl, extraArgs: args );
+		proxy.put(key, synCtl, extraArgs: args );
 	}
-	
+
 	release { |key, fadeTime| proxy.removeAt(key, fadeTime) }
 
 	releaseAll { | fadeTime | proxy.release(fadeTime) }
-	
-	spawn { |args| 
-		if (proxy.awake) { warn("NPVoicer: proxy is awake; should not be awake for spawning.") };
-		proxy.spawn(args); 
+
+	spawn { |args|
+		if (proxy.awake) {
+			warn("NPVoicer: proxy is awake; should not be awake for spawning.") };
+		proxy.spawn(args);
 	}
-	
+
 	playingKeys { ^proxy.objects.indices }
-	
+
 		// the most basic messages for the proxy
+	// don't play the source, just the monitor
 	play { | out, numChannels, group, multi=false, vol, fadeTime, addAction |
-		proxy.play(out, numChannels, group, multi=false, vol, fadeTime, addAction)
+		proxy.play(out, numChannels, group, multi, vol, fadeTime, addAction)
 	}
-	
+
 	playN { | outs, amps, ins, vol, fadeTime, group, addAction |
 		proxy.playN(outs, amps, ins, vol, fadeTime, group, addAction);
 	}
-	
+
 	stop { | fadeTime = 0.1, reset = false | proxy.stop (fadeTime, reset) }
-	
+
 	end { | fadeTime = 0.1, reset = false | proxy.end(fadeTime, reset) }
-	
+
 	pause { proxy.pause }
-	
+
 	resume { proxy.resume }
+
+	// set global params: key, val, key, val, ...
+	set { |...args| proxy.set(*args); }
+	unset { |...keys| proxy.unset(*keys); }
+
+	map { |...args| proxy.map(*args); }
+	unmap { |...keys| proxy.map(*keys); }
+
+	// set params individually per node
+	setAt { |key ... args| proxy.setAt(key, *args); }
+	unsetAt { |key ... keys| proxy.setAt(key, *keys); }
+
 }
 

Modified: JITLibExtensions/classes/extNodeProxySetAt.sc
===================================================================
--- JITLibExtensions/classes/extNodeProxySetAt.sc	2013-12-26 11:52:50 UTC (rev 2670)
+++ JITLibExtensions/classes/extNodeProxySetAt.sc	2013-12-26 22:23:23 UTC (rev 2671)
@@ -1,20 +1,24 @@
-	// move to regular JITLib when fully tested. 
-	
-+ NodeProxy { 
-	setAt { |nodeKey, args|
+	// move to regular JITLib when fully tested.
+
++ NodeProxy {
+	setAt { |nodeKey ... args|
 		var node = this.objects[nodeKey];
 		if (node.notNil) { node.set(*args) }
 	}
+	unsetAt { |nodeKey ... keys|
+		var node = this.objects[nodeKey];
+		if (node.notNil) { node.unset(*keys) }
+	}
 }
 
 	// error suppression not working yet, fixme.
-+ SynthControl { 
-//	set { | ... args | 
++ SynthControl {
+//	set { | ... args |
 //		// as fast as possible, no errors please
-//		server.sendBundle(nil, [ 
-//			['/error', -1], 
+//		server.sendBundle(nil, [
+//			['/error', -1],
 //			["/n_set", nodeID] ++ args,
-//			['/error', -2] 
+//			['/error', -2]
 //		]);
 //	}
 }

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/