本文整理汇总了C++中LFO::cosU方法的典型用法代码示例。如果您正苦于以下问题:C++ LFO::cosU方法的具体用法?C++ LFO::cosU怎么用?C++ LFO::cosU使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LFO
的用法示例。
在下文中一共展示了LFO::cosU方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onAudio
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;
}
}
示例2: audioCB
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;
}
}