const int gFrameSize = 256; const int gFrameSize = 64; const int gFrameSize = 32;
| 38 | //const int gFrameSize = 64; |
| 39 | //const int gFrameSize = 32; |
| 40 | void AudioThread(const int sources, IPLContext context, IPLSimulator simulator, IPLSimulationSettings settings) |
| 41 | { |
| 42 | IPLSourceSettings sourceSettings; |
| 43 | sourceSettings.flags = settings.flags; |
| 44 | |
| 45 | IPLSource source = nullptr; |
| 46 | iplSourceCreate(simulator, &sourceSettings, &source); |
| 47 | iplSourceAdd(source, simulator); |
| 48 | iplSimulatorCommit(simulator); |
| 49 | |
| 50 | IPLSimulationSharedInputs sharedInputs{}; |
| 51 | sharedInputs.listener.origin = IPLVector3{ 0, 1, 0 }; |
| 52 | sharedInputs.numRays = settings.maxNumRays; |
| 53 | sharedInputs.numBounces = 1; |
| 54 | sharedInputs.duration = settings.maxDuration; |
| 55 | sharedInputs.order = settings.maxOrder; |
| 56 | sharedInputs.irradianceMinDistance = 1.0f; |
| 57 | iplSimulatorSetSharedInputs(simulator, IPL_SIMULATIONFLAGS_REFLECTIONS, &sharedInputs); |
| 58 | |
| 59 | IPLSimulationInputs inputs{}; |
| 60 | inputs.flags = (IPLSimulationFlags) (IPL_SIMULATIONFLAGS_REFLECTIONS); |
| 61 | inputs.directFlags = (IPLDirectSimulationFlags) 0; |
| 62 | inputs.source.origin = IPLVector3{ 0, 1, 0 }; |
| 63 | inputs.source.ahead = IPLVector3{ 0, 0, -1 }; |
| 64 | inputs.source.up = IPLVector3{ 0, 1, 0 }; |
| 65 | inputs.source.right = IPLVector3{ 1, 0, 0 }; |
| 66 | inputs.distanceAttenuationModel = IPLDistanceAttenuationModel{}; |
| 67 | inputs.airAbsorptionModel = IPLAirAbsorptionModel{}; |
| 68 | inputs.directivity = IPLDirectivity{}; |
| 69 | inputs.occlusionType = IPL_OCCLUSIONTYPE_RAYCAST; |
| 70 | inputs.occlusionRadius = 0.0f; |
| 71 | inputs.numOcclusionSamples = 0; |
| 72 | for (auto iBand = 0; iBand < ipl::Bands::kNumBands; ++iBand) |
| 73 | inputs.reverbScale[iBand] = 1.0f; |
| 74 | inputs.hybridReverbTransitionTime = 1.0f; |
| 75 | inputs.hybridReverbOverlapPercent = 0.25f; |
| 76 | iplSourceSetInputs(source, IPL_SIMULATIONFLAGS_REFLECTIONS, &inputs); |
| 77 | |
| 78 | iplSimulatorRunReflections(simulator); |
| 79 | |
| 80 | IPLSimulationOutputs outputs{}; |
| 81 | outputs.reflections.type = settings.reflectionType; |
| 82 | outputs.reflections.tanDevice = settings.tanDevice; |
| 83 | iplSourceGetOutputs(source, IPL_SIMULATIONFLAGS_REFLECTIONS, &outputs); |
| 84 | |
| 85 | auto numChannels = (settings.maxOrder + 1) * (settings.maxOrder + 1); |
| 86 | |
| 87 | IPLAudioBuffer dryAudio; |
| 88 | IPLAudioBuffer mixedWetAudio; |
| 89 | iplAudioBufferAllocate(context, 1, gFrameSize, &dryAudio); |
| 90 | iplAudioBufferAllocate(context, numChannels, gFrameSize, &mixedWetAudio); |
| 91 | FillRandomData(dryAudio.data[0], gFrameSize); |
| 92 | |
| 93 | IPLAudioSettings audioSettings{}; |
| 94 | audioSettings.samplingRate = settings.samplingRate; |
| 95 | audioSettings.frameSize = settings.frameSize; |
| 96 | |
| 97 | IPLReflectionEffectSettings effectSettings{}; |
no test coverage detected