View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide

basic stereo input level meters

"LED style" level meters for inputs 1 & 2
matt rogalsky
(I am sure someone else has written better...)

usage:
Synth.play({ arg synth;
VU.kr(synth);
AudioIn.ar([1,2]);
});


VU {                                  
        
        *kr {      
        
        		arg synth;                             
                                                        
			var amp1,amp2,colors,cliplevel;
			var w;

			w = GUIWindow.new("In", Rect.newBy(870, 50, 105, 151));
			
			10.do({ arg i;
				StringView.new( w, Rect.newBy(35, 120-(i*11), 8, 8), "");
			});
			
			10.do({ arg i;
				StringView.new( w, Rect.newBy(71, 120-(i*11), 8, 8), "");
			});
			
			20.do({ arg i;
				w.at(i).backColor = Color.new(100,100,200);
			});

			cliplevel = 0.23; // set this to whatever value your inputs seem to clip at
			
			amp1 = Amplitude.kr(AudioIn.ar(1));
			amp2 = Amplitude.kr(AudioIn.ar(2));
			
			colors = [
				Color.new(0,100,0),
				Color.new(0,100,0),
				Color.new(0,100,0),
				Color.new(0,100,0),
				Color.new(0,100,0),
				Color.new(0,100,0),
				Color.new(0,100,0),
				Color.new(255,255,0),
				Color.new(255,255,0),
				Color.new(255,0,0)
			];

			synth.trepeat(0,0.1,{
				10.do({ arg i;
					if (amp1.poll >= ((cliplevel / 10) * i), 
					{w.at(i).backColor = colors.at(i)},
					{w.at(i).backColor = Color.new(100,100,200)});
				});
				10.do({ arg i;
					if (amp2.poll >= ((cliplevel / 10)  i), 
					{w.at(i+10).backColor = colors.at(i)},
					{w.at(i+10).backColor = Color.new(100,100,200)});
				});
			});
		

			^Plug.kr(0.0);
                
        }
        
}

/*
authors so far:
mattr
*/


Link to this Page