Top-rated recipes tagged "scope"http://code.activestate.com/recipes/tags/scope/top/2013-06-19T19:06:50-07:00ActiveState Code RecipesDecorator to expose local variables of a function after execution [alternative implementation] (Python)
2010-07-08T09:44:28-07:00Andrea Maffezzolihttp://code.activestate.com/recipes/users/4171157/http://code.activestate.com/recipes/577295-decorator-to-expose-local-variables-of-a-function-/
<p style="color: grey">
Python
recipe 577295
by <a href="/recipes/users/4171157/">Andrea Maffezzoli</a>
(<a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/function/">function</a>, <a href="/recipes/tags/inner/">inner</a>, <a href="/recipes/tags/local/">local</a>, <a href="/recipes/tags/scope/">scope</a>, <a href="/recipes/tags/variables/">variables</a>).
Revision 6.
</p>
<p>Please note that the present is a fork of the <a href="http://code.activestate.com/recipes/577283/">recipe 577283</a> "Decorator to expose local variables of a function after execution" of Pietro Berkes, available at <a href="http://code.activestate.com/recipes/577283-decorator-to-expose-local-variables-of-a-function-/" rel="nofollow">http://code.activestate.com/recipes/577283-decorator-to-expose-local-variables-of-a-function-/</a> , and aiming only to report the alternative implementation "persistent_locals2", whose I'm co-author with Pietro Berkes, and which was submitted together to the original recipe. Refer to the latter for an exhaustive description and discussion.</p>
Decorator to expose local variables of a function after execution (Python)
2010-07-07T22:01:23-07:00Pietro Berkeshttp://code.activestate.com/recipes/users/4174299/http://code.activestate.com/recipes/577283-decorator-to-expose-local-variables-of-a-function-/
<p style="color: grey">
Python
recipe 577283
by <a href="/recipes/users/4174299/">Pietro Berkes</a>
(<a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/function/">function</a>, <a href="/recipes/tags/inner/">inner</a>, <a href="/recipes/tags/local/">local</a>, <a href="/recipes/tags/scope/">scope</a>, <a href="/recipes/tags/variables/">variables</a>).
Revision 2.
</p>
<p>Decorator to expose the local variables defined in the inner scope of a function. At the exit of the decorated function (regular exit or exceptions), the local dictionary is copied to a read-only property, <code>locals</code>.</p>
<p>The main implementation is based on injecting bytecode into the original function, and requires the lightweight module <code>byteplay</code> (available <a href="http://code.google.com/p/byteplay/">here</a>). See below for an alternative implementation that only uses the standard library.</p>
Bash Script For An Oscilloscope... (Bash)
2013-06-19T19:06:50-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578570-bash-script-for-an-oscilloscope/
<p style="color: grey">
Bash
recipe 578570
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/anim/">anim</a>, <a href="/recipes/tags/audio/">audio</a>, <a href="/recipes/tags/audioscope/">audioscope</a>, <a href="/recipes/tags/bash/">bash</a>, <a href="/recipes/tags/oscilloscope/">oscilloscope</a>, <a href="/recipes/tags/scope/">scope</a>, <a href="/recipes/tags/script/">script</a>, <a href="/recipes/tags/sound_exchange/">sound_exchange</a>, <a href="/recipes/tags/sox/">sox</a>, <a href="/recipes/tags/terminal/">terminal</a>).
</p>
<p>This code is the latest as of 19-06-2013. It is an AudioScope designed around a Macbook Pro 13"
of which only has ONE microphone input. It works under Linux variants too. Read the code for
much more info.</p>
<p>It was my way of learning Bash scripting.</p>
<p>It is resident here at this site:-</p>
<p><a href="http://www.unix.com/shell-programming-scripting/212939-start-simple-audio-scope-shell-script.html" rel="nofollow">http://www.unix.com/shell-programming-scripting/212939-start-simple-audio-scope-shell-script.html</a></p>
<p>It started off as a fun idea and is now becoming a very serious project.</p>
<p>As it stands this is fully working but it is uncalibrated and this is where it will stay on this site.</p>
<p>As the above site is the host then all future uploads will be there...</p>
<p>To do list...</p>
<p>DC input. [1]
DC polarity. [1]
2 more Internal sync modes.
External triggering.
Zoom facility - if possible in text mode.
Vertical calibration. [2]
Frequency measurement. {3]
(Others.)</p>
<p>[1] I have simple HW built as an idea but yet to prove it...
[2] Preliminary HW built but not yet used. Calibration SW and circuit(s) to be built into script as it progresses.
[3] I already have a working script but not completely satisfied at it at this point...</p>
<p>I am noing to say much else except that it has already been given a 5 star rating on the above UNIX site...</p>
<p>As it stands this code is entirely Public Domian and you may do with it as you please...</p>
<p>Enjoy something completely different using Bash scripting...</p>
<p>Finally the code defaults to a DEMO mode which requires no HW access at all but everything is still functional...</p>
<p>__Thoroughly__ read the code for more information...</p>
<p>As a circuit is inside the script then it is best viewed in plan text mode.</p>
<p>Bazza, G0LCU.</p>
For MacBook_Pro-Heads Only. Simple LF Audio Oscilloscope Using Standard Text Mode Python. (Python)
2012-10-07T14:15:55-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578282-for-macbook_pro-heads-only-simple-lf-audio-oscillo/
<p style="color: grey">
Python
recipe 578282
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/anim/">anim</a>, <a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/audio/">audio</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/display/">display</a>, <a href="/recipes/tags/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/oscilloscope/">oscilloscope</a>, <a href="/recipes/tags/pyaudio/">pyaudio</a>, <a href="/recipes/tags/scope/">scope</a>, <a href="/recipes/tags/sound/">sound</a>).
</p>
<p>For MacBook_Pro-Heads Only. Simple LF Audio Oscilloscope Using Standard Text Mode Python.</p>
<p>SimpleScope_OSX.py</p>
<p>Do you remember this upload from myself on 26-06-2011...</p>
<p><a href="http://code.activestate.com/recipes/577771-simple-lf-audio-oscilloscope-using-standard-text-m/?in=user-4177147" rel="nofollow">http://code.activestate.com/recipes/577771-simple-lf-audio-oscilloscope-using-standard-text-m/?in=user-4177147</a></p>
<p>Well here is an August 2012 vintage MacBook Pro 13 inch version of it for OSX 10.7.5...</p>
<p>This is proof of concept code for a kids level project I am doing for a MacBook Pro, 13 inch, OSX 10.7.5.
A DEMO to show how to display a waveform using standard text mode Python.
"pyaudio" must be installed for this to work.
Levels are set using the standard audio mixers, (System Preferences -> Sound).</p>
<p>Just whistle a signal of say 300Hz to 3KHz, (normal voice spectrum), using say, the internal mic, and watch a waveform appear inside the X-Y graticule.</p>
<p>Read the code for more information.</p>
<p>$VER: SimpleScope_OSX.py_Version_0.00.10_(C)2012_B.Walker_G0LCU.</p>
<p>This code is GPL2, but, the hardware information is Public Domain.</p>
<p>(I am looking into including Windows and Linux variants too using pyaudio to access the sound system.)</p>
<p>Enjoy finding simple solutions to often very difficult problems.</p>
<p>Bazza, G0LCU...</p>
Simple LF Audio Oscilloscope Using Standard Text Mode Python. (Python)
2011-06-26T21:42:55-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/577771-simple-lf-audio-oscilloscope-using-standard-text-m/
<p style="color: grey">
Python
recipe 577771
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/anim/">anim</a>, <a href="/recipes/tags/audio/">audio</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/display/">display</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/oscilloscope/">oscilloscope</a>, <a href="/recipes/tags/scope/">scope</a>, <a href="/recipes/tags/sound/">sound</a>).
</p>
<p>A Linux DEMO to show how to display a waveform using standard text mode Python.
The audio device /dev/dsp is used and must be available. Levels are set using the
standard audio mixers.</p>
<p>Just feed a signal of say 300Hz to 3KHz, (normal voice spectrum), using say, the
internal mic, and watch the waveform appear inside the X-Y graticule.</p>
<p>This method WILL be used for a program proper and may be uploaded to this site
in the future.</p>
<p>Read the code for more information.</p>
<p>This code is Public Domain and you may do with it as you please.</p>
<p>Enjoy finding simple solutions to often very difficult problems.</p>
Simple LF Audio Oscilloscope Using Standard Python. (Python)
2011-04-07T17:17:57-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/577644-simple-lf-audio-oscilloscope-using-standard-python/
<p style="color: grey">
Python
recipe 577644
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/anim/">anim</a>, <a href="/recipes/tags/audio/">audio</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/display/">display</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/oscilloscope/">oscilloscope</a>, <a href="/recipes/tags/scope/">scope</a>, <a href="/recipes/tags/sound/">sound</a>).
</p>
<p>AudioScope.py</p>
<p>I think this might be a first for both Python.</p>
<p>Initially uploaded to LXF, now also here under the MIT licence.</p>
<p>I am building a kids level seismometer and wanted to use standard Python inside Linux.</p>
<p>This DEMO code was my starter idea and looks as though using standard ASCII only might just work a real treat.</p>
<p>I've issued it to LXF under the MIT licence for future reasons.</p>
<p>It doesn't look much on screen except that the waveform(s) shown is/are a basic visual, electrical representation
of your voice. ;o)</p>
<p>It is possible to link the earphone socket on this notebook to the mic input and start the Audio Function
Generator, elsewhere in this site, in a separate Python terminal and see those waveforms inside the
AudioScope.py`s own Python terminal.</p>
<p>This grabs a 1 second 8KB burst, and then displays it onto the Python terminal. The timebase, amplitude, trigger,
single shot and others are not included but the main grab and display using /dev/dsp is shown. This can be made
platform independent by changing the /dev/dsp to something external like the Arduino Dev Board. This uses
STANDARD Python 2.5.x and later and tested on PCLinuxOS 2009 and Debian 6.0.0.</p>
<p>Enjoy finding simple solutions to often very difficult problems.</p>
<p>Bazza, G0LCU.</p>