MCPcopy Create free account
hub / github.com/LancePutnam/Gamma / onAudio

Method onAudio

examples/algorithmic/notesFromSine.cpp:36–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34 }
35
36 void onAudio(AudioIOData& io){
37 while(io()){
38 if(tmr()){
39 // Add to the phase a low-integer division of 2π plus a small
40 // offset for variation.
41 phase = scl::wrapPhase(phase + 2*M_PI / (rnd::prob(0.9)?3:2) + 0.012);
42
43 float frq = sin(phase) * 8;
44
45 // Map sine value to nearest pitch in C-major scale
46 frq = scl::ratioET(scl::nearest(frq, "2212221")) * scl::freq("c4");
47
48 src.freq(frq);
49 env.reset();
50 }
51
52 float s = src() * env() * 0.2;
53
54 io.out(0) = s;
55 io.out(1) = s;
56 }
57 }
58};
59
60int main(){

Callers

nothing calls this directly

Calls 7

wrapPhaseFunction · 0.85
probFunction · 0.85
ratioETFunction · 0.85
freqFunction · 0.85
nearestFunction · 0.50
freqMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected