Classes | GUI > Interfaces

Stethoscope : Object

An oscilloscope
Subclasses: QStethoscope

Description

Stethoscope provides a complete oscilloscope GUI. It displays a window containing a bus-plotting ScopeView and an interface to configure the plotting and choose among the buses.

Creation by message .scope

Several classes provide a convenient 'scope' method that creates a Stethoscope to display their data. See for example: Server: -scope, Bus: -scope, Function: -scope.

Keyboard shortcuts

The following keyboard shortcuts may be used when focused on the Stethoscope display:

ShortcutAction
Jone channel back
Kswitch rate (audio vs. control)
Lone channel forward
Ojump to first hardware output channel and adjust numChannels to hardware
Ijump to first hardware input channel and adjust numChannels to hardware
spacerun, if not running already
. (period)stop
Mtoggle screen size
+ / -zoom horizontally
* / _zoom vertically
Schange style between parallel and overlay
Shift+Schange style to lissajou
Shift+Aallocate buffer size so it fills the screen (to next power of two) (this can be dangerous, might crash)

Class Methods

Stethoscope.new(server, numChannels: 2, index: 0, bufsize: 4096, zoom: 1, rate: 'audio', view, bufnum)

Create a Stethoscope, either as a window, or placed on a given parent view.

Arguments:

server

A valid Server (either a local or the internal server), or nil, in which case the Server.default is used.

numChannels

An integer. Default value is 2.

index

The offset index. An Integer. Default is nil.

bufsize

The size of the analysis buffer. Default is 4096. See also -bufsize.

zoom

Horizontal magnification of the displayed wave. Default is 1. See also -xZoom.

rate

\audio or \control. Default is \audio.

view

The optional parent view. Default is nil. If nil, then it will open in its own Window.

bufnum

The id number of the Buffer to analyze. Default value is nil. If nil, then a Buffer of size bufSize is allocated.

discussion: Example:

s.boot
{SinOsc.ar([330,440], 0, 0.4)}.play;
Stethoscope(s,2);

Stethoscope.isValidServer(aServer)

Tests whether Stethoscope can operate on the given server (any local server. See Server: -isLocal).

Arguments:

aServer

A Server.

Returns:

A Boolean.

Stethoscope.ugenScopes

Returns an array of the running ugen scopes.

s.boot
{[SinOsc.ar.scope,WhiteNoise.ar(0.5).scope]*0.1}.scope(2);
Stethoscope.ugenScopes; // returns the ugen scopes

Stethoscope.tileBounds

A utility method used by UGen: -scope to tile scope windows.

Returns:

A Rect.

Inherited class methods

Instance Methods

Data

.server

The server on which the scope operates.

.rate

.rate = argRate: 'audio'

Whether to operate on audio or control busses.

Arguments:

argRate

One of the two symbols: \audio or \control.

.index

.index = i

The starting index of the busses to scope.

Arguments:

i

An Integer.

.numChannels

.numChannels = n

The amount of adjacent busses to scope (from -index on).

Arguments:

n

An Integer.

.bufsize

Defines the maximum allowed -cycle.

.cycle

.cycle = val

NOTE: Only available in Qt GUI

The exact scoping period, in signal frames. Reciprocal to what is also known as sweep speed in analog oscilloscopes. It is dynamically adjustable while the scope is running.

Data from scoped signals will be accumulated into a buffer until it reaches cycle amount frames, at which point the buffering will immediately restart. The view will repeatedly display the entire buffer; it may skip a cycle if the drawing is too slow to keep up with the speed of incoming data, but the cycle boundaries will never shift with respect to signals.

If you are scoping a periodic signal, setting cycle to match the signal's period will keep the waveform locked in place.

Display

.window

The (parent) Window of the scope.

.size

.size = value

From superclass: Object

Sets the width and the height of the scope window.

Arguments:

value

An Integer (the window is square).

.toggleSize

Toggle between small and large size.

.zoom

.zoom = val

A synonym for -xZoom.

.xZoom

.xZoom = val

Magnifies the displayed wave horizontally to the given factor.

This sets -cycle to 1024 * xZoom.reciprocal.

Arguments:

val

A Float.

.yZoom

.yZoom = val

Magnifies the displayed wave vertically to the given factor.

Arguments:

val

A Float.

.style = val

The plotting style:

Arguments:

val

One of the above Integers.

Operation

.run

Starts the scope, if not already running.

.quit

Closes the window, and cleans up any used synths and buffers.

Convenience

.setProperties(numChannels, index, bufsize, zoom, rate)

Sets several properties at once: -numChannels, -index, -bufsize, -zoom, and -rate.

Inherited instance methods

Undocumented instance methods

.bus

.bus = b

.doOnServerQuit

.doOnServerTree

.initStethoscope(server_, parent, bus_, bufsize_, cycle_)

.keyDown(char, mod)

.largeSize

.largeSize = value

.scopeView

.smallSize

.smallSize = value

.stop

.switchRate

.toInputBus

.toOutputBus

.view

Examples

A step-by-step example

s.boot;
(
{
    SinOsc.ar([225, 450, 900], 0, 0.2)
    + LPF.ar(
        LFPulse.ar(226 * [1, 2, 5],[0,0.1,0.1],0.2, 0.2),
        MouseX.kr(20, 10000, 1)
        )
}.scope;
)

// server.scope only changes the properies explicitly given:

s.scope(numChannels:5);
s.scope(index:12);
s.scope(zoom:4);
s.scope(index:0);

s.scopeWindow.size = 600;
s.scopeWindow.size = 222;

// scoping buses:

a = Bus.audio(s, 4);
{ WhiteNoise.ar(0.2.dup(4)) }.play(s, a);

a.scope;

c = Bus.control(s, 3);
{ WhiteNoise.kr(1.dup(4) * MouseX.kr) }.play(s, c);

c.scope;

// note that scoping control rate buses shows block size interpolation (this is due to the
// fact that ScopeOut.kr doesn't work yet.)

Embedded use

You can pass your own view in to add a stethoscope to it:

w = Window.new("my own scope", Rect(20, 20, 400, 500));
w.view.decorator = FlowLayout(w.view.bounds);
c = Stethoscope.new(s, view:w.view);
w.onClose = { c.free }; // don't forget this
w.front;