MyApp(){
		lpf.type(LOW_PASS);		// Set filter to low-pass response
		lpf.res(4);				// Set resonance amount to emphasize filter
		env.attack(0.01);		// Set short (10 ms) attack
		env.decay(0.4);			// Set longer (400 ms) decay
		tmr.freq(120./60.*4.);	// Set timer frequency to 120 BPM
		tmr.phaseMax();			// Ensures timer triggers on first sample
		modCutoff.period(30);	// Set period of cutoff modulation
		modCutoff.phase(0.5);	// Start half-way through cycle
		freq.lag(0.1);			// Lag time of portamento effect
		step=0;
	}
Example #2
0
void audioCB(AudioIOData& io){

	while(io()){

		float s = src();

		// Input next sample for analysis
		// When this returns true, then we have a new spectral frame
		if(stft(s)){
		
			float frac = scl::pow3( edge.triU() );
			int N = stft.numBins();
			
			for(int k=0; k<N; ++k){
				int indKnee = frac * N;
				stft.bin(k) *= k < indKnee ? 1:0;
			}
		}
		
		// Get next resynthesized sample
		s = stft() * 0.2;
		
		io.out(0) = s;
		io.out(1) = s;
	}
}
	void onAudio(AudioIOData& io){
		while(io()){

			if(tmr()){
				// Our sequence of pitches
				float pitches[] = {0,0,12,0,0,10,-5,0};
				// Map pitch class to a frequency in Hz
				float f = 55 * pow(2, pitches[step]/12.);
				// Increment step counter
				step = (step + 1) % 8;
				// Set new target frequence of portamento
				freq = f;
				// Restart envelope using a soft reset (to avoid clicks)
				env.resetSoft();
			}

			// Set saw frequency from portamento filter
			saw.freq(freq());

			// Get next envelope value
			float e = env();
			// Map envelope value to cutoff frequency
			lpf.freq(e * (modCutoff.paraU()*6000 + 500) + 40);
			// Generate next saw sample
			float s = saw() * 0.3;
			// Filter saw sample
			s = lpf(s) * e;
			// Send sample to DAC
			io.out(0) = io.out(1) = s;
		}
	}
void audioCB(AudioIOData& io){

	while(io()){
		
		if(tmr()){
			switch(flangeType){
			case 0:	printf("Low-pass feedforward\n");
				flanger.feeds(0.7, 0); break;
			case 1:	printf("High-pass feedforward\n");
				flanger.feeds(-0.7,0); break;
			case 2:	printf("Low-pass feedback\n");
				flanger.feeds(0,0.7); break;
			case 3:	printf("High-pass feedback\n");
				flanger.feeds(0,-0.7); break;
			case 4:	printf("Low-pass dual-feed\n");
				flanger.feeds(0.7,0.7); break;
			case 5:	printf("High-pass dual-feed\n");
				flanger.feeds(-0.7,-0.7); break;
			case 6:	printf("All-pass 1\n");
				flanger.feeds(0.9,-0.9); break;
			case 7:	printf("All-pass 2\n");
				flanger.feeds(-0.9,0.9); break;
			}
			(++flangeType) %= 8;
		}
		
		float s = src.up();
		s = flanger(s)*0.1;

		io.out(0) = io.out(1) = s;
	}
}
Example #5
0
	void onAudio(AudioIOData& io){

		while(io()){

			if(tmr()){
				switch(feedType){
				case 0:	printf("Low-pass feedforward\n");
					comb.feeds( 1,0); break;
				case 1:	printf("High-pass feedforward\n");
					comb.feeds(-1,0); break;
				case 2:	printf("Low-pass feedback\n");
					comb.feeds(0,0.7); break;
				case 3:	printf("High-pass feedback\n");
					comb.feeds(0,-0.7); break;
				case 4:	printf("Low-pass dual-feed\n");
					comb.feeds(0.7,0.7); break;
				case 5:	printf("High-pass dual-feed\n");
					comb.feeds(-0.7,-0.7); break;
				case 6:	printf("All-pass 1\n");
					comb.feeds(0.9,-0.9); break;
				case 7:	printf("All-pass 2\n");
					comb.feeds(-0.9,0.9); break;
				}
				(++feedType) %= 8;
			}
			
			float s = src()*0.1;
			
			comb.ipolType(ipl::ROUND);
			comb.delay(mod.triU() * 1./400 + 1./10000);
			s = comb(s);

			io.out(0) = io.out(1) = s;
		}
	}
Example #6
0
	MyApp(){
		feedType=0;
		tmr.phaseMax();
		tmr.period(4);
		mod.period(4);
		src.freq(100);
		comb.maxDelay(1./100);
	}
Example #7
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);
	}
}
Example #9
0
	void onAudio(AudioIOData& io){

		// Set the frequency, in Hz
		buzz.freq(55);

		mod.period(16);

		while(io()){

			int nh = mod.triU() * 64;

			// Set number of harmonics
			buzz.harmonics(nh);
	
			float s = buzz() * 0.2;

			io.out(0) = s;
			io.out(1) = s;
		}
	}
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;
	}
}
Example #11
0
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;
	}
}
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()){
	
		int nh = mod.triU() * 64;
		buzz.harmonics(nh);
	
		float s = buzz();

		io.out(0) = io.out(1) = s*0.2;
	}
}
Example #14
0
	void onAudio(AudioIOData& io){
		while(io()){
			if(syncMode()){
				softSync^=true;
				printf("%s sync\n", softSync?"soft":"hard");
			}

			// When the sync osc completes cycle, reset the phase of the formant osc
			float w = sync.up();
			if(sync.cycled()) formant.phase(0);

			// Set the pitch of the formants
			formant.freq(mod.triU()*2200+200);

			// The formant oscillator determines the spectral envelope
			float s = formant.tri();

			// Drop amp to zero at sync points?
			if(softSync){
				w = 1.f - scl::pow8(w);	// flattop window
				s *= w;					// apply window
			}

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

	while(io()){
		
		float cutoff = scl::pow3(mod.triU()) * 10000;
		
		filt.freq(cutoff);
		
		float s = filt(src());
			
		io.out(0) = io.out(1) = s * 0.2f;
	}
}
Example #16
0
void audioCB(AudioIOData& io){

	while(io()){

		if(tmr()){
			for(int i=0; i<filt.size(); ++i){
				filt.set(i,
					Vowel::freq(Vowel::WOMAN, (Vowel::Phoneme)ivowel(), i),
					Vowel::amp(Vowel::WOMAN, (Vowel::Phoneme)ivowel(), i)
				);
			}
			++ivowel;
		}

		osc.freq(330.5 + vib()*3);
		osc.mod(0.2);

		float s = osc.pulse();
		
		s = filt(s);

		io.out(0) = io.out(1) = s * 0.1f;
	}
}
Example #17
0
void audioCB(AudioIOData& io){

	while(io()){

		// Generate our mono signal
		float s = src() * 0.2;

		// Modulate pan position between left (-1) and right (1) channels		
		pan.pos(panMod.tri());

		// The output is two floats (stereo)
		float2 xy = pan(s);

		io.out(0) = xy.x;
		io.out(1) = xy.y;
	}
}
void audioCB(AudioIOData& io){

	while(io()){
		float s	= sineT1()
				+ sineT2.nextL()
				+ sineCS().i
				+ sineC1.cos()
				+ sineC2()
				+ sineRs()
		;

		s = s/6 - sin(sineC3.nextPhase());	// pass only the artifacts
		
		io.out(0) = io.out(1) = s * 0.2f;
	}

}
Example #19
0
	MyApp()
	:	stft(4096, 4096/4, 0, HANN, COMPLEX),
		chrA1(0.31, 0.002, 0.20111, -0.7, 0.9),
		chrA2(0.22, 0.002, 0.10151, -0.7, 0.9),
		chrA3(0.13, 0.002, 0.05131, -0.7, 0.9),
		chrB1(0.31, 0.002, 0.20141, -0.7, 0.9),
		chrB2(0.22, 0.002, 0.10171, -0.7, 0.9),
		chrB3(0.13, 0.002, 0.05111, -0.7, 0.9)
	{
		tmr.period(10);
		osc1.freq(40);
		osc2.freq(40.003);
		oscA.freq(62);
		oscB.freq(62.003);
		mix.period(60);
		modfs1.period(101);
		modfs2.period(102);
	}
Example #20
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;
	}
	
}
Example #21
0
void audioCB(AudioIOData& io){

	while(io()){
		
		if(tmr()){
			switch(cnt){
				case 0: filt.type(Filter::LP); printf("Low-pass\n"); break;
				case 1: filt.type(Filter::HP); printf("High-pass\n"); break;
				case 2: filt.type(Filter::BP); printf("Band-pass\n"); break;
				case 3: filt.type(Filter::BR); printf("Band-reject\n"); break;
			}
			++cnt %= 4;
		}
		
		float cutoff = scl::pow3(mod.triU()) * 10000;

		filt.res(4);
		filt.freq(cutoff);
		
		float s = filt(src());
	
		io.out(0) = io.out(1) = s * 0.1f;
	}
}
Example #22
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;
		}
	}
Example #23
0
	void onAudio(AudioIOData& io){

		while(io()){

			// Increment waveform type
			if(tmr()) (++waveform)%=13;

			// Modulate modifier parameter with raised cosine
			osc.mod(mod.cosU());
		
			float s = 0.f;
			
			switch(waveform){ 
					
				// non-modifiable generators ordered from dull to bright:
				case  0: s = osc.cos();		break;		// Cosine approximation: one harmonic
				case  1: s = osc.even3();	break;		// Even harmonic sine-like wave (3rd order)
				case  2: s = osc.even5();	break;		// Even harmonic sine-like wave (5th order)
				case  3: s = osc.tri();		break;		// Triangle wave: 1/f^2 odd harmonics
				case  4: s = osc.para();	break;		// Parabola train: 1/f^2 all harmonics
				case  5: s = osc.sqr()/4;	break;		// Square wave: 1/f odd harmonics
				case  6: s = osc.down()/4;	break;		// Downward saw wave: 1/f all harmonics
				case  7: s = osc.up()/4;	break;		// Upward saw wave: 1/f all harmonics
				case  8: s = osc.imp()/4;	break;		// Impulse train: flat spectrum all harmonics
				
				// modifiable generators ordered from dull to bright:
				case  9: s = osc.stair()/4;	break;		// Mix between a square and impulse
				case 10: s = osc.pulse()/4;	break;		// Mix between up and down
				case 11: s = osc.line2()/4;	break;		// Mix between a saw and a triangle
				case 12: s = osc.up2()/4;	break;		// Mix between two saws
			}
			
			io.out(0) = io.out(1) = s * 0.2f;
		}
	}
Example #24
0
	MyApp(){
		tmr.period(2);
		mod.period(2);
		osc.freq(220);
		waveform=0;
	}
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;
	}
}