| 420 | |
| 421 | |
| 422 | void Compressor::process(const ALuint SamplesToDo, FloatBufferLine *OutBuffer) |
| 423 | { |
| 424 | const ALuint numChans{mNumChans}; |
| 425 | |
| 426 | ASSUME(SamplesToDo > 0); |
| 427 | ASSUME(numChans > 0); |
| 428 | |
| 429 | const ALfloat preGain{mPreGain}; |
| 430 | if(preGain != 1.0f) |
| 431 | { |
| 432 | auto apply_gain = [SamplesToDo,preGain](FloatBufferLine &input) noexcept -> void |
| 433 | { |
| 434 | ALfloat *buffer{al::assume_aligned<16>(input.data())}; |
| 435 | std::transform(buffer, buffer+SamplesToDo, buffer, |
| 436 | std::bind(std::multiplies<float>{}, _1, preGain)); |
| 437 | }; |
| 438 | std::for_each(OutBuffer, OutBuffer+numChans, apply_gain); |
| 439 | } |
| 440 | |
| 441 | LinkChannels(this, SamplesToDo, OutBuffer); |
| 442 | |
| 443 | if(mAuto.Attack || mAuto.Release) |
| 444 | CrestDetector(this, SamplesToDo); |
| 445 | |
| 446 | if(mHold) |
| 447 | PeakHoldDetector(this, SamplesToDo); |
| 448 | else |
| 449 | PeakDetector(this, SamplesToDo); |
| 450 | |
| 451 | GainCompressor(this, SamplesToDo); |
| 452 | |
| 453 | if(mDelay) |
| 454 | SignalDelay(this, SamplesToDo, OutBuffer); |
| 455 | |
| 456 | const ALfloat (&sideChain)[BUFFERSIZE*2] = mSideChain; |
| 457 | auto apply_comp = [SamplesToDo,&sideChain](FloatBufferLine &input) noexcept -> void |
| 458 | { |
| 459 | ALfloat *buffer{al::assume_aligned<16>(input.data())}; |
| 460 | const ALfloat *gains{al::assume_aligned<16>(&sideChain[0])}; |
| 461 | std::transform(gains, gains+SamplesToDo, buffer, buffer, |
| 462 | std::bind(std::multiplies<float>{}, _1, _2)); |
| 463 | }; |
| 464 | std::for_each(OutBuffer, OutBuffer+numChans, apply_comp); |
| 465 | |
| 466 | auto side_begin = std::begin(mSideChain) + SamplesToDo; |
| 467 | std::copy(side_begin, side_begin+mLookAhead, std::begin(mSideChain)); |
| 468 | } |
no test coverage detected