// GraphElem peak = UGen.ar( "Peak", in, t_trig );
GraphElem trigA = UGen.ar( "Trig1", t_trig, UGen.ir( "SampleDur" ));
// GraphElem peak = UGen.ar( "Peak", in, trigA );
GraphElem peak = UGen.kr( "Peak", in, trigA );
final GraphElem out;
final SynthDef def;
GraphElem temp;
if( numChannels > 1 ) {
temp = peak;
peak = temp.getOutput( 0 );
for( int i = 1; i < numChannels; i++ ) {
// peak = UGen.ar( "max", peak, temp.getOutput( i ));
peak = UGen.kr( "max", peak, temp.getOutput( i ));
}
temp = rms;
rms = temp.getOutput( 0 );
for( int i = 1; i < numChannels; i++ ) {
rms = UGen.ar( "+", rms, temp.getOutput( i ));
}
rms = UGen.ar( "*", rms, UGen.ir( 1.0f / numChannels ));
}
// 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 = UGen.kr( "Out", i_kOtBs, UGen.array( UGen.kr( "Latch", peak, t_trig ), rms ));
out = UGen.kr( "Out", i_kOtBs, UGen.array( peak, rms ));
def = new SynthDef( "swing-peak" + numChannels, out );
// def.writeDefFile( new java.io.File( "/Users/rutz/Desktop/meters.scsyndef" ));
return def;
}