void play(double &left, double &right) { if (count%(int)(SAMPLE_RATE*1.6)==0) { kick_freq.reset(); env_kick.reset(); } if (count%(int)(SAMPLE_RATE*6.4)==0) { env_bass.reset(); bass_freq.reset(); bass2_freq.reset(); } left += kick.freq(kick_freq.val()).val() * env_kick.val() * 0.3; left += fil_bass.io( bass.freq(bass_freq.val()).val() + bass2.freq(bass2_freq.val()).val() ) * env_bass.val() * 0.3; if (count%(int)(SAMPLE_RATE*25.6)==0) { for (int i = 0; i < 8; i++) { s0_freq[i] = rand()%5000+500; } } if (count%(int)(SAMPLE_RATE*3.2)==0) { s0_fade.reset(); } if (count%(int)(SAMPLE_RATE*0.1)==0) { if (s0_i > 7) s0_i = 0; s0.freq(s0_freq[s0_i++]); env_s0.reset(); if (rand()%4==0) { env_s1.reset(); } } left += s0.val() * env_s0.val() * s0_fade.val() * 0.1; left += s1.val() * env_s1.val() * 0.05; for (int n = 0; n < num; n++) { if (ars[n].done()) { sines[n].freq(rand()%1000+100); ars[n].set(0, 1, rand()%1000*0.01, 0, rand()%1000*0.01); } } for (int n = 0; n < num; n++) { left += sines[n].val() * ars[n].val() * 0.02; } right = left; }
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()){ env = fund*2 + rnd::uni(10.0); // set new target value of envelope } osc2.freq(env()); // modulate frequency of 2nd harmonic float s = (osc1() + osc2()) * 0.1; io.out(0) = io.out(1) = s; } }
void audioCB(AudioIOData& io){ while(io()){ if(tmr()){ freq = pow(2, rnd::uniS(1.))*440; } src.freq(freq()); float s = src(); io.out(0) = io.out(1) = s * 0.2f; } }
void onAudio(AudioIOData& io){ tmr.period(0.25); // Set time taken to reach new frequency value freq.lag(0.1); while(io()){ if(tmr()){ // Set new target frequency of one-pole freq = pow(2, rnd::uniS(1.))*440; } // Use smoothed output of one-pole for oscillator frequency src.freq(freq()); float s = src(); io.out(0) = io.out(1) = s * 0.2f; } }
void onAudio(AudioIOData& io){ while(io()){ src.freq(220); float s = src(); // Input next sample for analysis // When this returns true, then we have a new spectral frame if(stft(s)){ // Loop through all the bins for(unsigned k=0; k<stft.numBins(); ++k){ // Here we simply scale the complex sample stft.bin(k) *= 0.2; } } // Get next resynthesized sample s = stft(); io.out(0) = s; io.out(1) = s; } }