Exemple #1
0
void audioCB(AudioIOData& io){
	using namespace gam::rnd;
	while(io()){

		if(tmr()){ if(prob()) rng++; }

		float mx = mix.hann();
		float s = (oscA.up() - oscB.up())*mx + (osc1.up() - osc2.up())*(1-mx);

		fshift1.freq(modfs1.tri()*2);
		fshift2.freq(modfs2.tri()*2);
		s = ((fshift1(s) + fshift2(s))/2 + s)/1;

		if(stft(s)){
		
			rnd::push(rng);
			float prb = rnd::uni(0.3, 0.1);
			for(unsigned k=0; k<stft.numBins(); ++k){
				//float frac = double(k)/stft.numBins();
				float m = pick(pick(2,1, 0.1),0, prb);
				stft.bins(k) *= m;
			}
			rnd::pop();
			stft.zeroEnds();
		}
			
		s = stft()*0.5;
		//float s0=s, s1=s;
		float s0 = chrA3(chrA2(chrA1(s)));
		float s1 = chrB3(chrB2(chrB1(s)));

		io.out(0) = s0;
		io.out(1) = s1;
	}
}
void audioCB(AudioIOData& io){

	while(io()){

		float s = osc();
		io.out(0) = io.out(1) = s * 0.2f;
		
		osc.phaseAdd(s*0.01*mod.hann());
		//osc.freq((s*0.5+0.5)*mod.hann()*800 + 400);
	}
}
void audioCB(AudioIOData& io){

	while(io()){

		oscM.freq(modFreq.hann() * 110 + 1);	// change modulator frequency

		float s = oscC() * (oscM() * 0.5 + 0.5) * 0.2;
		
		io.out(0) = io.out(1) = s;
	}
}
void audioCB(AudioIOData& io){

	while(io()){

		oscM.freq(modFreq.hann() * 110 + 1);	// change modulator frequency
		oscC.freq(ff + oscM()*100);				// modulate frequency of carrier

		float s = oscC() * 0.2;
		
		io.out(0) = io.out(1) = s;
	}
}
void audioCB(AudioIOData& io){

	while(io()){
	
		if(tmr()){
			if(cnt()){
				modMode ^= true;			// increment LFO type, switch mod mode when wraps
				printf("\nMod mode: %s modulation\n", modMode? "Amp" : "Freq");
			}
		}
			
		env.mod(mod.cosU());	// modulate modifier parameter with unipolar cosine wave

		float s = 0.f;			// initialize current sample to zero

		switch(cnt.val){			
				
			// non-modifiable generators ordered from smooth to sharp:
			case  0: s = env.cosU();	break;	// unipolar cosine
			case  1: s = env.hann();	break;	// a computed hann window (inverted cosU)
			case  2: s = env.triU();	break;	// unipolar triangle
			case  3: s = env.upU();		break;  // unipolar upward ramp
			case  4: s = env.downU();	break;  // unipolar downward ramp
			case  5: s = env.sqrU();	break;	// unipolar square

			// modifiable generator ordered from smooth to sharp:
			case  6: s = env.pulseU();	break;	// Mix between upward ramp and downward ramp
			case  7: s = env.stairU();	break;	// Mix between a square and impulse. 
			case  8: s = env.line2U();	break;	// Mix between a ramp and a triangle
			case  9: s = env.up2U();	break;  // Mix between two ramps			
		}
		
		if(modMode){			// amplitude modulate noise with envelope
			s *= noise();
		}
		else{					   // frequency modulate oscillator with envelope
			osc.freq(s*400 + 200); // between 100 and 200 hz
			s = osc.cos();
		}
		
		io.out(0) = io.out(1) = s*0.2;
	}
}
void audioCB(AudioIOData& io){
	using namespace gam::rnd;
	while(io()){

		float s = osc.up()*0.1;

		// The Hilbert transform returns a complex number
		Complex<float> c = hil(s);
		
		// Perform a frequency shift
		shifter.freq(shiftMod.hann()*1000);
		c *= shifter();
		
		// Output the real and imaginary components
		float s0 = c.r;
		float s1 = c.i;
	
		io.out(0) = s0;
		io.out(1) = s1;
	}
}
Exemple #7
0
	void onAudio(AudioIOData& io){
		while(io()){

			// Generate new seed?
			if(tmr()){ if(rnd::prob()) seed++; }

			// Modulated mix between pulse waves
			float mx = mix.hann();
			float s = (oscA.up() - oscB.up())*mx + (osc1.up() - osc2.up())*(1-mx);

			// Add frequency shifted versions of signal to get barberpole combs
			fshift1.freq(modfs1.tri()*2);
			fshift2.freq(modfs2.tri()*2);
			s += (fshift1(s) + fshift2(s))*0.5;

			if(stft(s)){
				// Apply spectral thin
				rnd::push(seed);
				float prb = rnd::uni(0.3, 0.1);
				for(unsigned k=0; k<stft.numBins(); ++k){
					//float frac = double(k)/stft.numBins();
					float m = rnd::pick(rnd::pick(2,1, 0.1),0, prb);
					stft.bin(k) *= m;
				}
				rnd::pop();
				stft.zeroEnds();
			}

			s = stft()*0.5;

			// "Spatialize" with modulated echoes
			float s0 = chrA3(chrA2(chrA1(s)));
			float s1 = chrB3(chrB2(chrB1(s)));

			io.out(0) = s0;
			io.out(1) = s1;
		}
	}