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

[sc-dev] Using SCFreqScope to automatically display frequency response curves



Hi -

With a small tweak to SCFreqScope, it's possible to do other cool
things with it, like interactively plot the frequency response of a
filter. Check out the attached patch and the example file - I think
this is really nice, to visualise the response of a filter like
this...

Dan

-- 
http://www.mcld.co.uk
Index: build/SCClassLibrary/Common/GUI/osx/SCFreqScope.sc
===================================================================
--- build/SCClassLibrary/Common/GUI/osx/SCFreqScope.sc	(revision 8097)
+++ build/SCClassLibrary/Common/GUI/osx/SCFreqScope.sc	(working copy)
@@ -7,6 +7,7 @@
 	var <scopebuf, <fftbuf;
 	var <active, <node, <inBus, <dbRange, dbFactor, rate, <freqMode;
 	var <bufSize;	// size of FFT
+	var <>specialSynthDef, <specialSynthArgs; // Allows to override the analysis synth
 	
 	*viewClass { ^SCScope }
 	
@@ -116,9 +117,9 @@
 //				\fftbufnum, fftbuf.bufnum, \scopebufnum, scopebuf.bufnum]);
 
 		node = server.nextNodeID; // get new node just to be safe
-		server.sendMsg("/s_new", "freqScope" ++ freqMode.asString, node, 1, 0, 
+		server.sendMsg("/s_new", specialSynthDef ?? {"freqScope" ++ freqMode.asString}, node, 1, 0, 
 				\in, inBus, \dbFactor, dbFactor, \rate, 4,
-				\fftbufnum, fftbuf.bufnum, \scopebufnum, scopebuf.bufnum);
+				\fftbufnum, fftbuf.bufnum, \scopebufnum, scopebuf.bufnum, *specialSynthArgs);
 	}
 	
 	kill {
@@ -197,6 +198,22 @@
 		});
 	}
 	
+	specialSynthArgs_ {|args|
+		specialSynthArgs = args;
+		if(args.notNil and:{active}){
+			server.sendMsg("/n_set", node, *specialSynthArgs);
+		}
+	}
+	
+	special { |defname, extraargs|
+		this.specialSynthDef_(defname);
+		this.specialSynthArgs_(extraargs);
+		if(active, {
+			server.sendMsg("/n_free", node);
+			node = server.nextNodeID;
+			this.start;
+		});		
+	}
 }
 
 FreqScope {

Attachment: SCFreqScope_special.scd
Description: Binary data