Esempio n. 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;
	}
}
Esempio n. 2
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;
		}
	}