| 67 | } |
| 68 | |
| 69 | AudioEffectState AmbisonicsDecodeEffect::apply(const AmbisonicsDecodeEffectParams& params, |
| 70 | const AudioBuffer& in, |
| 71 | AudioBuffer& out) |
| 72 | { |
| 73 | AmbisonicsRotateEffectParams rotateParams{}; |
| 74 | rotateParams.orientation = params.orientation; |
| 75 | rotateParams.order = params.order; |
| 76 | |
| 77 | mRotateEffect->apply(rotateParams, in, mRotated); |
| 78 | |
| 79 | auto binaural = (params.binaural && mSpeakerLayout.type == SpeakerLayoutType::Stereo && params.hrtf && mBinauralEffect); |
| 80 | |
| 81 | if (binaural && !mPrevBinaural) |
| 82 | { |
| 83 | mPanningEffect->reset(); |
| 84 | } |
| 85 | else if (!binaural && mPrevBinaural && mBinauralEffect) |
| 86 | { |
| 87 | mBinauralEffect->reset(); |
| 88 | } |
| 89 | |
| 90 | AudioEffectState effectState = AudioEffectState::TailComplete; |
| 91 | |
| 92 | if (binaural) |
| 93 | { |
| 94 | AmbisonicsBinauralEffectParams binauralParams{}; |
| 95 | binauralParams.hrtf = params.hrtf; |
| 96 | binauralParams.order = params.order; |
| 97 | |
| 98 | effectState = mBinauralEffect->apply(binauralParams, mRotated, out); |
| 99 | } |
| 100 | else |
| 101 | { |
| 102 | AmbisonicsPanningEffectParams panningParams{}; |
| 103 | panningParams.order = params.order; |
| 104 | |
| 105 | effectState = mPanningEffect->apply(panningParams, mRotated, out); |
| 106 | } |
| 107 | |
| 108 | mPrevBinaural = binaural; |
| 109 | |
| 110 | return effectState; |
| 111 | } |
| 112 | |
| 113 | AudioEffectState AmbisonicsDecodeEffect::tail(AudioBuffer& out) |
| 114 | { |