| 90 | } |
| 91 | |
| 92 | bool PerTrackEffect::ProcessPass(TrackList &outputs, |
| 93 | Instance &instance, EffectSettings &settings) |
| 94 | { |
| 95 | const auto duration = settings.extra.GetDuration(); |
| 96 | bool bGoodResult = true; |
| 97 | bool isGenerator = GetType() == EffectTypeGenerate; |
| 98 | bool isProcessor = GetType() == EffectTypeProcess; |
| 99 | |
| 100 | Buffers inBuffers, outBuffers; |
| 101 | ChannelName map[3]; |
| 102 | size_t prevBufferSize = 0; |
| 103 | int count = 0; |
| 104 | bool clear = false; |
| 105 | |
| 106 | // It's possible that the number of channels the effect expects changed based on |
| 107 | // the parameters (the Audacity Reverb effect does when the stereo width is 0). |
| 108 | const auto numAudioIn = instance.GetAudioInCount(); |
| 109 | const auto numAudioOut = instance.GetAudioOutCount(); |
| 110 | if (numAudioOut < 1) |
| 111 | return false; |
| 112 | |
| 113 | // Instances that can be reused in each loop pass |
| 114 | std::vector<std::shared_ptr<EffectInstance>> recycledInstances{ |
| 115 | // First one is the given one; any others pushed onto here are |
| 116 | // discarded when we exit |
| 117 | std::dynamic_pointer_cast<EffectInstanceEx>(instance.shared_from_this()) |
| 118 | }; |
| 119 | |
| 120 | const bool multichannel = numAudioIn > 1; |
| 121 | int iChannel = 0; |
| 122 | TrackListHolder results; |
| 123 | const auto waveTrackVisitor = |
| 124 | [&](WaveTrack &wt, WaveChannel &chan, bool isFirst) { |
| 125 | if (isFirst) |
| 126 | iChannel = 0; |
| 127 | |
| 128 | sampleCount len = 0; |
| 129 | sampleCount start = 0; |
| 130 | WaveChannel *pRight{}; |
| 131 | |
| 132 | const int channel = (multichannel ? -1 : iChannel++); |
| 133 | const auto numChannels = MakeChannelMap(wt.NChannels(), channel, map); |
| 134 | if (multichannel) { |
| 135 | assert(numAudioIn > 1); |
| 136 | if (numChannels == 2) { |
| 137 | // TODO: more-than-two-channels |
| 138 | pRight = (*wt.Channels().rbegin()).get(); |
| 139 | clear = false; |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | if (!isGenerator) { |
| 144 | GetBounds(wt, &start, &len); |
| 145 | mSampleCnt = len; |
| 146 | if (len > 0 && numAudioIn < 1) { |
| 147 | bGoodResult = false; |
| 148 | return; |
| 149 | } |
no test coverage detected