| 57 | } |
| 58 | |
| 59 | void processSubBlock (const choc::audio::AudioMIDIBlockDispatcher::Block& block, |
| 60 | bool replaceOutput) override |
| 61 | { |
| 62 | auto& output = block.audioOutput; |
| 63 | |
| 64 | if (! isPlaying) |
| 65 | { |
| 66 | if (replaceOutput) |
| 67 | output.clear(); |
| 68 | |
| 69 | return; |
| 70 | } |
| 71 | |
| 72 | auto numFrames = output.getNumFrames(); |
| 73 | auto numChannels = output.getNumChannels(); |
| 74 | |
| 75 | for (uint32_t frame = 0; frame < numFrames; ++frame) |
| 76 | { |
| 77 | if (samplesPlayed >= maxSamples) |
| 78 | { |
| 79 | isPlaying = false; |
| 80 | |
| 81 | for (uint32_t channel = 0; channel < numChannels; ++channel) |
| 82 | output.getSample (channel, frame) = 0.0f; |
| 83 | |
| 84 | continue; |
| 85 | } |
| 86 | |
| 87 | auto sample = sineWave.getSample() * 0.1f; |
| 88 | |
| 89 | for (uint32_t channel = 0; channel < numChannels; ++channel) |
| 90 | { |
| 91 | if (replaceOutput) |
| 92 | output.getSample (channel, frame) = sample; |
| 93 | else |
| 94 | output.getSample (channel, frame) += sample; |
| 95 | } |
| 96 | |
| 97 | ++samplesPlayed; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | void endBlock() override |
| 102 | { |
no test coverage detected