Example #1
0
void audioCB(AudioIOData& io){
    
	while(io()){
        if(tmr()){
            //good way to get random numbers in gamma.  Uniform distribution between two numbers
            int tempHarmonic = rnd::uni(1,6);
 
            //set the center frequency by calling freq(freqYouWant)
            filter.freq(tempHarmonic*fundamentalFrequency);
            
            float tempWidth = (tempHarmonic*fundamentalFrequency)/rnd::uni(2,100);
            
            //set the filter's width (related to Q) by calling width(widthYouWant).
            filter.width(tempWidth);
            
            //print the filter's center frequency and width
            cout<< "frequency: " << (tempHarmonic*fundamentalFrequency) << endl << "width: " << tempWidth << endl;
        }          
        
        //this is how we filter our source.  
        float s = filter(src())*5.0;
        
		io.out(0) = io.out(1) = s; 
	}
}
Example #2
0
void audioCB(AudioIOData& io){

	while(io()){
		using namespace gam::rnd;

		if(tmr()){
			env0 = uni(0.4, 0.39);
			if(prob(0.8)){
				float r = uni(1.);
				tmr.period(r * 4);
				env0.period(r * 4);
			}
			
			int a = pick(8,6, 0.7);
			if(prob(0.2)) osc0.freq(quanOct(a, 440.));
			if(prob(0.1)) osc1.freq(quanOct(a, 220.));
			if(prob(0.1)) osc2.freq(quanOct(a, 110.));
			if(prob(0.1)) osc3.freq(quanOct(a,  55.));
			if(prob(0.2)) frq0 = lin(8000, 400);
			if(prob(0.2)) frq1 = lin(8000, 400);//printf("d");
		}
		
		float e = lag(env0());
		del0.delay(e);
		del1.delay(e * 0.9);
		
		float s = (osc0.up() * mod0() + osc1.up() * mod1() + osc2.up() * mod2() + osc3.up() * mod3()) * 0.05;
		res0.freq(frq0()); res1.freq(frq1());
		s = res0(s) + res1(s);

		float sl = ech0(del0(s), ap0(ech0()));
		float sr = ech1(del1(s), ap1(ech1()));

		io.out(0) = sl;
		io.out(1) = sr;
	}
	
}