-
-
Save PaperSloth/187312edf82aaacefa086cfad9187acc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define WIN32_LEAN_AND_MEAN | |
#include <windows.h> | |
#include <iostream> | |
#include <xaudio2.h> | |
#include <string> | |
#include <wrl/client.h> | |
#include "WAVFileReader.h" | |
#pragma comment(lib,"xaudio2.lib") | |
HRESULT PlayWave(_In_ IXAudio2* pXaudio2, _In_z_ LPCWSTR szFilename); | |
HRESULT FindMediaFileCch(_Out_writes_(cchDest) WCHAR* strDestPath, _In_ int cchDest, _In_z_ LPCWSTR strFilename); | |
int main(int argc, char* argv[]) | |
{ | |
Microsoft::WRL::ComPtr<IXAudio2> pXAudio2 = nullptr; | |
UINT32 flags = 0; | |
HRESULT hr = XAudio2Create(&pXAudio2, flags); | |
if (FAILED(hr)) | |
{ | |
wprintf(L"Failed to init XAudio2 engine: %#X\n", hr); | |
return 1; | |
} | |
CoInitializeEx(nullptr, COINIT_MULTITHREADED); | |
IXAudio2MasteringVoice* pMasteringVoice = nullptr; | |
if (FAILED(hr = pXAudio2->CreateMasteringVoice(&pMasteringVoice))) | |
{ | |
wprintf(L"Failed creating mastering voice: %#X\n", hr); | |
CoUninitialize(); | |
return 1; | |
} | |
if (FAILED(hr = PlayWave(pXAudio2.Get(), L"Resources\\Voice\\再生したよ~!.wav"))) | |
{ | |
wprintf(L"Failed creating source voice: %#X\n", hr); | |
CoUninitialize(); | |
return 1; | |
} | |
pMasteringVoice->DestroyVoice(); | |
CoUninitialize(); | |
return 0; | |
} | |
_Use_decl_annotations_ | |
HRESULT PlayWave(IXAudio2* pXaudio2, LPCWSTR szFilename) | |
{ | |
// 省略 | |
} | |
_Use_decl_annotations_ | |
HRESULT FindMediaFileCch(WCHAR* strDestPath, int cchDest, LPCWSTR strFilename) | |
{ | |
// 省略 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment