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

Class delay_processor

example/io_delay.cpp:20–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18using namespace q::literals;
19
20struct delay_processor : q::audio_stream
21{
22 delay_processor(
23 int device_id
24 , q::duration delay
25 , float feedback
26 )
27 : audio_stream(q::audio_device::get(device_id), 1, 2)
28 , _delay(delay, sampling_rate())
29 , _feedback(feedback)
30 {}
31
32 void process(in_channels const& in, out_channels const& out)
33 {
34 auto left = out[0];
35 auto right = out[1];
36 auto ch0 = in[0];
37 for (auto frame : out.frames)
38 {
39 // Get the next input sample
40 auto s = ch0[frame];
41
42 // Mix the signal and the delayed signal
43 _y = s + _delay();
44
45 // Feed back the result to the delay
46 _delay.push(_y * _feedback);
47
48 // Output
49 left[frame] = s;
50 right[frame] = _y;
51 }
52 }
53
54 q::delay _delay;
55 float _feedback;
56 float _y = 0.0f;
57};
58
59int main()
60{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected