Пример #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
	}	
}
Пример #2
0
	static void audioCB(AudioIOData& io){
		MyApp * self = (MyApp *)io.user();
		while(io()){
			self->phase += 0.001;
			float s0 = rng.uniformS() * sin(self->phase);
			float s1 = sin(self->phase * 100.);
			io.out(0) = s0;
			io.out(1) = s1;
		}
	}
Пример #3
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 and right output channel samples
		io.out(1,i) = s * ampR;
	}
}
// Our main audio callback
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
	while(io()){

		float s = io.in(0);		// get the line-in or microphone sample

		io.out(0) = s * ampL;	// set left and right output channel samples
		io.out(1) = s * ampR;
	}
}