| 314 | } |
| 315 | |
| 316 | void SteamAudioSpatializerFX::Execute(AkAudioBuffer* in_pBuffer, AkUInt32 in_uInOffset, AkAudioBuffer* out_pBuffer) |
| 317 | { |
| 318 | AKASSERT(in_pBuffer->uValidFrames == out_pBuffer->MaxFrames()); |
| 319 | AKASSERT(in_uInOffset == 0); |
| 320 | |
| 321 | // -- clear actual output |
| 322 | |
| 323 | for (AkUInt32 i = 0; i < out_pBuffer->NumChannels(); ++i) |
| 324 | { |
| 325 | memset(out_pBuffer->GetChannel(i), 0, out_pBuffer->MaxFrames() * sizeof(float)); |
| 326 | } |
| 327 | |
| 328 | // -- ensure everything is initialized |
| 329 | |
| 330 | if (LazyInit() != AK_Success) |
| 331 | { |
| 332 | out_pBuffer->eState = AK_Fail; |
| 333 | return; |
| 334 | } |
| 335 | |
| 336 | auto& globalState = SteamAudioWwise::GlobalState::Get(); |
| 337 | |
| 338 | auto context = globalState.context.Read(); |
| 339 | auto hrtf = globalState.hrtf.Read(); |
| 340 | |
| 341 | // -- update source for simulation reasons |
| 342 | |
| 343 | AkGameObjectID gameObjectID = m_context->GetGameObjectInfo()->GetGameObjectID(); |
| 344 | if (gameObjectID != m_prevGameObjectID) |
| 345 | { |
| 346 | m_source = globalState.sourceMap.Get(gameObjectID); |
| 347 | m_prevGameObjectID = gameObjectID; |
| 348 | } |
| 349 | |
| 350 | auto source = m_source ? m_source->Read() : nullptr; |
| 351 | |
| 352 | IPLSimulationOutputs sourceOutputs{}; |
| 353 | iplSourceGetOutputs(source, (IPLSimulationFlags) (IPL_SIMULATIONFLAGS_DIRECT | IPL_SIMULATIONFLAGS_REFLECTIONS | IPL_SIMULATIONFLAGS_PATHING), &sourceOutputs); |
| 354 | |
| 355 | // -- clear input |
| 356 | |
| 357 | for (IPLint32 i = 0; i < m_inBuffer.numChannels; ++i) |
| 358 | { |
| 359 | memset(m_inBuffer.data[i], 0, m_inBuffer.numSamples * sizeof(IPLfloat32)); |
| 360 | } |
| 361 | |
| 362 | // -- copy input |
| 363 | |
| 364 | auto numSamplesConsumed = std::min(in_pBuffer->uValidFrames, (AkUInt16) m_inBuffer.numSamples); |
| 365 | for (AkUInt32 i = 0; i < std::min(in_pBuffer->NumChannels(), (AkUInt32) m_inBuffer.numChannels); ++i) |
| 366 | { |
| 367 | memcpy(m_inBuffer.data[i], in_pBuffer->GetChannel(i), numSamplesConsumed * sizeof(IPLfloat32)); |
| 368 | } |
| 369 | |
| 370 | // -- calculate source and listener positions |
| 371 | |
| 372 | bool bUseGamePosition = !SteamAudioWwise::IsRunningInEditor(); |
| 373 | IPLCoordinateSpace3 listenerCoords{}; |
nothing calls this directly
no test coverage detected