如何加载 mp3 声音文件并在我的 Windows 8 应用程序中播放?我找不到可以帮助我理解我必须做什么的教程?
到目前为止,我所做的只是:
声音.h
#pragma once
#include <xaudio2.h>
class Sound
{
Sound( );
void Initialize();
void Play( wchar_t fileName );
private:
interface IXAudio2* audioEngine;
interface IXAudio2MasteringVoice* masteringVoice;
IXAudio2SourceVoice* sourceVoice;
WAVEFORMATEX* format;
};
声音.cpp
#include "pch.h"
#include "Sound.h"
Sound::Sound()
{}
void Sound::Initialize()
{
// Create the XAudio2 Engine
UINT32 flags = 0;
XAudio2Create( &audioEngine, flags );
// Create the mastering voice
audioEngine->CreateMasteringVoice(
&masteringVoice,
XAUDIO2_DEFAULT_CHANNELS,
48000
);
//
// Create the source voice
//
audioEngine->CreateSourceVoice(
&sourceVoice,
format,
0,
XAUDIO2_DEFAULT_FREQ_RATIO,
nullptr,
nullptr,
nullptr
);
}
void Sound::Play( wchar_t fileName )
{
// To do:
// Load sound file and play it
}
我什至不知道我所做的是否正确......