Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I figured out you have to go through COM and CoCreateInstance(). Something like</p> <pre><code>#include &lt;windows.h&gt; #include &lt;stdio.h&gt; #include &lt;XAudio2.h&gt; int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) { WAVEFORMATEX format; format.wFormatTag = 1; format.nChannels = 1; format.nSamplesPerSec = 44100; format.nAvgBytesPerSec = 44100; format.nBlockAlign = 1; format.wBitsPerSample = 8; format.cbSize = 0; CoInitializeEx(NULL, COINIT_MULTITHREADED); IXAudio2* pXAudio2 = NULL; IXAudio2SourceVoice* source = NULL; IXAudio2MasteringVoice* master = NULL; HRESULT hr; if ( FAILED(hr = XAudio2Create( &amp;pXAudio2, 0, XAUDIO2_DEFAULT_PROCESSOR ) ) ) { MessageBox(0, L"hi", L"hi", 0); } if ( FAILED(hr = pXAudio2-&gt;CreateMasteringVoice(&amp;master ) ) ) { MessageBox(0, L"hi", L"hi", 0); } if ( FAILED(hr = pXAudio2-&gt;CreateSourceVoice(&amp;source, &amp;format) ) ) { MessageBox(0, L"hi", L"hi", 0); } char str[30]; float freq = 0.0; source-&gt;GetFrequencyRatio(&amp;freq); sprintf(str, "%f", freq); MessageBoxA(0, str, str, 0); UINT32 OperationSetCounter = 0; UINT32 OperationID = UINT32(InterlockedIncrement(LPLONG(&amp;OperationSetCounter))); if ( FAILED(hr = source-&gt;SetFrequencyRatio(1.1,OperationID ) ) ) { MessageBox(0, L"hi", L"hi", 0); } if ( FAILED(hr = pXAudio2-&gt;CommitChanges(OperationID ) ) ) { MessageBox(0, L"hi", L"hi", 0); } float freq2 = 0.0; source-&gt;GetFrequencyRatio(&amp;freq2); sprintf(str, "%f", freq2); MessageBoxA(0, str, str, 0); Sleep(2000); float freq3 = 0.0; source-&gt;GetFrequencyRatio(&amp;freq3); sprintf(str, "%f", freq3); if (freq3 != 1.0) { MessageBoxA(0, str, str, 0); } source-&gt;Start(0); return 0; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload