MCPcopy Create free account
hub / github.com/ValveSoftware/steam-audio / process

Function process

fmod/src/spatialize_effect.cpp:1024–1298  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1022}
1023
1024FMOD_RESULT F_CALL process(FMOD_DSP_STATE* state,
1025 unsigned int length,
1026 const FMOD_DSP_BUFFER_ARRAY* inBuffers,
1027 FMOD_DSP_BUFFER_ARRAY* outBuffers,
1028 FMOD_BOOL inputsIdle,
1029 FMOD_DSP_PROCESS_OPERATION operation)
1030{
1031 auto effect = reinterpret_cast<State*>(state->plugindata);
1032
1033 auto sourceCoordinates = calcCoordinates(effect->source.absolute);
1034 auto listenerCoordinates = calcListenerCoordinates(state);
1035
1036 if (operation == FMOD_DSP_PROCESS_QUERY)
1037 {
1038 if (!initFmodOutBufferFormat(inBuffers, outBuffers, state, effect->outputFormat))
1039 return FMOD_ERR_DSP_DONTPROCESS;
1040
1041 if (inputsIdle)
1042 {
1043 if (effect->hasTail)
1044 {
1045 effect->shouldProcessTail = true;
1046 }
1047 else
1048 {
1049 // if the sound is idle, we still need to check the expected overall gain to help manage
1050 // channel counts. updateOverallGain won't do any processing - just determine how loud
1051 // the sound would be (according to attenuation, etc) if it were playing.
1052 // Note: the SteamAudio Unity plugin now calculates iplGetDirectSoundPath so this is even lighter
1053 updateOverallGain(state, sourceCoordinates, listenerCoordinates);
1054 return FMOD_ERR_DSP_DONTPROCESS;
1055 }
1056 }
1057 }
1058 else if (operation == FMOD_DSP_PROCESS_PERFORM)
1059 {
1060 updateOverallGain(state, sourceCoordinates, listenerCoordinates);
1061
1062 auto samplingRate = 0;
1063 auto frameSize = 0u;
1064 state->functions->getsamplerate(state, &samplingRate);
1065 state->functions->getblocksize(state, &frameSize);
1066
1067 auto numChannelsIn = inBuffers->buffernumchannels[0];
1068 auto numChannelsOut = outBuffers->buffernumchannels[0];
1069 auto in = inBuffers->buffers[0];
1070 auto out = outBuffers->buffers[0];
1071
1072 // Start by clearing the output buffer.
1073 memset(out, 0, numChannelsOut * frameSize * sizeof(float));
1074
1075 // Make sure that audio processing state has been initialized. If initialization fails, stop and emit silence.
1076 // TODO: if nothing is initialized, do some fallback processing (passthrough, panning, or something like that).
1077 auto initFlags = lazyInit(state, numChannelsIn, numChannelsOut);
1078 if (!(initFlags & INIT_DIRECTAUDIOBUFFERS) || !(initFlags & INIT_BINAURALEFFECT) || !(initFlags & INIT_DIRECTEFFECT))
1079 return FMOD_ERR_DSP_SILENCE;
1080
1081 if (gNewHRTFWritten)

Callers

nothing calls this directly

Calls 15

calcCoordinatesFunction · 0.85
initFmodOutBufferFormatFunction · 0.85
updateOverallGainFunction · 0.85
getDirectParamsFunction · 0.85
calcListenerCoordinatesFunction · 0.70
lazyInitFunction · 0.70
applyVolumeRampFunction · 0.70
numChannelsForOrderFunction · 0.70
numSamplesForDurationFunction · 0.70
iplHRTFReleaseFunction · 0.50
iplHRTFRetainFunction · 0.50
iplSourceReleaseFunction · 0.50

Tested by

no test coverage detected