SwingOSC – Java-based GUI classes

This class is meant as an emulation of SCFreqScope. last mod: 17-jul-09 sciss ; for bugs and different behaviour, see also the JSCStethoscope help file.

JSCScope

Note: please use the abstraction layer ScopeView if possible!

JSCScope shows a realtime view of a buffer, with horizontal axis corresponding to time (buffer frame offset) and vertical axis corresponding to amplitude. Most likely you will want to use JSCStethoscope instead which handles window creation, buffer recording from any input bus, and keyboard control. JSCScope can be useful if you want to combine it with other custom views, as shown in the following example:

(
s = JSCStethoscope.defaultServer.waitForBoot({
    b = Buffer.alloc( s, 1024 );
    w = JSCWindow( "My Analyzer", Rect( 0, 0, 284, 304 ), false );
    w.view.background = Color.hsv( 0.3, 0.5, 0.5 );
    f = JSCScope( w, Rect( 24, 4, 256, 276 )).bufnum_( b.bufnum )
        .background_( Color.green( 0.2 ))
        .opaque_( false );  // don't know why this is currently necessary ;-C
    u = JSCUserView( w, f.bounds ).canFocus_( false )
        .drawFunc_({ arg view;
            var b = view.bounds.moveTo( -1,-1 ),
                corners = [ b.leftTop, b.rightTop, b.rightBottom, b.leftBottom ],
                scales = [ 1 @ 1, -1 @ 1, -1 @ -1, 1 @ -1 ];
            JPen.fillColor = w.view.background;
            corners.do({ arg c, i;
                JPen.use({
                    JPen.translate( c.x, c.y ); JPen.scale( scales[ i ].x, scales[ i ].y );
                    JPen.moveTo( 0 @ 0 ); JPen.lineTo( 0 @ 100 ); JPen.quadCurveTo( 100 @ 0, 0 @ 0 );
                    JPen.fill;
                });
            });
        });
    JSCSlider( w, Rect( 0, 4, 24, 276 )).value_( 0.5 )
        .action_({ arg view; f.yZoom = view.value.linexp( 0, 1, 1/8, 8 )});
    JSCSlider( w, Rect( 24, 280, 256, 24 )).value_( 0.6 )
        .action_({ arg view; f.xZoom = view.value.linexp( 0, 1, 1/8, 4 )});
    x = { RecordBuf.ar( SinOsc.ar( SinOsc.ar( LFNoise1.kr( 1 )
        .linexp( -1, 1, 30, 3000 )).linexp( -1, 1, 30, 3000 ), 0, 0.25 ), b )}.play( s );
    w.onClose = { x.free; b.free };
    w.front;
});
)

Close window and the scope synth and buffer are killed.

The example shows how the buffer is assigned using the bufnum_ method, and how the sliders are used to do waveform scalling (xZoom_ and yZoom_).

Other customization methods include waveColor_, and style_. See the JSCStethoscope help file for more info on those.