| 17 | using namespace q::literals; |
| 18 | |
| 19 | struct delay_processor : q::audio_stream |
| 20 | { |
| 21 | delay_processor( |
| 22 | float* wav |
| 23 | , float sps |
| 24 | , q::duration delay |
| 25 | , float feedback |
| 26 | ) |
| 27 | : audio_stream(0, 2, sps) |
| 28 | , _wav(wav) |
| 29 | , _delay(delay, sps) |
| 30 | , _feedback(feedback) |
| 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 | // Get the next input sample |
| 40 | auto s = *_wav++; |
| 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 | float* _wav; |
| 55 | q::delay _delay; |
| 56 | float _feedback; |
| 57 | float _y = 0.0f; |
| 58 | }; |
| 59 | |
| 60 | int main() |
| 61 | { |
nothing calls this directly
no outgoing calls
no test coverage detected