Note: please use the abstraction layer GUI.peakMeterView if possible! (see GUI). See also JSCView.
s.boot;
(
w = JSCWindow( "Meter", Rect( 200, 200, 200, 228 ), false );
b = JSCPeakMeter( w, Rect( 4, 4, 56, 220 ));
b.bus = Bus( \audio, s.options.numOutputBusChannels, 2, s );
w.front;
)
The meter can be configured, using the properties border, caption, captionVisible, captionPosition, rmsPainted, and holdPainted, as demonstrated by the following example:
(
JSCCheckBox( w, Rect( 70, 4, 126, 24 )).string_( "Border" ).action_({ arg v; b.border = v.value });
JSCCheckBox( w, Rect( 70, 32, 126, 24 )).string_( "Caption" ).action_({ arg v; b.caption = v.value });
JSCCheckBox( w, Rect( 90, 60, 126, 24 )).string_( "Visible" ).value_( true ).action_({ arg v; b.captionVisible = v.value });
JSCStaticText( w, Rect( 90, 88, 30, 24 )).string_( "Pos:" );
JSCPopUpMenu( w, Rect( 124, 88, 72, 24 )).items_([ \left, \right, \center ])
.action_({ arg v; b.captionPosition = v.items[ v.value ]});
JSCCheckBox( w, Rect( 70, 116, 126, 24 )).string_( "RMS Painted" ).value_( true ).action_({ arg v; b.rmsPainted = v.value });
JSCCheckBox( w, Rect( 70, 144, 126, 24 )).string_( "Hold Painted" ).value_( true ).action_({ arg v; b.holdPainted = v.value });
)
When the caption is active and visible, the label font can be changed:
b.font = JSCFont( "Eurostile", 11 );
b.font = JSCFont( "Andale Mono", 13 );
When the monitored bus is silent, you can pause the meter updates to save some CPU power:
b.active = false;
b.active = true;
A utility method for monitoring all the audio interface's inputs and outputs:
JSCPeakMeter.meterServer( s );
x = { (CoinGate.ar( (2 / SampleRate.ir) ! s.options.numOutputBusChannels, Impulse.ar( SampleRate.ir / 2 ))) * 0.7 }.play
x.free;
Regulating display refresh rate:
JSCPeakMeter.setRefreshRate( 5 ); // note: this is global per swing server
JSCPeakMeter.setRefreshRate( 30 ); // default
Horizontal layout:
(
w = JSCWindow( "Meter", Rect( 200, 200, 228, 63 ), false );
b = JSCPeakMeter( w, Rect( 4, 4, 220, 56 ))
.border_( true ).orientation_( \h );
b.bus = Bus( \audio, s.options.numOutputBusChannels, 2, s );
w.front;
)