| 393 | |
| 394 | |
| 395 | void Compressor::process(const uint SamplesToDo, FloatBufferLine *OutBuffer) |
| 396 | { |
| 397 | const size_t numChans{mNumChans}; |
| 398 | |
| 399 | ASSUME(SamplesToDo > 0); |
| 400 | ASSUME(numChans > 0); |
| 401 | |
| 402 | const float preGain{mPreGain}; |
| 403 | if(preGain != 1.0f) |
| 404 | { |
| 405 | auto apply_gain = [SamplesToDo,preGain](FloatBufferLine &input) noexcept -> void |
| 406 | { |
| 407 | float *buffer{al::assume_aligned<16>(input.data())}; |
| 408 | std::transform(buffer, buffer+SamplesToDo, buffer, |
| 409 | std::bind(std::multiplies<float>{}, _1, preGain)); |
| 410 | }; |
| 411 | std::for_each(OutBuffer, OutBuffer+numChans, apply_gain); |
| 412 | } |
| 413 | |
| 414 | LinkChannels(this, SamplesToDo, OutBuffer); |
| 415 | |
| 416 | if(mAuto.Attack || mAuto.Release) |
| 417 | CrestDetector(this, SamplesToDo); |
| 418 | |
| 419 | if(mHold) |
| 420 | PeakHoldDetector(this, SamplesToDo); |
| 421 | else |
| 422 | PeakDetector(this, SamplesToDo); |
| 423 | |
| 424 | GainCompressor(this, SamplesToDo); |
| 425 | |
| 426 | if(mDelay) |
| 427 | SignalDelay(this, SamplesToDo, OutBuffer); |
| 428 | |
| 429 | const float (&sideChain)[BufferLineSize*2] = mSideChain; |
| 430 | auto apply_comp = [SamplesToDo,&sideChain](FloatBufferLine &input) noexcept -> void |
| 431 | { |
| 432 | float *buffer{al::assume_aligned<16>(input.data())}; |
| 433 | const float *gains{al::assume_aligned<16>(&sideChain[0])}; |
| 434 | std::transform(gains, gains+SamplesToDo, buffer, buffer, |
| 435 | std::bind(std::multiplies<float>{}, _1, _2)); |
| 436 | }; |
| 437 | std::for_each(OutBuffer, OutBuffer+numChans, apply_comp); |
| 438 | |
| 439 | auto side_begin = std::begin(mSideChain) + SamplesToDo; |
| 440 | std::copy(side_begin, side_begin+mLookAhead, std::begin(mSideChain)); |
| 441 | } |
no test coverage detected