MCPcopy Create free account
hub / github.com/cycfi/q / process

Method process

example/square_synth.cpp:33–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31 {}
32
33 void process(out_channels const& out)
34 {
35 auto left = out[0];
36 auto right = out[1];
37 for (auto frame : out.frames)
38 {
39 // Generate the ADSR envelope
40 auto env_ = env() * velocity;
41
42 // Set the filter frequency
43 filter.cutoff(env_);
44
45 // Synthesize the square wave
46 auto val = q::square(phase++);
47
48 // Apply the envelope (amplifier and filter) with soft clip
49 val = clip(filter(val) * env_);
50
51 // Output
52 right[frame] = left[frame] = val;
53 }
54 }
55
56 q::phase_iterator phase; // The phase iterator
57 q::adsr_envelope_gen env; // The envelope generator

Callers 1

mainFunction · 0.45

Calls 2

clipClass · 0.85
cutoffMethod · 0.45

Tested by

no test coverage detected