1declare name 		"capture";
2declare version 	"1.0";
3declare author 		"Grame";
4declare license 	"BSD";
5declare copyright 	"(c)GRAME 2006";
6
7//-------------------------------------------------
8// 		Capture : record up to 8s of sound and
9//		playback the recorded sound in loop
10//-------------------------------------------------
11
12import("music.lib");
13
14B = checkbox("Capture");	// Capture sound while pressed
15I = int(B);			// convert button signal from float to integer
16R = (I-I') <= 0;		// Reset capture when button is pressed
17D = (+(I):*(R))~_;		// Compute capture duration while button is pressed: 0..NNNN0..MMM
18
19
20capture = *(B) : (+ : delay(8*65536, D-1)) ~ *(1.0-B) ;
21
22
23smooth(c)	= *(1-c) : +~*(c);
24level		= hslider("level (db)", 0, -96, 4, 0.1) : db2linear : smooth(0.999);
25
26process 	= vgroup( "Audio Capture", capture : *(level) ) ;
27
28