MCPcopy Create free account
hub / github.com/StereoKit/StereoKit / FindAcceptableWaveformat

Function FindAcceptableWaveformat

StereoKitC/libraries/isac_spatial_sound.cpp:182–202  ·  view source on GitHub ↗

Given an activated ISpatialAudioClient interface, finds the supported WAVEFORMATEX that matches our needs We only operate in 48kHz float. If that's supported, it is returned. Otherwise, this function fails

Source from the content-addressed store, hash-verified

180// Given an activated ISpatialAudioClient interface, finds the supported WAVEFORMATEX that matches our needs
181// We only operate in 48kHz float. If that's supported, it is returned. Otherwise, this function fails
182HRESULT FindAcceptableWaveformat(ISpatialAudioClient* isac, WAVEFORMATEX* objectFormat) {
183 // Initialize ISAC with its preferred format
184 ComPtr<IAudioFormatEnumerator> audioObjectFormatEnumerator;
185 RETURN_IF_FAILED(isac->GetSupportedAudioObjectFormatEnumerator(&audioObjectFormatEnumerator));
186 UINT32 audioObjectFormatCount = 0;
187 RETURN_IF_FAILED(audioObjectFormatEnumerator->GetCount(&audioObjectFormatCount));
188 RETURN_HR_IF(E_FAIL, audioObjectFormatCount == 0);
189
190 // Find the first format that's in 48kHz, float. This is the best supported format
191 for (uint32_t i = 0u; i < audioObjectFormatCount; i++) {
192 WAVEFORMATEX* format = nullptr;
193 RETURN_IF_FAILED(audioObjectFormatEnumerator->GetFormat(0, &format));
194 if (format->nSamplesPerSec == c_HrtfSampleRate && format->wFormatTag == WAVE_FORMAT_IEEE_FLOAT) {
195 *objectFormat = *format;
196 break;
197 }
198 }
199 RETURN_HR_IF_NULL(E_NOT_VALID_STATE, objectFormat);
200
201 return S_OK;
202}
203
204///////////////////////////////////////////
205

Callers 1

ActivateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected