| 66 | } |
| 67 | |
| 68 | InitFlags lazyInit(UnityAudioEffectState* state, |
| 69 | int numChannelsIn, |
| 70 | int numChannelsOut) |
| 71 | { |
| 72 | assert(state); |
| 73 | |
| 74 | auto initFlags = INIT_NONE; |
| 75 | |
| 76 | if (!gContext) |
| 77 | return initFlags; |
| 78 | |
| 79 | if (!gHRTF[1]) |
| 80 | return initFlags; |
| 81 | |
| 82 | if (!state->effectdata) |
| 83 | { |
| 84 | state->effectdata = new State(); |
| 85 | reset(state); |
| 86 | } |
| 87 | |
| 88 | auto effect = state->GetEffectData<State>(); |
| 89 | if (!effect) |
| 90 | return initFlags; |
| 91 | |
| 92 | IPLAudioSettings audioSettings; |
| 93 | audioSettings.samplingRate = state->samplerate; |
| 94 | audioSettings.frameSize = state->dspbuffersize; |
| 95 | |
| 96 | auto status = IPL_STATUS_SUCCESS; |
| 97 | |
| 98 | if (gIsSimulationSettingsValid) |
| 99 | { |
| 100 | status = IPL_STATUS_SUCCESS; |
| 101 | |
| 102 | if (!effect->reflectionEffect) |
| 103 | { |
| 104 | IPLReflectionEffectSettings effectSettings; |
| 105 | effectSettings.type = gSimulationSettings.reflectionType; |
| 106 | effectSettings.irSize = numSamplesForDuration(gSimulationSettings.maxDuration, audioSettings.samplingRate); |
| 107 | effectSettings.numChannels = numChannelsForOrder(gSimulationSettings.maxOrder); |
| 108 | |
| 109 | status = iplReflectionEffectCreate(gContext, &audioSettings, &effectSettings, &effect->reflectionEffect); |
| 110 | } |
| 111 | |
| 112 | if (status == IPL_STATUS_SUCCESS) |
| 113 | initFlags = static_cast<InitFlags>(initFlags | INIT_REFLECTIONEFFECT); |
| 114 | } |
| 115 | |
| 116 | if (numChannelsOut > 0 && gIsSimulationSettingsValid) |
| 117 | { |
| 118 | status = IPL_STATUS_SUCCESS; |
| 119 | |
| 120 | if (!effect->ambisonicsEffect) |
| 121 | { |
| 122 | IPLAmbisonicsDecodeEffectSettings effectSettings; |
| 123 | effectSettings.speakerLayout = speakerLayoutForNumChannels(numChannelsOut); |
| 124 | effectSettings.hrtf = gHRTF[1]; |
| 125 | effectSettings.maxOrder = gSimulationSettings.maxOrder; |
no test coverage detected