14 #ifdef HAVE_SSE_INTRINSICS
15 #include <xmmintrin.h>
16 #elif defined(HAVE_NEON)
21 #include "alcomplex.h"
23 #include "alnumbers.h"
24 #include "alnumeric.h"
27 #include "core/ambidefs.h"
28 #include "core/bufferline.h"
29 #include "core/buffer_storage.h"
30 #include "core/context.h"
31 #include "core/devformat.h"
32 #include "core/device.h"
33 #include "core/effectslot.h"
34 #include "core/filters/splitter.h"
35 #include "core/fmt_traits.h"
36 #include "core/mixer.h"
37 #include "intrusive_ptr.h"
38 #include "polyphase_resampler.h"
44 /* Convolution reverb is implemented using a segmented overlap-add method. The
45 * impulse response is broken up into multiple segments of 128 samples, and
46 * each segment has an FFT applied with a 256-sample buffer (the latter half
47 * left silent) to get its frequency-domain response. The resulting response
48 * has its positive/non-mirrored frequencies saved (129 bins) in each segment.
50 * Input samples are similarly broken up into 128-sample segments, with an FFT
51 * applied to each new incoming segment to get its 129 bins. A history of FFT'd
52 * input segments is maintained, equal to the length of the impulse response.
54 * To apply the reverberation, each impulse response segment is convolved with
55 * its paired input segment (using complex multiplies, far cheaper than FIRs),
56 * accumulating into a 256-bin FFT buffer. The input history is then shifted to
57 * align with later impulse response segments for next time.
59 * An inverse FFT is then applied to the accumulated FFT buffer to get a 256-
60 * sample time-domain response for output, which is split in two halves. The
61 * first half is the 128-sample output, and the second half is a 128-sample
62 * (really, 127) delayed extension, which gets added to the output next time.
63 * Convolving two time-domain responses of lengths N and M results in a time-
64 * domain signal of length N+M-1, and this holds true regardless of the
65 * convolution being applied in the frequency domain, so these "overflow"
66 * samples need to be accounted for.
68 * To avoid a delay with gathering enough input samples to apply an FFT with,
69 * the first segment is applied directly in the time-domain as the samples come
70 * in. Once enough have been retrieved, the FFT is applied on the input and
71 * it's paired with the remaining (FFT'd) filter segments for processing.
75 void LoadSamples(double *RESTRICT dst
, const al::byte
*src
, const size_t srcstep
, FmtType srctype
,
76 const size_t samples
) noexcept
78 #define HANDLE_FMT(T) case T: al::LoadSampleArray<T>(dst, src, srcstep, samples); break
84 HANDLE_FMT(FmtDouble
);
92 inline auto& GetAmbiScales(AmbiScaling scaletype
) noexcept
96 case AmbiScaling::FuMa
: return AmbiScale::FromFuMa();
97 case AmbiScaling::SN3D
: return AmbiScale::FromSN3D();
98 case AmbiScaling::UHJ
: return AmbiScale::FromUHJ();
99 case AmbiScaling::N3D
: break;
101 return AmbiScale::FromN3D();
104 inline auto& GetAmbiLayout(AmbiLayout layouttype
) noexcept
106 if(layouttype
== AmbiLayout::FuMa
) return AmbiIndex::FromFuMa();
107 return AmbiIndex::FromACN();
110 inline auto& GetAmbi2DLayout(AmbiLayout layouttype
) noexcept
112 if(layouttype
== AmbiLayout::FuMa
) return AmbiIndex::FromFuMa2D();
113 return AmbiIndex::FromACN2D();
123 constexpr float Deg2Rad(float x
) noexcept
124 { return static_cast<float>(al::numbers::pi
/ 180.0 * x
); }
127 using complex_d
= std::complex<double>;
129 constexpr size_t ConvolveUpdateSize
{256};
130 constexpr size_t ConvolveUpdateSamples
{ConvolveUpdateSize
/ 2};
133 void apply_fir(al::span
<float> dst
, const float *RESTRICT src
, const float *RESTRICT filter
)
135 #ifdef HAVE_SSE_INTRINSICS
136 for(float &output
: dst
)
138 __m128 r4
{_mm_setzero_ps()};
139 for(size_t j
{0};j
< ConvolveUpdateSamples
;j
+=4)
141 const __m128 coeffs
{_mm_load_ps(&filter
[j
])};
142 const __m128 s
{_mm_loadu_ps(&src
[j
])};
144 r4
= _mm_add_ps(r4
, _mm_mul_ps(s
, coeffs
));
146 r4
= _mm_add_ps(r4
, _mm_shuffle_ps(r4
, r4
, _MM_SHUFFLE(0, 1, 2, 3)));
147 r4
= _mm_add_ps(r4
, _mm_movehl_ps(r4
, r4
));
148 output
= _mm_cvtss_f32(r4
);
153 #elif defined(HAVE_NEON)
155 for(float &output
: dst
)
157 float32x4_t r4
{vdupq_n_f32(0.0f
)};
158 for(size_t j
{0};j
< ConvolveUpdateSamples
;j
+=4)
159 r4
= vmlaq_f32(r4
, vld1q_f32(&src
[j
]), vld1q_f32(&filter
[j
]));
160 r4
= vaddq_f32(r4
, vrev64q_f32(r4
));
161 output
= vget_lane_f32(vadd_f32(vget_low_f32(r4
), vget_high_f32(r4
)), 0);
168 for(float &output
: dst
)
171 for(size_t j
{0};j
< ConvolveUpdateSamples
;++j
)
172 ret
+= src
[j
] * filter
[j
];
179 struct ConvolutionState final
: public EffectState
{
180 FmtChannels mChannels
{};
181 AmbiLayout mAmbiLayout
{};
182 AmbiScaling mAmbiScaling
{};
186 std::array
<float,ConvolveUpdateSamples
*2> mInput
{};
187 al::vector
<std::array
<float,ConvolveUpdateSamples
>,16> mFilter
;
188 al::vector
<std::array
<float,ConvolveUpdateSamples
*2>,16> mOutput
;
190 alignas(16) std::array
<complex_d
,ConvolveUpdateSize
> mFftBuffer
{};
192 size_t mCurrentSegment
{0};
193 size_t mNumConvolveSegs
{0};
196 alignas(16) FloatBufferLine mBuffer
{};
198 BandSplitter mFilter
{};
199 float Current
[MAX_OUTPUT_CHANNELS
]{};
200 float Target
[MAX_OUTPUT_CHANNELS
]{};
202 using ChannelDataArray
= al::FlexArray
<ChannelData
>;
203 std::unique_ptr
<ChannelDataArray
> mChans
;
204 std::unique_ptr
<complex_d
[]> mComplexData
;
207 ConvolutionState() = default;
208 ~ConvolutionState() override
= default;
210 void NormalMix(const al::span
<FloatBufferLine
> samplesOut
, const size_t samplesToDo
);
211 void UpsampleMix(const al::span
<FloatBufferLine
> samplesOut
, const size_t samplesToDo
);
212 void (ConvolutionState::*mMix
)(const al::span
<FloatBufferLine
>,const size_t)
213 {&ConvolutionState::NormalMix
};
215 void deviceUpdate(const DeviceBase
*device
, const Buffer
&buffer
) override
;
216 void update(const ContextBase
*context
, const EffectSlot
*slot
, const EffectProps
*props
,
217 const EffectTarget target
) override
;
218 void process(const size_t samplesToDo
, const al::span
<const FloatBufferLine
> samplesIn
,
219 const al::span
<FloatBufferLine
> samplesOut
) override
;
221 DEF_NEWDEL(ConvolutionState
)
224 void ConvolutionState::NormalMix(const al::span
<FloatBufferLine
> samplesOut
,
225 const size_t samplesToDo
)
227 for(auto &chan
: *mChans
)
228 MixSamples({chan
.mBuffer
.data(), samplesToDo
}, samplesOut
, chan
.Current
, chan
.Target
,
232 void ConvolutionState::UpsampleMix(const al::span
<FloatBufferLine
> samplesOut
,
233 const size_t samplesToDo
)
235 for(auto &chan
: *mChans
)
237 const al::span
<float> src
{chan
.mBuffer
.data(), samplesToDo
};
238 chan
.mFilter
.processHfScale(src
, chan
.mHfScale
);
239 MixSamples(src
, samplesOut
, chan
.Current
, chan
.Target
, samplesToDo
, 0);
244 void ConvolutionState::deviceUpdate(const DeviceBase
*device
, const Buffer
&buffer
)
246 constexpr uint MaxConvolveAmbiOrder
{1u};
250 decltype(mFilter
){}.swap(mFilter
);
251 decltype(mOutput
){}.swap(mOutput
);
252 mFftBuffer
.fill(complex_d
{});
255 mNumConvolveSegs
= 0;
258 mComplexData
= nullptr;
260 /* An empty buffer doesn't need a convolution filter. */
261 if(!buffer
.storage
|| buffer
.storage
->mSampleLen
< 1) return;
263 constexpr size_t m
{ConvolveUpdateSize
/2 + 1};
264 auto bytesPerSample
= BytesFromFmt(buffer
.storage
->mType
);
265 auto realChannels
= ChannelsFromFmt(buffer
.storage
->mChannels
, buffer
.storage
->mAmbiOrder
);
266 auto numChannels
= ChannelsFromFmt(buffer
.storage
->mChannels
,
267 minu(buffer
.storage
->mAmbiOrder
, MaxConvolveAmbiOrder
));
269 mChans
= ChannelDataArray::Create(numChannels
);
271 /* The impulse response needs to have the same sample rate as the input and
272 * output. The bsinc24 resampler is decent, but there is high-frequency
273 * attenation that some people may be able to pick up on. Since this is
274 * called very infrequently, go ahead and use the polyphase resampler.
276 PPhaseResampler resampler
;
277 if(device
->Frequency
!= buffer
.storage
->mSampleRate
)
278 resampler
.init(buffer
.storage
->mSampleRate
, device
->Frequency
);
279 const auto resampledCount
= static_cast<uint
>(
280 (uint64_t{buffer
.storage
->mSampleLen
}*device
->Frequency
+(buffer
.storage
->mSampleRate
-1)) /
281 buffer
.storage
->mSampleRate
);
283 const BandSplitter splitter
{device
->mXOverFreq
/ static_cast<float>(device
->Frequency
)};
284 for(auto &e
: *mChans
)
285 e
.mFilter
= splitter
;
287 mFilter
.resize(numChannels
, {});
288 mOutput
.resize(numChannels
, {});
290 /* Calculate the number of segments needed to hold the impulse response and
291 * the input history (rounded up), and allocate them. Exclude one segment
292 * which gets applied as a time-domain FIR filter. Make sure at least one
293 * segment is allocated to simplify handling.
295 mNumConvolveSegs
= (resampledCount
+(ConvolveUpdateSamples
-1)) / ConvolveUpdateSamples
;
296 mNumConvolveSegs
= maxz(mNumConvolveSegs
, 2) - 1;
298 const size_t complex_length
{mNumConvolveSegs
* m
* (numChannels
+1)};
299 mComplexData
= std::make_unique
<complex_d
[]>(complex_length
);
300 std::fill_n(mComplexData
.get(), complex_length
, complex_d
{});
302 mChannels
= buffer
.storage
->mChannels
;
303 mAmbiLayout
= buffer
.storage
->mAmbiLayout
;
304 mAmbiScaling
= buffer
.storage
->mAmbiScaling
;
305 mAmbiOrder
= minu(buffer
.storage
->mAmbiOrder
, MaxConvolveAmbiOrder
);
307 auto srcsamples
= std::make_unique
<double[]>(maxz(buffer
.storage
->mSampleLen
, resampledCount
));
308 complex_d
*filteriter
= mComplexData
.get() + mNumConvolveSegs
*m
;
309 for(size_t c
{0};c
< numChannels
;++c
)
311 /* Load the samples from the buffer, and resample to match the device. */
312 LoadSamples(srcsamples
.get(), buffer
.samples
.data() + bytesPerSample
*c
, realChannels
,
313 buffer
.storage
->mType
, buffer
.storage
->mSampleLen
);
314 if(device
->Frequency
!= buffer
.storage
->mSampleRate
)
315 resampler
.process(buffer
.storage
->mSampleLen
, srcsamples
.get(), resampledCount
,
318 /* Store the first segment's samples in reverse in the time-domain, to
319 * apply as a FIR filter.
321 const size_t first_size
{minz(resampledCount
, ConvolveUpdateSamples
)};
322 std::transform(srcsamples
.get(), srcsamples
.get()+first_size
, mFilter
[c
].rbegin(),
323 [](const double d
) noexcept
-> float { return static_cast<float>(d
); });
325 size_t done
{first_size
};
326 for(size_t s
{0};s
< mNumConvolveSegs
;++s
)
328 const size_t todo
{minz(resampledCount
-done
, ConvolveUpdateSamples
)};
330 auto iter
= std::copy_n(&srcsamples
[done
], todo
, mFftBuffer
.begin());
332 std::fill(iter
, mFftBuffer
.end(), complex_d
{});
334 forward_fft(mFftBuffer
);
335 filteriter
= std::copy_n(mFftBuffer
.cbegin(), m
, filteriter
);
341 void ConvolutionState::update(const ContextBase
*context
, const EffectSlot
*slot
,
342 const EffectProps
* /*props*/, const EffectTarget target
)
344 /* NOTE: Stereo and Rear are slightly different from normal mixing (as
345 * defined in alu.cpp). These are 45 degrees from center, rather than the
346 * 30 degrees used there.
348 * TODO: LFE is not mixed to output. This will require each buffer channel
349 * to have its own output target since the main mixing buffer won't have an
350 * LFE channel (due to being B-Format).
352 static constexpr ChanMap MonoMap
[1]{
353 { FrontCenter
, 0.0f
, 0.0f
}
355 { FrontLeft
, Deg2Rad(-45.0f
), Deg2Rad(0.0f
) },
356 { FrontRight
, Deg2Rad( 45.0f
), Deg2Rad(0.0f
) }
358 { BackLeft
, Deg2Rad(-135.0f
), Deg2Rad(0.0f
) },
359 { BackRight
, Deg2Rad( 135.0f
), Deg2Rad(0.0f
) }
361 { FrontLeft
, Deg2Rad( -45.0f
), Deg2Rad(0.0f
) },
362 { FrontRight
, Deg2Rad( 45.0f
), Deg2Rad(0.0f
) },
363 { BackLeft
, Deg2Rad(-135.0f
), Deg2Rad(0.0f
) },
364 { BackRight
, Deg2Rad( 135.0f
), Deg2Rad(0.0f
) }
366 { FrontLeft
, Deg2Rad( -30.0f
), Deg2Rad(0.0f
) },
367 { FrontRight
, Deg2Rad( 30.0f
), Deg2Rad(0.0f
) },
368 { FrontCenter
, Deg2Rad( 0.0f
), Deg2Rad(0.0f
) },
370 { SideLeft
, Deg2Rad(-110.0f
), Deg2Rad(0.0f
) },
371 { SideRight
, Deg2Rad( 110.0f
), Deg2Rad(0.0f
) }
373 { FrontLeft
, Deg2Rad(-30.0f
), Deg2Rad(0.0f
) },
374 { FrontRight
, Deg2Rad( 30.0f
), Deg2Rad(0.0f
) },
375 { FrontCenter
, Deg2Rad( 0.0f
), Deg2Rad(0.0f
) },
377 { BackCenter
, Deg2Rad(180.0f
), Deg2Rad(0.0f
) },
378 { SideLeft
, Deg2Rad(-90.0f
), Deg2Rad(0.0f
) },
379 { SideRight
, Deg2Rad( 90.0f
), Deg2Rad(0.0f
) }
381 { FrontLeft
, Deg2Rad( -30.0f
), Deg2Rad(0.0f
) },
382 { FrontRight
, Deg2Rad( 30.0f
), Deg2Rad(0.0f
) },
383 { FrontCenter
, Deg2Rad( 0.0f
), Deg2Rad(0.0f
) },
385 { BackLeft
, Deg2Rad(-150.0f
), Deg2Rad(0.0f
) },
386 { BackRight
, Deg2Rad( 150.0f
), Deg2Rad(0.0f
) },
387 { SideLeft
, Deg2Rad( -90.0f
), Deg2Rad(0.0f
) },
388 { SideRight
, Deg2Rad( 90.0f
), Deg2Rad(0.0f
) }
391 if(mNumConvolveSegs
< 1)
394 mMix
= &ConvolutionState::NormalMix
;
396 for(auto &chan
: *mChans
)
397 std::fill(std::begin(chan
.Target
), std::end(chan
.Target
), 0.0f
);
398 const float gain
{slot
->Gain
};
399 /* TODO: UHJ should be decoded to B-Format and processed that way, since
400 * there's no telling if it can ever do a direct-out mix (even if the
401 * device is outputing UHJ, the effect slot can feed another effect that's
404 * Not that UHJ should really ever be used for convolution, but it's a
405 * valid format regardless.
407 if((mChannels
== FmtUHJ2
|| mChannels
== FmtUHJ3
|| mChannels
== FmtUHJ4
) && target
.RealOut
408 && target
.RealOut
->ChannelIndex
[FrontLeft
] != INVALID_CHANNEL_INDEX
409 && target
.RealOut
->ChannelIndex
[FrontRight
] != INVALID_CHANNEL_INDEX
)
411 mOutTarget
= target
.RealOut
->Buffer
;
412 const uint lidx
= target
.RealOut
->ChannelIndex
[FrontLeft
];
413 const uint ridx
= target
.RealOut
->ChannelIndex
[FrontRight
];
414 (*mChans
)[0].Target
[lidx
] = gain
;
415 (*mChans
)[1].Target
[ridx
] = gain
;
417 else if(IsBFormat(mChannels
))
419 DeviceBase
*device
{context
->mDevice
};
420 if(device
->mAmbiOrder
> mAmbiOrder
)
422 mMix
= &ConvolutionState::UpsampleMix
;
423 const auto scales
= AmbiScale::GetHFOrderScales(mAmbiOrder
, device
->mAmbiOrder
);
424 (*mChans
)[0].mHfScale
= scales
[0];
425 for(size_t i
{1};i
< mChans
->size();++i
)
426 (*mChans
)[i
].mHfScale
= scales
[1];
428 mOutTarget
= target
.Main
->Buffer
;
430 auto&& scales
= GetAmbiScales(mAmbiScaling
);
431 const uint8_t *index_map
{(mChannels
== FmtBFormat2D
) ?
432 GetAmbi2DLayout(mAmbiLayout
).data() :
433 GetAmbiLayout(mAmbiLayout
).data()};
435 std::array
<float,MaxAmbiChannels
> coeffs
{};
436 for(size_t c
{0u};c
< mChans
->size();++c
)
438 const size_t acn
{index_map
[c
]};
439 coeffs
[acn
] = scales
[acn
];
440 ComputePanGains(target
.Main
, coeffs
.data(), gain
, (*mChans
)[c
].Target
);
446 DeviceBase
*device
{context
->mDevice
};
447 al::span
<const ChanMap
> chanmap
{};
450 case FmtMono
: chanmap
= MonoMap
; break;
452 case FmtStereo
: chanmap
= StereoMap
; break;
453 case FmtRear
: chanmap
= RearMap
; break;
454 case FmtQuad
: chanmap
= QuadMap
; break;
455 case FmtX51
: chanmap
= X51Map
; break;
456 case FmtX61
: chanmap
= X61Map
; break;
457 case FmtX71
: chanmap
= X71Map
; break;
466 mOutTarget
= target
.Main
->Buffer
;
467 if(device
->mRenderMode
== RenderMode::Pairwise
)
469 auto ScaleAzimuthFront
= [](float azimuth
, float scale
) -> float
471 constexpr float half_pi
{al::numbers::pi_v
<float>*0.5f
};
472 const float abs_azi
{std::fabs(azimuth
)};
473 if(!(abs_azi
>= half_pi
))
474 return std::copysign(minf(abs_azi
*scale
, half_pi
), azimuth
);
478 for(size_t i
{0};i
< chanmap
.size();++i
)
480 if(chanmap
[i
].channel
== LFE
) continue;
481 const auto coeffs
= CalcAngleCoeffs(ScaleAzimuthFront(chanmap
[i
].angle
, 2.0f
),
482 chanmap
[i
].elevation
, 0.0f
);
483 ComputePanGains(target
.Main
, coeffs
.data(), gain
, (*mChans
)[i
].Target
);
486 else for(size_t i
{0};i
< chanmap
.size();++i
)
488 if(chanmap
[i
].channel
== LFE
) continue;
489 const auto coeffs
= CalcAngleCoeffs(chanmap
[i
].angle
, chanmap
[i
].elevation
, 0.0f
);
490 ComputePanGains(target
.Main
, coeffs
.data(), gain
, (*mChans
)[i
].Target
);
495 void ConvolutionState::process(const size_t samplesToDo
,
496 const al::span
<const FloatBufferLine
> samplesIn
, const al::span
<FloatBufferLine
> samplesOut
)
498 if(mNumConvolveSegs
< 1)
501 constexpr size_t m
{ConvolveUpdateSize
/2 + 1};
502 size_t curseg
{mCurrentSegment
};
503 auto &chans
= *mChans
;
505 for(size_t base
{0u};base
< samplesToDo
;)
507 const size_t todo
{minz(ConvolveUpdateSamples
-mFifoPos
, samplesToDo
-base
)};
509 std::copy_n(samplesIn
[0].begin() + base
, todo
,
510 mInput
.begin()+ConvolveUpdateSamples
+mFifoPos
);
512 /* Apply the FIR for the newly retrieved input samples, and combine it
513 * with the inverse FFT'd output samples.
515 for(size_t c
{0};c
< chans
.size();++c
)
517 auto buf_iter
= chans
[c
].mBuffer
.begin() + base
;
518 apply_fir({std::addressof(*buf_iter
), todo
}, mInput
.data()+1 + mFifoPos
,
521 auto fifo_iter
= mOutput
[c
].begin() + mFifoPos
;
522 std::transform(fifo_iter
, fifo_iter
+todo
, buf_iter
, buf_iter
, std::plus
<>{});
528 /* Check whether the input buffer is filled with new samples. */
529 if(mFifoPos
< ConvolveUpdateSamples
) break;
532 /* Move the newest input to the front for the next iteration's history. */
533 std::copy(mInput
.cbegin()+ConvolveUpdateSamples
, mInput
.cend(), mInput
.begin());
535 /* Calculate the frequency domain response and add the relevant
536 * frequency bins to the FFT history.
538 auto fftiter
= std::copy_n(mInput
.cbegin(), ConvolveUpdateSamples
, mFftBuffer
.begin());
539 std::fill(fftiter
, mFftBuffer
.end(), complex_d
{});
540 forward_fft(mFftBuffer
);
542 std::copy_n(mFftBuffer
.cbegin(), m
, &mComplexData
[curseg
*m
]);
544 const complex_d
*RESTRICT filter
{mComplexData
.get() + mNumConvolveSegs
*m
};
545 for(size_t c
{0};c
< chans
.size();++c
)
547 std::fill_n(mFftBuffer
.begin(), m
, complex_d
{});
549 /* Convolve each input segment with its IR filter counterpart
552 const complex_d
*RESTRICT input
{&mComplexData
[curseg
*m
]};
553 for(size_t s
{curseg
};s
< mNumConvolveSegs
;++s
)
555 for(size_t i
{0};i
< m
;++i
,++input
,++filter
)
556 mFftBuffer
[i
] += *input
* *filter
;
558 input
= mComplexData
.get();
559 for(size_t s
{0};s
< curseg
;++s
)
561 for(size_t i
{0};i
< m
;++i
,++input
,++filter
)
562 mFftBuffer
[i
] += *input
* *filter
;
565 /* Reconstruct the mirrored/negative frequencies to do a proper
568 for(size_t i
{m
};i
< ConvolveUpdateSize
;++i
)
569 mFftBuffer
[i
] = std::conj(mFftBuffer
[ConvolveUpdateSize
-i
]);
571 /* Apply iFFT to get the 256 (really 255) samples for output. The
572 * 128 output samples are combined with the last output's 127
573 * second-half samples (and this output's second half is
574 * subsequently saved for next time).
576 inverse_fft(mFftBuffer
);
578 /* The iFFT'd response is scaled up by the number of bins, so apply
579 * the inverse to normalize the output.
581 for(size_t i
{0};i
< ConvolveUpdateSamples
;++i
)
583 static_cast<float>(mFftBuffer
[i
].real() * (1.0/double{ConvolveUpdateSize
})) +
584 mOutput
[c
][ConvolveUpdateSamples
+i
];
585 for(size_t i
{0};i
< ConvolveUpdateSamples
;++i
)
586 mOutput
[c
][ConvolveUpdateSamples
+i
] =
587 static_cast<float>(mFftBuffer
[ConvolveUpdateSamples
+i
].real() *
588 (1.0/double{ConvolveUpdateSize
}));
591 /* Shift the input history. */
592 curseg
= curseg
? (curseg
-1) : (mNumConvolveSegs
-1);
594 mCurrentSegment
= curseg
;
596 /* Finally, mix to the output. */
597 (this->*mMix
)(samplesOut
, samplesToDo
);
601 struct ConvolutionStateFactory final
: public EffectStateFactory
{
602 al::intrusive_ptr
<EffectState
> create() override
603 { return al::intrusive_ptr
<EffectState
>{new ConvolutionState
{}}; }
608 EffectStateFactory
*ConvolutionStateFactory_getFactory()
610 static ConvolutionStateFactory ConvolutionFactory
{};
611 return &ConvolutionFactory
;