SwingOSCJava-based GUI classes

JSCPeakMeterView

!!!INCOMPLETE!!!

Note: please use the abstraction layer GUI.peakMeterView if possible! (see GUI). See also JSCView.

s.boot;


(

    w = JSCWindow( "Meter", Rect( 200, 200, 128, 225 ), false );

    b = JSCPeakMeterView( w, Rect( 4, 4, 56, 217 ));

    b.bus = Bus( \audio, s.options.numOutputBusChannels, 2, s );

    w.front;

)


b.border = true;

b.border = false;

b.caption = true;

b.caption = false;

b.caption = true;

b.font = JFont( "Eurostile", 11 );

b.font = JFont( "Andale Mono", 13 );

b.captionVisible = false;

b.captionVisible = true;

b.captionPosition = \right;

b.captionPosition = \left;

b.captionPosition = \center;

b.rmsPainted = false;

b.rmsPainted = true;

b.holdPainted = false;

b.holdPainted = true;


/*

b.bus = Bus( \audio, s.options.numOutputBusChannels, 4, s );

b.bounds = Rect( 4, 4, 72, 217 );

//b.refresh;


b.bounds = Rect( 4, 4, 120, 217 );

//b.refresh;

*/


s.boot;


b.mouseDownAction = { "Doing!".postln };



(

SynthDef( "eisk-meter", { arg i_aInBs = 0, i_kOtBs, t_trig;

var in, rms, peak;

in = In.ar( i_aInBs );

rms = Lag.ar( in.squared, 0.1 ); // Amplitude.ar reports strange things (at least not the RMS)

// peak nowaday DOES take the abs

// peak = Peak.ar( abs( in ), t_trig );

peak = Peak.ar( in, t_trig );

// we are reading the values asynchronously through

// a /c_getn on the meter bus. each request is followed

// by a /n_set to re-trigger the latch so that we are

// not missing any peak values.

Out.kr( i_kOtBs, [ Latch.kr( peak, t_trig ), rms ]);

}).send( s );

)


//x = Synth( "eisk-meter", [ \i_aInBs, b.bus.index, \i_kOtBs, ~cbus.index ], target: ~group );

//b.group = Group.tail( s );

b.active = true;

~synth = 2.collect({ arg i; Synth.basicNew( "eisk-meter", s )});

//~group = Group.tail( s );

s.listSendBundle( nil, x.collect({ arg synth, i; synth.newMsg( b.group, [ \i_aInBs, b.bus.index + i, \i_kOtBs, ~cbus.index + (i << 1) ])}));


s.dumpOSC( 0 )


// ~dust = { arg freq = 1000; Dust.ar( freq )}.play;


~rout = fork { inf.do({ s.sendBundle( nil, [ '/c_getn', ~cbus.index, 4 ], [ '/n_set', ~group.nodeID, \t_trig, 1 ]); 0.03.wait })};


s.dumpOSC( 1 )

s.dumpOSC( 0 )

g.dumpOSC( 0 )


b.active = false;


s.sendMsg( '/n_set', ~group.nodeID, \t_trig, 1 );

~group.trace


~meter = JavaObject.basicNew( b.id, b.server );


~resp = OSCpathResponder( s.addr, [ '/c_setn', 0, 4 ], { arg time, resp, msg; ~meter.meterUpdate( msg.copyToEnd( 3 ), 0, 0 )}).add;


SystemClock.seconds

thisThread.seconds

Date.getDate

thisThread.elapsed

Process.elapsedTime


~resp.remove;


public boolean meterUpdate( float[] peakRMSPairs, int offset, long time );



b.active = false;

x.do(_.free)


b.manager