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

Re: [sc-dev] SF.net SVN: supercollider:[8152] trunk/build



great, I'll add it

Dan Stowell wrote:
Hi jost -

How about the code I just posted to sc-users? Here it is again,
tweaked for SwingOSC compat:

Server.default = s = GUI.stethoscope.defaultServer.boot;

{|in| MoogFF.ar(in, freq: MouseX.kr(10, 10000, 1),
gain:MouseY.kr(4,0))}.scopeResponse

LPF.scopeResponse
HPF.scopeResponse
MoogFF.scopeResponse
BBandPass.scopeResponse
BLowShelf.scopeResponse // by default BLowShelf doesn't mangle much
Resonz.scopeResponse
BRF.scopeResponse
Integrator.scopeResponse
Median.scopeResponse // nonlinear, and therefore interesting


Dan

2008/12/15 jostM <sc3@xxxxxxxx>:
  
This is extremely cool. You wouldn't have a code example, which you used
while testing scopeResponse, that we could add to the help file, would you ?

jostM

danstowell@xxxxxxxxxxxxxxxxxxxxx wrote:
    
Revision: 8152
          http://supercollider.svn.sourceforge.net/supercollider/?rev=8152&view=rev
Author:   danstowell
Date:     2008-12-15 20:00:39 +0000 (Mon, 15 Dec 2008)

Log Message:
-----------
Added SCFreqScope:special and SCFreqScope.response, plus convenience "scopeResponse" methods for Function and Filter

Modified Paths:
--------------
    trunk/build/ChangeLog
    trunk/build/Help/GUI/SCFreqScope.html
    trunk/build/SCClassLibrary/Common/GUI/osx/SCFreqScope.sc

Added Paths:
-----------
    trunk/build/SCClassLibrary/Common/GUI/PlusGUI/Control/scopeResponse.sc

Modified: trunk/build/ChangeLog
===================================================================
--- trunk/build/ChangeLog     2008-12-15 19:26:13 UTC (rev 8151)
+++ trunk/build/ChangeLog     2008-12-15 20:00:39 UTC (rev 8152)
@@ -24,11 +24,11 @@
 * 2008-11-29 Pitch ugen can now also track the pitch of control-rate signals - mb
 * 2008-12-03 added PV_Div ugen for complex division - ds
 * 2008-12-07 added PV_Conj ugen for complex conjugate - ds
-* 2008-12-15 new ViewRedirect for easier cross-platform gui syntax. e.g. Window now redirects to SCWindow or JWindow. ds & jostM
-* 2008-12-15 revised and updated all SC Gui documentation. New gui introduction. New SCUserView subclassing tutorial. - jostM
+* 2008-12-15 new ViewRedirect for easier cross-platform gui syntax. e.g. Window now redirects to SCWindow or JWindow. ds & jm
+* 2008-12-15 revised and updated all SC Gui documentation. New gui introduction. New SCUserView subclassing tutorial. - jm
+* 2008-12-15 added methods to SCFreqScope for "special" SynthDef, and for visualising frequency responses - ds


-
 Bugfixes:
 ---------
 * 2008-05-20 fix for the special case when 0.2.asFraction beachballs the lang (bug id 1856972) - jr

Modified: trunk/build/Help/GUI/SCFreqScope.html
===================================================================
--- trunk/build/Help/GUI/SCFreqScope.html     2008-12-15 19:26:13 UTC (rev 8151)
+++ trunk/build/Help/GUI/SCFreqScope.html     2008-12-15 20:00:39 UTC (rev 8152)
@@ -5,37 +5,37 @@
 <meta http-equiv="Content-Style-Type" content="text/css">
 <title></title>
 <meta name="Generator" content="Cocoa HTML Writer">
-<meta name="CocoaVersion" content="949.35">
+<meta name="CocoaVersion" content="824.48">
 <style type="text/css">
 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
 p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
 p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
-p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #001ee6}
+p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #0021e7}
 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica}
 p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
-p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000}
-p.p8 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco; min-height: 12.0px}
-p.p9 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica}
-p.p10 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica; min-height: 14.0px}
-p.p11 {margin: 0.0px 0.0px 0.0px 85.0px; text-indent: -85.0px; font: 12.0px Helvetica}
-p.p12 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica}
-p.p13 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica; min-height: 17.0px}
-p.p14 {margin: 0.0px 0.0px 0.0px 85.0px; text-indent: -85.0px; font: 12.0px Helvetica; min-height: 14.0px}
-p.p15 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #000000; min-height: 14.0px}
-p.p16 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #bf0000}
-p.p17 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000; min-height: 12.0px}
-p.p18 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #bf0000; min-height: 12.0px}
-p.p19 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #000000; min-height: 16.0px}
+p.p7 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco; min-height: 12.0px}
+p.p8 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica}
+p.p9 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica; min-height: 14.0px}
+p.p10 {margin: 0.0px 0.0px 0.0px 85.0px; text-indent: -85.0px; font: 12.0px Helvetica}
+p.p11 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica}
+p.p12 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica; min-height: 17.0px}
+p.p13 {margin: 0.0px 0.0px 0.0px 85.0px; text-indent: -85.0px; font: 12.0px Helvetica; min-height: 14.0px}
+p.p14 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #ad140d}
+p.p15 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #ad140d; min-height: 12.0px}
+p.p16 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px}
 span.s1 {font: 18.0px Helvetica}
-span.s2 {color: #0020f6}
+span.s2 {color: #0030ef}
 span.s3 {color: #000000}
 span.s4 {text-decoration: underline}
-span.s5 {color: #0000bf}
+span.s5 {color: #001bb9}
 span.s6 {color: #606060}
-span.s7 {color: #bf0000}
+span.s7 {color: #ad140d}
 span.s8 {color: #6f7178}
-span.s9 {font: 14.0px Helvetica}
-span.s10 {font: 11.0px Monaco; color: #0018b8}
+span.s9 {color: #0000ff}
+span.s10 {color: #007300}
+span.s11 {font: 9.0px Monaco; color: #007300}
+span.s12 {font: 14.0px Helvetica}
+span.s13 {font: 11.0px Monaco; color: #0024b3}
 span.Apple-tab-span {white-space:pre}
 </style>
 </head>
@@ -55,102 +55,117 @@
 <p class="p1">It also frees the buffers that the scope allocated and stops the FFT analysis synth. So:</p>
 <p class="p2"><br></p>
 <p class="p6"><span class="Apple-tab-span">  </span><span class="Apple-tab-span">    </span>(</p>
-<p class="p7"><span class="Apple-tab-span">  </span><span class="Apple-tab-span">    </span>w = <span class="s5">SCWindow</span>(<span class="s6">"My Analyzer"</span>, <span class="s5">Rect</span>(0, 0, 511, 300));</p>
-<p class="p7"><span class="Apple-tab-span">  </span><span class="Apple-tab-span">    </span>f = <span class="s5">SCFreqScope</span>(w, w.view.bounds);</p>
-<p class="p7"><span class="Apple-tab-span">  </span><span class="Apple-tab-span">    </span>w.onClose_({ f.kill });<span class="Apple-converted-space">  </span><span class="s7">// YOU MUST HAVE THIS</span></p>
-<p class="p7"><span class="Apple-tab-span">  </span><span class="Apple-tab-span">    </span>w.front;</p>
-<p class="p7"><span class="Apple-tab-span">  </span><span class="Apple-tab-span">    </span><span class="s3">)</span></p>
+<p class="p6"><span class="Apple-tab-span">  </span><span class="Apple-tab-span">    </span>w = <span class="s5">SCWindow</span>(<span class="s6">"My Analyzer"</span>, <span class="s5">Rect</span>(0, 0, 511, 300));</p>
+<p class="p6"><span class="Apple-tab-span">  </span><span class="Apple-tab-span">    </span>f = <span class="s5">SCFreqScope</span>(w, w.view.bounds);</p>
+<p class="p6"><span class="Apple-tab-span">  </span><span class="Apple-tab-span">    </span>w.onClose_({ f.kill });<span class="Apple-converted-space">  </span><span class="s7">// YOU MUST HAVE THIS</span></p>
+<p class="p6"><span class="Apple-tab-span">  </span><span class="Apple-tab-span">    </span>w.front;</p>
+<p class="p6"><span class="Apple-tab-span">  </span><span class="Apple-tab-span">    </span>)</p>
 <p class="p2"><br></p>
 <p class="p5"><b>Creation / Class Methods</b></p>
-<p class="p8"><br></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span>*new (parent, bounds)</b></p>
-<p class="p10"><b><span class="Apple-tab-span">      </span></b></p>
-<p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span><b>parent </b>-<span class="Apple-converted-space">  </span>The parent view.</p>
-<p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span><b>bounds </b>- An instance of <a href=""><span class="s8">Rect</span></a>,<span class="Apple-converted-space">  </span>or<span class="Apple-converted-space">  </span>a <a href=""><span class="s8">Point</span></a> indicating width@height.</p>
-<p class="p8"><br></p>
-<p class="p8"><br></p>
-<p class="p12"><b>Instance Methods</b></p>
-<p class="p13"><br></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span>kill</b></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span><span class="Apple-tab-span">    </span>Very important</b>.<span class="Apple-converted-space">  </span>This must be run when the parent window is closed to avoid problems. It also frees the buffers that the scope allocated and stops the FFT analysis synth.</p>
-<p class="p10"><span class="Apple-tab-span"> </span></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span>active</b></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span>active_ (bool)</b></p>
-<p class="p10"><b><span class="Apple-tab-span">      </span></b></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span><span class="Apple-tab-span">    </span></b>Turn the scope on or off.</p>
-<p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span><b>bool </b>- An instance of Boolean.</p>
-<p class="p14"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span>freqMode</b></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span>freqMode_ (mode)</b></p>
-<p class="p10"><b><span class="Apple-tab-span">      </span></b></p>
-<p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span><b>mode </b>- 0= linear, 1= logarithmic.</p>
-<p class="p14"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span>inBus</b></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span>inBus_ (num)</b></p>
-<p class="p10"><b><span class="Apple-tab-span">      </span></b></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span><span class="Apple-tab-span">    </span></b>The bus to listen on.</p>
-<p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span><b>num </b>- an audio<span class="Apple-converted-space">  </span><a href=""><span class="s2">Bus</span></a> number.</p>
-<p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span><span class="Apple-tab-span">    </span><span class="Apple-tab-span">    </span></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span>dbRange</b></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span>dbRange_ (db)</b></p>
-<p class="p10"><b><span class="Apple-tab-span">      </span></b></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span><span class="Apple-tab-span">    </span></b>Get/set the amplitude range.</p>
-<p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span><b>db </b>- A <a href=""><span class="s2">Number</span></a>.</p>
-<p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span><span class="Apple-tab-span">    </span><span class="Apple-tab-span">    </span></p>
-<p class="p12"><b>Subclassing and Internal Methods<span class="Apple-converted-space"> </span></b></p>
-<p class="p9"><span class="s9"><span class="Apple-tab-span"> </span></span>The following methods are usually not used directly or are called by a primitive. Programmers can still call or override these as needed.<span class="Apple-converted-space"> </span></p>
-<p class="p10"><span class="Apple-tab-span"> </span></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span>*viewClass</b><span class="Apple-converted-space">  </span>Returns <span class="s10">SCScope</span>.<span class="Apple-converted-space">  </span>See also Subclassing and Internal Methods in <a href=""><span class="s2">SCView</span></a></p>
-<p class="p8"><br></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span>*initClass</b><span class="Apple-converted-space">  </span>Sets the classVar , <b>server</b> = Server.internal.</p>
-<p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span>server</b> - A classVar. must be Server.internal</p>
-<p class="p9"><b><span class="Apple-tab-span">       </span>start</b></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span>eventSeq (delta, funcs)</b></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span>cmdPeriod</b></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span>initSCFreqScope</b></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span>sendSynthDefs</b></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span>allocBuffers</b></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span>freeBuffers</b></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span>node</b></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span>scopebuf</b></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span>fftbuf</b></p>
-<p class="p9"><b><span class="Apple-tab-span">       </span>bufSize</b></p>
-<p class="p10"><b><span class="Apple-tab-span">      </span></b></p>
-<p class="p12"><b>Examples</b></p>
+<p class="p7"><br></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>*new (parent, bounds)</b></p>
+<p class="p9"><b><span class="Apple-tab-span">       </span></b></p>
+<p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span><b>parent </b>-<span class="Apple-converted-space">  </span>The parent view.</p>
+<p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span><b>bounds </b>- An instance of <a href=""><span class="s8">Rect</span></a>,<span class="Apple-converted-space">  </span>or<span class="Apple-converted-space">  </span>a <a href=""><span class="s8">Point</span></a> indicating width@height.</p>
+<p class="p7"><br></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>*response (parent, bounds, bus1, bus2, freqMode)</b></p>
+<p class="p9"><b><span class="Apple-tab-span">       </span></b></p>
+<p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span>Create a scope in a special frequency-response mode. This uses FFT-based spectral division to estimate the frequency response of some effect, on the assumption that the signal to <b>bus1</b> is transformed to the signal at <b>bus2</b> by some linear time-invariant process.</p>
+<p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span><b>parent </b>-<span class="Apple-converted-space">  </span>The parent view.</p>
+<p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span><b>bounds </b>- An instance of <a href=""><span class="s8">Rect</span></a>,<span class="Apple-converted-space">  </span>or<span class="Apple-converted-space">  </span>a <a href=""><span class="s8">Point</span></a> indicating width@height.</p>
+<p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span><b>bus1</b> - The bus on which the "pre" signal is found.</p>
+<p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span><b>bus2</b> - The bus on which the "post" signal is found.</p>
+<p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span><b>freqMode</b> - linear (0) or log(1) frequency mode. Defaults to 1.</p>
+<p class="p7"><br></p>
+<p class="p7"><br></p>
+<p class="p11"><b>Instance Methods</b></p>
+<p class="p12"><br></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>kill</b></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span><span class="Apple-tab-span">    </span>Very important</b>.<span class="Apple-converted-space">  </span>This must be run when the parent window is closed to avoid problems. It also frees the buffers that the scope allocated and stops the FFT analysis synth.</p>
+<p class="p9"><span class="Apple-tab-span">  </span></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>active</b></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>active_ (bool)</b></p>
+<p class="p9"><b><span class="Apple-tab-span">       </span></b></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span><span class="Apple-tab-span">    </span></b>Turn the scope on or off.</p>
+<p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span><b>bool </b>- An instance of Boolean.</p>
+<p class="p13"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>freqMode</b></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>freqMode_ (mode)</b></p>
+<p class="p9"><b><span class="Apple-tab-span">       </span></b></p>
+<p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span><b>mode </b>- 0= linear, 1= logarithmic.</p>
+<p class="p13"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>inBus</b></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>inBus_ (num)</b></p>
+<p class="p9"><b><span class="Apple-tab-span">       </span></b></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span><span class="Apple-tab-span">    </span></b>The bus to listen on.</p>
+<p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span><b>num </b>- an audio<span class="Apple-converted-space">  </span><a href=""><span class="s2">Bus</span></a> number.</p>
+<p class="p9"><span class="Apple-tab-span">  </span><span class="Apple-tab-span">    </span><span class="Apple-tab-span">    </span><span class="Apple-tab-span">    </span></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>dbRange</b></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>dbRange_ (db)</b></p>
+<p class="p9"><b><span class="Apple-tab-span">       </span></b></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span><span class="Apple-tab-span">    </span></b>Get/set the amplitude range.</p>
+<p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span><b>db </b>- A <a href=""><span class="s2">Number</span></a>.</p>
+<p class="p9"><span class="Apple-tab-span">  </span><span class="Apple-tab-span">    </span><span class="Apple-tab-span">    </span><span class="Apple-tab-span">    </span></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>special (defname, extraArgs)</b></p>
+<p class="p9"><b><span class="Apple-tab-span">       </span></b></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span><span class="Apple-tab-span">    </span></b>Put the scope into a special mode using a user-specified <a href=""><span class="s9">SynthDef</span></a>. Note that only very particular SynthDefs should be used, namely ones that are derived from the <span class="s10">\</span><span class="s11">freqScope0</span> or <span class="s11">\freqScope1</span> SynthDefs. Most users will not need to use this method directly, but it can be used to provide a customised analysis shown in the scope.</p>
+<p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span><b>defname </b>- Name of the SynthDef you wish to use.</p>
+<p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span><b>extraArgs </b>- extra arguments that you may wish to pass to the synth.</p>
+<p class="p9"><span class="Apple-tab-span">  </span><span class="Apple-tab-span">    </span><span class="Apple-tab-span">    </span><span class="Apple-tab-span">    </span></p>
+<p class="p11"><b>Subclassing and Internal Methods<span class="Apple-converted-space"> </span></b></p>
+<p class="p8"><span class="s12"><span class="Apple-tab-span">        </span></span>The following methods are usually not used directly or are called by a primitive. Programmers can still call or override these as needed.<span class="Apple-converted-space"> </span></p>
+<p class="p9"><span class="Apple-tab-span">  </span></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>*viewClass</b><span class="Apple-converted-space">  </span>Returns <span class="s13">SCScope</span>.<span class="Apple-converted-space">  </span>See also Subclassing and Internal Methods in <a href=""><span class="s2">SCView</span></a></p>
+<p class="p7"><br></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>*initClass</b><span class="Apple-converted-space">  </span>Sets the classVar , <b>server</b> = Server.internal.</p>
+<p class="p9"><span class="Apple-tab-span">  </span><span class="Apple-tab-span">    </span></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>server</b> - A classVar. must be Server.internal</p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>start</b></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>eventSeq (delta, funcs)</b></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>cmdPeriod</b></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>initSCFreqScope</b></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>sendSynthDefs</b></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>allocBuffers</b></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>freeBuffers</b></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>node</b></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>scopebuf</b></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>fftbuf</b></p>
+<p class="p8"><b><span class="Apple-tab-span">       </span>bufSize</b></p>
+<p class="p9"><b><span class="Apple-tab-span">       </span></b></p>
+<p class="p11"><b>Examples</b></p>
+<p class="p2"><br></p>
+<p class="p14">// Start internal server</p>
+<p class="p6">s = <span class="s5">Server</span>.internal.boot;</p>
+<p class="p3"><br></p>
+<p class="p14">// Create analyzer in a window</p>
+<p class="p6">(</p>
+<p class="p6">w = <span class="s5">SCWindow</span>(<span class="s6">"My Analyzer"</span>, <span class="s5">Rect</span>(0, 0, 511, 300)); <span class="s7">// width should be 511</span></p>
+<p class="p6">f = <span class="s5">SCFreqScope</span>(w, w.view.bounds);</p>
+<p class="p14"><span class="s3">f.active_(</span><span class="s5">true</span><span class="s3">); <span class="Apple-tab-span">       </span></span>// turn it on the first time;</p>
+<p class="p3"><br></p>
+<p class="p6">w.onClose_({ f.kill });<span class="Apple-converted-space">  </span><span class="s7">// you must have this</span></p>
+<p class="p6">w.front;</p>
+<p class="p6">)</p>
+<p class="p3"><br></p>
+<p class="p6">{ <span class="s5">SinOsc</span>.ar([500, 1000], 0, 0.25).mean.dup }.play(s);<span class="Apple-converted-space">  </span><span class="s7">// start two sine waves</span></p>
+<p class="p3"><br></p>
+<p class="p14"><span class="s3">f.freqMode_(1);<span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span></span>// change to log scale so we can see them</p>
+<p class="p14"><span class="s3">f.inBus_(1);<span class="Apple-tab-span">    </span><span class="Apple-tab-span">    </span><span class="Apple-tab-span">    </span></span>// look at bus 1</p>
+<p class="p14"><span class="s3">f.dbRange_(200);<span class="Apple-tab-span">        </span><span class="Apple-tab-span">    </span></span>// expand amplitude range</p>
+<p class="p14"><span class="s3">f.active_(</span><span class="s5">false</span><span class="s3">);<span class="Apple-tab-span">       </span><span class="Apple-tab-span">    </span></span>// turn scope off (watch CPU)</p>
+<p class="p14"><span class="s3">f.active_(</span><span class="s5">true</span><span class="s3">);<span class="Apple-tab-span">        </span><span class="Apple-tab-span">    </span></span>// turn it back on<span class="Apple-tab-span">   </span><span class="Apple-tab-span">    </span><span class="Apple-tab-span">    </span><span class="Apple-tab-span">    </span></p>
+<p class="p3"><br></p>
+<p class="p3"><br></p>
+<p class="p14">// Now press command-period.<span class="Apple-converted-space">  </span>The scope is still running.</p>
+<p class="p3"><br></p>
+<p class="p3"><br></p>
+<p class="p6">{ <span class="s5">SinOsc</span>.ar([500, 1000], 0, 0.25).mean.dup }.play(s);<span class="Apple-converted-space">  </span><span class="s7">// start sines again</span></p>
+<p class="p3"><br></p>
+<p class="p3"><br></p>
+<p class="p14">// Close window and scope is killed.</p>
 <p class="p15"><br></p>
-<p class="p16">// Start internal server</p>
-<p class="p7">s = <span class="s5">Server</span>.internal.boot;</p>
-<p class="p17"><br></p>
-<p class="p16">// Create analyzer in a window</p>
-<p class="p7">(</p>
-<p class="p7">w = <span class="s5">SCWindow</span>(<span class="s6">"My Analyzer"</span>, <span class="s5">Rect</span>(0, 0, 511, 300)); <span class="s7">// width should be 511</span></p>
-<p class="p7">f = <span class="s5">SCFreqScope</span>(w, w.view.bounds);</p>
-<p class="p16"><span class="s3">f.active_(</span><span class="s5">true</span><span class="s3">); <span class="Apple-tab-span">       </span></span>// turn it on the first time;</p>
-<p class="p17"><br></p>
-<p class="p7">w.onClose_({ f.kill });<span class="Apple-converted-space">  </span><span class="s7">// you must have this</span></p>
-<p class="p7">w.front;</p>
-<p class="p7">)</p>
-<p class="p17"><br></p>
-<p class="p7">{ <span class="s5">SinOsc</span>.ar([500, 1000], 0, 0.25).mean.dup }.play(s);<span class="Apple-converted-space">  </span><span class="s7">// start two sine waves</span></p>
-<p class="p17"><br></p>
-<p class="p16"><span class="s3">f.freqMode_(1);<span class="Apple-tab-span"> </span><span class="Apple-tab-span">    </span></span>// change to log scale so we can see them</p>
-<p class="p16"><span class="s3">f.inBus_(1);<span class="Apple-tab-span">    </span><span class="Apple-tab-span">    </span><span class="Apple-tab-span">    </span></span>// look at bus 1</p>
-<p class="p16"><span class="s3">f.dbRange_(200);<span class="Apple-tab-span">        </span><span class="Apple-tab-span">    </span></span>// expand amplitude range</p>
-<p class="p16"><span class="s3">f.active_(</span><span class="s5">false</span><span class="s3">);<span class="Apple-tab-span">       </span><span class="Apple-tab-span">    </span></span>// turn scope off (watch CPU)</p>
-<p class="p16"><span class="s3">f.active_(</span><span class="s5">true</span><span class="s3">);<span class="Apple-tab-span">        </span><span class="Apple-tab-span">    </span></span>// turn it back on<span class="Apple-tab-span">   </span><span class="Apple-tab-span">    </span><span class="Apple-tab-span">    </span><span class="Apple-tab-span">    </span></p>
-<p class="p17"><br></p>
-<p class="p17"><br></p>
-<p class="p16">// Now press command-period.<span class="Apple-converted-space">  </span>The scope is still running.</p>
-<p class="p17"><br></p>
-<p class="p17"><br></p>
-<p class="p7">{ <span class="s5">SinOsc</span>.ar([500, 1000], 0, 0.25).mean.dup }.play(s);<span class="Apple-converted-space">  </span><span class="s7">// start sines again</span></p>
-<p class="p17"><br></p>
-<p class="p17"><br></p>
-<p class="p16">// Close window and scope is killed.</p>
-<p class="p18"><br></p>
-<p class="p18"><br></p>
-<p class="p18"><br></p>
-<p class="p19"><br></p>
+<p class="p15"><br></p>
+<p class="p15"><br></p>
+<p class="p16"><br></p>
 </body>
 </html>

Added: trunk/build/SCClassLibrary/Common/GUI/PlusGUI/Control/scopeResponse.sc
===================================================================
--- trunk/build/SCClassLibrary/Common/GUI/PlusGUI/Control/scopeResponse.sc                            (rev 0)
+++ trunk/build/SCClassLibrary/Common/GUI/PlusGUI/Control/scopeResponse.sc    2008-12-15 20:00:39 UTC (rev 8152)
@@ -0,0 +1,80 @@
+/*
+Server.default = s = Server.internal.boot;
+
+{|in| MoogFF.ar(in, freq: LFCub.kr(0.2).exprange(10, 10000))}.scopeResponse
+{|in| MoogFF.ar(in)}.scopeResponse
+
+LPF.scopeResponse
+HPF.scopeResponse
+MoogFF.scopeResponse
+BLowPass.scopeResponse
+BBandPass.scopeResponse
+BLowShelf.scopeResponse // by default BLowShelf doesn't mangle much
+Resonz.scopeResponse
+BRF.scopeResponse
+Integrator.scopeResponse
+Formlet.scopeResponse
+Median.scopeResponse // nonlinear, and therefore interesting
+Slew.scopeResponse
+
+*/
+
++ Function {
+     scopeResponse{ |server, freqMode=1, label="Empirical Frequency response"|
+
+             var bus1, bus2, synth, win, fs;
+             server = server ?? {Server.internal};
+
+             // Create two private busses
+             bus1 = Bus.audio(server, 1).postln;
+             bus2 = Bus.audio(server, 1).postln;
+
+             // Create the SCFreqScope.response using the same simple window as in the helpfile
+             // Also, onClose must free the synth and the busses
+
+             win = GUI.window.new(label, Rect(100, 100, 511, 300));
+             fs = GUI.freqScopeView.response(win, win.view.bounds, bus1, bus2, freqMode);
+             win.onClose_{
+                     fs.kill;
+                     server.bind{[synth, bus1, bus2].do(_.free)};
+             };
+             win.front;
+             fs.active_(true);
+
+             Task{
+                     1.1.wait;
+                     server.sync;
+                     // Create a synth using this function and the busses
+                     synth = {
+                         var son1, son2;
+                         son1 = PinkNoise.ar;
+                         son2 = this.value(son1);
+                         Out.ar(bus1, son1);
+                         Out.ar(bus2, son2);
+                         Out.ar(0, [son1, son2] * 0.1); // audible
+                     }.play(Node.basicNew(server, fs.node), addAction: \addBefore);
+             }.play;
+
+             ^fs
+     }
+}
+
+
++ Filter {
+     *scopeResponse { |server, freqMode=1, label, args|
+             var argNames = this.class.findRespondingMethodFor(\ar).argNames;
+             var hasFreqInput = argNames.includes(\freq);
+
+             ^if(hasFreqInput){
+                     {|in| this.ar(in: in, freq:MouseX.kr(10, 10000, 1)) * Line.ar(0,1,0.1) }
+                             .scopeResponse(server ?? {Server.internal}, freqMode,
+                                     label ?? {"%: empirical frequency response (move mouse to change freq)".format(this.asString)}
+                                     )
+             }{ // no freq input
+                     {|in| this.ar(in: in) * Line.ar(0,1,0.1) }
+                             .scopeResponse(server ?? {Server.internal}, freqMode,
+                                     label ?? {"%: empirical frequency response".format(this.asString)}
+                                     )
+             }
+     }
+}

Modified: trunk/build/SCClassLibrary/Common/GUI/osx/SCFreqScope.sc
===================================================================
--- trunk/build/SCClassLibrary/Common/GUI/osx/SCFreqScope.sc  2008-12-15 19:26:13 UTC (rev 8151)
+++ trunk/build/SCClassLibrary/Common/GUI/osx/SCFreqScope.sc  2008-12-15 20:00:39 UTC (rev 8152)
@@ -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 }

@@ -79,6 +80,45 @@
 //                   phasor = ((LFSaw.ar(rate/BufDur.kr(fftbufnum), phase, 0.5, 0.5).cubed * numSamples)+1).round(2);
 //                   ScopeOut.ar( ((BufRd.ar(1, fftbufnum, phasor, 1) * mul).ampdb * dbFactor) + 1, scopebufnum);
 //           }).send(server);
+
+             // These next two are based on the original two, but adapted by Dan Stowell
+             // to calculate the frequency response between two channels
+             SynthDef("freqScope0_magresponse", { arg in=0, fftbufnum=0, scopebufnum=1, rate=4, phase=1, dbFactor = 0.02, in2=1;
+                     var signal, chain, result, phasor, numSamples, mul, add;
+                     var signal2, chain2, divisionbuf;
+                     mul = 0.00285;
+                     numSamples = (BufSamples.kr(fftbufnum) - 2) * 0.5; // 1023 (bufsize=2048)
+                     signal = In.ar(in);
+                     signal2 = In.ar(in2);
+                     chain = FFT(fftbufnum, signal, hop: 0.75, wintype:1);
+                     divisionbuf = LocalBuf(BufFrames.ir(fftbufnum));
+                     chain2 = FFT(divisionbuf, signal2, hop: 0.75, wintype:1);
+                     // Here we perform complex division to estimate the freq response
+                     chain = PV_Div(chain2, chain);
+                     chain = PV_MagSmear(chain, 1);
+                     // -1023 to 1023, 0 to 2046, 2 to 2048 (skip first 2 elements DC and Nyquist)
+                     phasor = LFSaw.ar(rate/BufDur.kr(fftbufnum), phase, numSamples, numSamples + 2);
+                     phasor = phasor.round(2); // the evens are magnitude
+                     ScopeOut.ar( ((BufRd.ar(1, divisionbuf, phasor, 1, 1) * mul).ampdb * dbFactor) + 1, scopebufnum);
+             }).send(server);
+
+             SynthDef("freqScope1_magresponse", { arg in=0, fftbufnum=0, scopebufnum=1, rate=4, phase=1, dbFactor = 0.02, in2=1;
+                     var signal, chain, result, phasor, halfSamples, mul, add;
+                     var signal2, chain2, divisionbuf;
+                     mul = 0.00285;
+                     halfSamples = BufSamples.kr(fftbufnum) * 0.5;
+                     signal = In.ar(in);
+                     signal2 = In.ar(in2);
+                     chain = FFT(fftbufnum, signal, hop: 0.75, wintype:1);
+                     divisionbuf = LocalBuf(BufFrames.ir(fftbufnum));
+                     chain2 = FFT(divisionbuf, signal2, hop: 0.75, wintype:1);
+                     // Here we perform complex division to estimate the freq response
+                     chain = PV_Div(chain2, chain);
+                     chain = PV_MagSmear(chain, 1);
+                     phasor = halfSamples.pow(LFSaw.ar(rate/BufDur.kr(fftbufnum), phase, 0.5, 0.5)) * 2; // 2 to bufsize
+                     phasor = phasor.round(2); // the evens are magnitude
+                     ScopeOut.ar( ((BufRd.ar(1, divisionbuf, phasor, 1, 1) * mul).ampdb * dbFactor) + 1, scopebufnum);
+             }).send(server);

              "SCFreqScope: SynthDefs sent".postln;
      }
@@ -116,9 +156,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 +237,27 @@
              });
      }

+     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;
+             });
+     }
+
+     *response{ |parent, bounds, bus1, bus2, freqMode=1|
+             ^this.new(parent, bounds).inBus_(bus1.index)
+                     .special("freqScope%_magresponse".format(freqMode), [\in2, bus2])
+     }
 }

 SCFreqScopeWindow { //was FreqScope


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/


      
_______________________________________________
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/