Пример #1
0
// create a callback for generating a block of samples
void audioCB(AudioIOData& io){

	UserData& user = *(UserData *)io.user();
	float ampL = user.ampL;
	float ampR = user.ampR;

	// loop through the number of samples in the block
	for(int i=0; i<io.framesPerBuffer(); ++i){
		
		float s = io.in(0,i);		// get the line-in or microphone sample
		
		io.out(0,i) = s * ampL;		// set left  output sample
		io.out(1,i) = s * ampR;		// set right output sample
	}

	// an alternative way to loop through the sample buffers
	while(io()){
		io.out(0) *= 0.5;			// scale left  output sample
		io.out(1) *= 0.5;			// scale right output sample
	}

	// if looping again, you must reset the frame iterator
	io.frame(0);
	while(io()){
		io.out(0) *= 2;				// scale left  output sample
		io.out(1) *= 2;				// scale right output sample
	}	
}